auth->check(dcCore::app()->auth->makePermissions([ dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, ]), dcCore::app()->blog->id); return static::$init; } public static function process(): bool { if (!static::$init) { return false; } # Admin menu dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( My::name(), 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->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id) ); dcCore::app()->addBehaviors([ # Dashboard favorites 'adminDashboardFavoritesV2' => function (dcFavorites $favs): void { $favs->register(My::id(), [ 'title' => My::name(), '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' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), ]); }, # Preference form 'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void { $active = (bool) $blog_settings->get(My::id())->get('active'); $allowedtplvalues = Epc::blogAllowedTplValues(); $allowedpubpages = Epc::blogAllowedPubPages(); echo '

' . My::name() . '

' . '
' . '
' . // active (new Para())->items([ (new Checkbox('epc_active', $active))->value(1), (new Label(__('Enable plugin'), Label::OUTSIDE_LABEL_AFTER))->for('epc_active')->class('classic'), ])->render() . '

' . __('This enable public widgets and contents filter.') . '

' . '

' . __('Set content filters') . '

' . '
' . '
' . '
' . __('Extra') . '
' . '

' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '

' . // allowedtplvalues (new Para())->items([ (new Label(__('Allowed DC template values:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedtplvalues'), (new Input('epc_allowedtplvalues'))->size(100)->maxlenght(0)->value(Epc::implode($allowedtplvalues)), ])->render() . '

' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '

' . // allowedpubpages (new Para())->items([ (new Label(__('Allowed public pages:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedpubpages'), (new Input('epc_allowedpubpages'))->size(100)->maxlenght(0)->value(Epc::implode($allowedpubpages)), ])->render() . '

' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '

' . '
' . '
' . '
' . '
'; }, # Save preference 'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void { $active = !empty($_POST['epc_active']); $allowedtplvalues = Epc::explode($_POST['epc_allowedtplvalues']); $allowedpubpages = Epc::explode($_POST['epc_allowedpubpages']); $blog_settings->get(My::id())->put('active', $active); $blog_settings->get(My::id())->put('allowedtplvalues', json_encode($allowedtplvalues)); $blog_settings->get(My::id())->put('allowedpubpages', json_encode($allowedpubpages)); }, # List filter 'adminFiltersListsV2' => function (ArrayObject $sorts): void { $sorts['epc'] = [ My::name(), [ __('Date') => 'epc_upddt', __('Key') => 'epc_key', __('Value') => 'epc_value', __('ID') => 'epc_id', ], 'epc_upddt', 'desc', [__('records per page'), 20], ]; }, # Widgets 'initWidgets' => [Widgets::class, 'initWidgets'], ]); return true; } }