diff --git a/_admin.php b/_admin.php index 3cfaab3..c910391 100644 --- a/_admin.php +++ b/_admin.php @@ -21,119 +21,80 @@ require __DIR__ . '/_widgets.php'; # Admin menu dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Enhance post content'), - 'plugin.php?p=enhancePostContent', + dcCore::app()->adminurl->get('admin.plugin.enhancePostContent'), urldecode(dcPage::getPF('enhancePostContent/icon.svg')), - preg_match( - '/plugin.php\?p=enhancePostContent(&.*)?$/', - $_SERVER['REQUEST_URI'] - ), + preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.enhancePostContent')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id) ); -dcCore::app()->addBehavior( - 'adminDashboardFavoritesV2', - ['epcAdminBehaviors', 'adminDashboardFavorites'] -); -dcCore::app()->addBehavior( - 'adminBlogPreferencesFormV2', - ['epcAdminBehaviors', 'adminBlogPreferencesForm'] -); -dcCore::app()->addBehavior( - 'adminBeforeBlogSettingsUpdate', - ['epcAdminBehaviors', 'adminBeforeBlogSettingsUpdate'] -); -dcCore::app()->addBehavior( - 'adminFiltersListsV2', - ['epcAdminBehaviors', 'adminFiltersLists'] -); +# Dashboard favorites +dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) { + $favs->register('enhancePostContent', [ + 'title' => __('Enhance post content'), + 'url' => dcCore::app()->adminurl->get('admin.plugin.enhancePostContent'), + 'small-icon' => urldecode(dcPage::getPF('enhancePostContent/icon.svg')), + 'large-icon' => urldecode(dcPage::getPF('enhancePostContent/icon.svg')), + 'permissions' => dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id), + ]); +}); -class epcAdminBehaviors -{ - public static function adminDashboardFavorites(dcFavorites $favs) - { - $favs->register('enhancePostContent', [ - 'title' => __('Enhance post content'), - 'url' => 'plugin.php?p=enhancePostContent', - 'small-icon' => urldecode(dcPage::getPF('enhancePostContent/icon.svg')), - 'large-icon' => urldecode(dcPage::getPF('enhancePostContent/icon.svg')), - 'permissions' => dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id), - 'active_cb' => [ - 'epcAdminBehaviors', - 'adminDashboardFavoritesActive', - ], - ]); - } +# Preference form +dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings) { + $active = (bool) $blog_settings->enhancePostContent->enhancePostContent_active; + $allowedtplvalues = libEPC::blogAllowedTplValues(); + $allowedpubpages = libEPC::blogAllowedPubPages(); - public static function adminDashboardFavoritesActive($request, $params) - { - return $request == 'plugin.php' - && isset($params['p']) - && $params['p'] == 'enhancePostContent'; - } + echo + '
' . + __('This enable public widgets and contents filter.') . + '
' . + '' . + '' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '
' . + '' . + form::field('epc_allowedtplvalues', 100, 0, libEPC::implode($allowedtplvalues)) . '
' . + '' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '
' . + '' . + form::field('epc_allowedpubpages', 100, 0, libEPC::implode($allowedpubpages)) . '
' . + '' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '
' . + '' . - __('This enable public widgets and contents filter.') . - '
' . - '' . - '' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '
' . - '' . - form::field('epc_allowedtplvalues', 100, 0, libEPC::implode($allowedtplvalues)) . '
' . - '' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '
' . - '' . - form::field('epc_allowedpubpages', 100, 0, libEPC::implode($allowedpubpages)) . '
' . - '' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '
' . - '