diff --git a/src/Backend.php b/src/Backend.php index bedd1e1..8f479f0 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -43,10 +43,10 @@ class Backend extends dcNsProcess dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem( My::name(), - dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), dcPage::getPF(My::id() . '/icon.svg'), - preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']), - dcCore::app()->auth->isSuperAdmin() + preg_match('/' . preg_quote((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']), + dcCore::app()->auth?->isSuperAdmin() ); dcCore::app()->addBehaviors([ @@ -84,7 +84,7 @@ class Backend extends dcNsProcess 'adminDashboardFavoritesV2' => function (dcFavorites $favs): void { $favs->register(My::BACKEND_LIST_ID, [ 'title' => My::name(), - 'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + 'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), 'small-icon' => dcPage::getPF(My::id() . '/icon.svg'), 'large-icon' => dcPage::getPF(My::id() . '/icon.svg'), //'permissions' => null, diff --git a/src/BackendList.php b/src/BackendList.php index c35ef94..6597062 100644 --- a/src/BackendList.php +++ b/src/BackendList.php @@ -23,7 +23,7 @@ use html; class BackendList extends adminGenericListV2 { - public function display($page, $nb_per_page, $enclose_block = '', $filter = false) + public function display(int $page, int $nb_per_page, string $enclose_block = '', bool $filter = false): void { if ($this->rs->isEmpty()) { echo $filter ? @@ -73,7 +73,7 @@ class BackendList extends adminGenericListV2 } } - private function logLine($checked) + private function logLine(bool $checked): void { $cols = [ 'check' => '
' . __('There are no logs') . '
'; } else { - dcCore::app()->admin->logs_filter->display( + $current->filter->display( 'admin.plugin.' . My::id(), form::hidden('p', My::id()) ); - dcCore::app()->admin->logs_list->display( - dcCore::app()->admin->logs_filter->__get('page'), - dcCore::app()->admin->logs_filter->__get('nb'), - '', - dcCore::app()->admin->logs_filter->show() + $current->filter->show() ); } } diff --git a/src/ManageVars.php b/src/ManageVars.php new file mode 100644 index 0000000..5975e81 --- /dev/null +++ b/src/ManageVars.php @@ -0,0 +1,67 @@ +entries = !empty($_POST['entries']) && is_array($_POST['entries']) ? $_POST['entries'] : []; + $this->all_logs = isset($_POST['all_logs']); + $this->selected_logs = isset($_POST['selected_logs']); + + $this->filter = new adminGenericFilterV2('dcloglist'); + $this->filter->add(dcAdminFilters::getPageFilter()); + $this->filter->add(dcAdminFilters::getInputFilter('blog_id', __('Blog:'))); + $this->filter->add(dcAdminFilters::getInputFilter('user_id', __('User:'))); + $this->filter->add(dcAdminFilters::getInputFilter('log_table', __('Component:'))); + $this->filter->add(dcAdminFilters::getInputFilter('log_ip', __('IP:'))); + $params = $this->filter->params(); + + try { + $this->logs = dcCore::app()->log->getLogs($params); + $this->list = new BackendList($this->logs, $this->logs->count()); + } catch (Exception $e) { + dcCore::app()->error->add($e->getMessage()); + } + } + + public static function init(): ManageVars + { + if (!(self::$container instanceof self)) { + self::$container = new self(); + } + + return self::$container; + } +}