add code inline doc
This commit is contained in:
parent
285ca702dd
commit
4cdaef23ee
5 changed files with 65 additions and 19 deletions
|
@ -21,16 +21,14 @@ use dcFavorites;
|
||||||
use dcNsProcess;
|
use dcNsProcess;
|
||||||
use dcPage;
|
use dcPage;
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage contributions list
|
|
||||||
*/
|
|
||||||
class Backend extends dcNsProcess
|
class Backend extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
&& dcCore::app()->auth?->isSuperAdmin()
|
&& My::phpCompliant()
|
||||||
&& My::phpCompliant();
|
&& !is_null(dcCore::app()->auth)
|
||||||
|
&& dcCore::app()->auth->isSuperAdmin();
|
||||||
|
|
||||||
return static::$init;
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +39,7 @@ class Backend extends dcNsProcess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// backend sidebar menu icon
|
||||||
dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem(
|
||||||
My::name(),
|
My::name(),
|
||||||
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||||
|
@ -50,6 +49,7 @@ class Backend extends dcNsProcess
|
||||||
);
|
);
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
|
// backend user preference for logs list columns
|
||||||
'adminColumnsListsV2' => function (ArrayObject $cols): void {
|
'adminColumnsListsV2' => function (ArrayObject $cols): void {
|
||||||
$cols[My::BACKEND_LIST_ID] = [
|
$cols[My::BACKEND_LIST_ID] = [
|
||||||
My::name(),
|
My::name(),
|
||||||
|
@ -63,7 +63,7 @@ class Backend extends dcNsProcess
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
// backend filter for logs list sort
|
||||||
'adminFiltersListsV2' => function (ArrayObject $sorts): void {
|
'adminFiltersListsV2' => function (ArrayObject $sorts): void {
|
||||||
$sorts[My::BACKEND_LIST_ID] = [
|
$sorts[My::BACKEND_LIST_ID] = [
|
||||||
My::name(),
|
My::name(),
|
||||||
|
@ -80,7 +80,7 @@ class Backend extends dcNsProcess
|
||||||
[__('Logs per page'), 30],
|
[__('Logs per page'), 30],
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
// backend user preference for dashboard icon
|
||||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||||
$favs->register(My::BACKEND_LIST_ID, [
|
$favs->register(My::BACKEND_LIST_ID, [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
|
|
|
@ -21,8 +21,19 @@ use Dotclear\Helper\Date;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Html\Form\Checkbox;
|
use Dotclear\Helper\Html\Form\Checkbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backend logs list helper.
|
||||||
|
*/
|
||||||
class BackendList extends adminGenericListV2
|
class BackendList extends adminGenericListV2
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Display logs record.
|
||||||
|
*
|
||||||
|
* @param int $page The current list page
|
||||||
|
* @param int $nb_per_page The record per page number
|
||||||
|
* @param string $enclose_block The enclose block
|
||||||
|
* @param bool $filter Filter is applied
|
||||||
|
*/
|
||||||
public function display(int $page, int $nb_per_page, string $enclose_block = '', bool $filter = false): void
|
public function display(int $page, int $nb_per_page, string $enclose_block = '', bool $filter = false): void
|
||||||
{
|
{
|
||||||
if ($this->rs->isEmpty()) {
|
if ($this->rs->isEmpty()) {
|
||||||
|
@ -73,6 +84,11 @@ class BackendList extends adminGenericListV2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a records line.
|
||||||
|
*
|
||||||
|
* @param bool $checked Selected line
|
||||||
|
*/
|
||||||
private function logLine(bool $checked): void
|
private function logLine(bool $checked): void
|
||||||
{
|
{
|
||||||
$cols = [
|
$cols = [
|
||||||
|
|
|
@ -35,8 +35,9 @@ class Manage extends dcNsProcess
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
&& dcCore::app()->auth?->isSuperAdmin()
|
&& My::phpCompliant()
|
||||||
&& My::phpCompliant();
|
&& !is_null(dcCore::app()->auth)
|
||||||
|
&& dcCore::app()->auth->isSuperAdmin();
|
||||||
|
|
||||||
return static::$init;
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +50,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
$current = ManageVars::init();
|
$current = ManageVars::init();
|
||||||
|
|
||||||
# Delete logs
|
// Delete logs
|
||||||
if ($current->selected_logs && !empty($current->entries) || $current->all_logs) {
|
if ($current->selected_logs && !empty($current->entries) || $current->all_logs) {
|
||||||
try {
|
try {
|
||||||
dcCore::app()->log->delLogs($current->entries, $current->all_logs);
|
dcCore::app()->log->delLogs($current->entries, $current->all_logs);
|
||||||
|
|
|
@ -20,20 +20,35 @@ use dcCore;
|
||||||
use Dotclear\Database\MetaRecord;
|
use Dotclear\Database\MetaRecord;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backend logs manage page vars container.
|
||||||
|
*/
|
||||||
class ManageVars
|
class ManageVars
|
||||||
{
|
{
|
||||||
/**
|
/** @var ManageVars $container self instance */
|
||||||
* @var ManageVars self instance
|
|
||||||
*/
|
|
||||||
private static $container;
|
private static $container;
|
||||||
|
|
||||||
|
/** @var adminGenericFilterV2 $filter The filter instance */
|
||||||
public readonly adminGenericFilterV2 $filter;
|
public readonly adminGenericFilterV2 $filter;
|
||||||
|
|
||||||
|
/** @var null|MetaRecord $logs The current records */
|
||||||
public readonly ?MetaRecord $logs;
|
public readonly ?MetaRecord $logs;
|
||||||
|
|
||||||
|
/** @var null|BackendList $list The records list form instance */
|
||||||
public readonly ?BackendList $list;
|
public readonly ?BackendList $list;
|
||||||
|
|
||||||
|
/** @var array $entries The post form selected entries */
|
||||||
public readonly array $entries;
|
public readonly array $entries;
|
||||||
|
|
||||||
|
/** @var bool $selected_logs The post form action */
|
||||||
public readonly bool $selected_logs;
|
public readonly bool $selected_logs;
|
||||||
|
|
||||||
|
/** @var bool $all_logs The post form action */
|
||||||
public readonly bool $all_logs;
|
public readonly bool $all_logs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor grabs post form value and sets properties.
|
||||||
|
*/
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$this->entries = !empty($_POST['entries']) && is_array($_POST['entries']) ? $_POST['entries'] : [];
|
$this->entries = !empty($_POST['entries']) && is_array($_POST['entries']) ? $_POST['entries'] : [];
|
||||||
|
@ -57,6 +72,11 @@ class ManageVars
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get instance.
|
||||||
|
*
|
||||||
|
* @return ManageVars The instance
|
||||||
|
*/
|
||||||
public static function init(): ManageVars
|
public static function init(): ManageVars
|
||||||
{
|
{
|
||||||
if (!(self::$container instanceof self)) {
|
if (!(self::$container instanceof self)) {
|
||||||
|
|
15
src/My.php
15
src/My.php
|
@ -16,6 +16,9 @@ namespace Dotclear\Plugin\dcLog;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module definition shortcut.
|
||||||
|
*/
|
||||||
class My
|
class My
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +32,9 @@ class My
|
||||||
public const BACKEND_LIST_ID = 'dcloglist';
|
public const BACKEND_LIST_ID = 'dcloglist';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module id
|
* This module id.
|
||||||
|
*
|
||||||
|
* @return string The module id
|
||||||
*/
|
*/
|
||||||
public static function id(): string
|
public static function id(): string
|
||||||
{
|
{
|
||||||
|
@ -37,7 +42,9 @@ class My
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module name
|
* This module name.
|
||||||
|
*
|
||||||
|
* @return string The module translated name
|
||||||
*/
|
*/
|
||||||
public static function name(): string
|
public static function name(): string
|
||||||
{
|
{
|
||||||
|
@ -45,7 +52,9 @@ class My
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check php version
|
* Check php version.
|
||||||
|
*
|
||||||
|
* @return bool True on supported PHP version
|
||||||
*/
|
*/
|
||||||
public static function phpCompliant(): bool
|
public static function phpCompliant(): bool
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue