add code inline doc

This commit is contained in:
Jean-Christian Paul Denis 2023-04-23 10:59:23 +02:00
parent 285ca702dd
commit 4cdaef23ee
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
5 changed files with 65 additions and 19 deletions

View File

@ -21,16 +21,14 @@ use dcFavorites;
use dcNsProcess;
use dcPage;
/**
* Manage contributions list
*/
class Backend extends dcNsProcess
{
public static function init(): bool
{
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;
}
@ -41,6 +39,7 @@ class Backend extends dcNsProcess
return false;
}
// backend sidebar menu icon
dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem(
My::name(),
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
@ -50,6 +49,7 @@ class Backend extends dcNsProcess
);
dcCore::app()->addBehaviors([
// backend user preference for logs list columns
'adminColumnsListsV2' => function (ArrayObject $cols): void {
$cols[My::BACKEND_LIST_ID] = [
My::name(),
@ -63,7 +63,7 @@ class Backend extends dcNsProcess
],
];
},
// backend filter for logs list sort
'adminFiltersListsV2' => function (ArrayObject $sorts): void {
$sorts[My::BACKEND_LIST_ID] = [
My::name(),
@ -80,7 +80,7 @@ class Backend extends dcNsProcess
[__('Logs per page'), 30],
];
},
// backend user preference for dashboard icon
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
$favs->register(My::BACKEND_LIST_ID, [
'title' => My::name(),

View File

@ -21,8 +21,19 @@ use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\Checkbox;
/**
* Backend logs list helper.
*/
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
{
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
{
$cols = [
@ -105,8 +121,8 @@ class BackendList extends adminGenericListV2
$this->userColumns(My::BACKEND_LIST_ID, $cols);
echo
'<tr class="line" id="p' . $this->rs->log_id . '">' .
implode(iterator_to_array($cols)) .
'</tr>';
'<tr class="line" id="p' . $this->rs->log_id . '">' .
implode(iterator_to_array($cols)) .
'</tr>';
}
}

View File

@ -35,8 +35,9 @@ class Manage extends dcNsProcess
public static function init(): bool
{
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;
}
@ -49,7 +50,7 @@ class Manage extends dcNsProcess
$current = ManageVars::init();
# Delete logs
// Delete logs
if ($current->selected_logs && !empty($current->entries) || $current->all_logs) {
try {
dcCore::app()->log->delLogs($current->entries, $current->all_logs);

View File

@ -20,20 +20,35 @@ use dcCore;
use Dotclear\Database\MetaRecord;
use Exception;
/**
* Backend logs manage page vars container.
*/
class ManageVars
{
/**
* @var ManageVars self instance
*/
/** @var ManageVars $container self instance */
private static $container;
/** @var adminGenericFilterV2 $filter The filter instance */
public readonly adminGenericFilterV2 $filter;
/** @var null|MetaRecord $logs The current records */
public readonly ?MetaRecord $logs;
/** @var null|BackendList $list The records list form instance */
public readonly ?BackendList $list;
/** @var array $entries The post form selected entries */
public readonly array $entries;
/** @var bool $selected_logs The post form action */
public readonly bool $selected_logs;
/** @var bool $all_logs The post form action */
public readonly bool $all_logs;
/**
* Constructor grabs post form value and sets properties.
*/
protected function __construct()
{
$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
{
if (!(self::$container instanceof self)) {

View File

@ -16,6 +16,9 @@ namespace Dotclear\Plugin\dcLog;
use dcCore;
/**
* Module definition shortcut.
*/
class My
{
/**
@ -29,7 +32,9 @@ class My
public const BACKEND_LIST_ID = 'dcloglist';
/**
* This module id
* This module id.
*
* @return string The module id
*/
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
{
@ -45,7 +52,9 @@ class My
}
/**
* Check php version
* Check php version.
*
* @return bool True on supported PHP version
*/
public static function phpCompliant(): bool
{