diff --git a/js/admin.js b/js/admin.js index beec66e..df1f767 100644 --- a/js/admin.js +++ b/js/admin.js @@ -2,6 +2,6 @@ $(function(){ /* toogle admin form sidebar */ $('#templator h5').toggleWithLegend( $('#templator').children().not('h5'), - {cookie:'dcx_templator_admin_form_sidebar',legend_click:true} + {user_pref:'dcx_templator_admin_form_sidebar',legend_click:true} ); }); \ No newline at end of file diff --git a/src/Backend.php b/src/Backend.php index 245a9b4..11a1966 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -14,50 +14,23 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; -use dcAdmin; use dcCore; -use dcMenu; -use dcNsProcess; -use dcPage; +use Dotclear\Core\Process; -class Backend extends dcNsProcess +class Backend extends Process { public static function init(): bool { - static::$init == defined('DC_CONTEXT_ADMIN') - && !is_null(dcCore::app()->blog) - && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ - My::PERMISSION_TEMPLATOR, - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, - ]), dcCore::app()->blog->id); - - return static::$init; + return self::status(My::checkContext(My::BACKEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } - // nullsafe - if (is_null(dcCore::app()->blog)) { - return false; - } - - //backend sidebar menu icon - if ((dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu)) { - dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( - My::name(), - dcCore::app()->adminurl->get('admin.plugin.' . My::id()), - urldecode(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, - My::PERMISSION_TEMPLATOR, - ]), dcCore::app()->blog->id) - ); - } + My::addBackendMenuItem(); dcCore::app()->addBehaviors([ 'adminPostHeaders' => [BackendBehaviors::class,'adminPostHeaders'], diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index fe603a3..7e0b907 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -16,10 +16,15 @@ namespace Dotclear\Plugin\templator; use ArrayObject; use dcCore; -use dcPage; -use dcPostsActions; -use Dotclear\Database\Cursor; -use Dotclear\Database\MetaRecord; +use Dotclear\Core\Backend\Action\ActionsPosts; +use Dotclear\Core\Backend\{ + Notices, + Page +}; +use Dotclear\Database\{ + Cursor, + MetaRecord +}; use Dotclear\Helper\Html\Html; use Exception; @@ -29,7 +34,7 @@ class BackendBehaviors { public static function adminPostHeaders(): string { - return dcPage::jsModuleLoad(My::id() . '/js/admin.js'); + return My::jsLoad('admin'); } public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void @@ -60,7 +65,7 @@ class BackendBehaviors } } - public static function adminPostsActions(dcPostsActions $pa): void + public static function adminPostsActions(ActionsPosts $pa): void { $pa->addAction( [ @@ -72,7 +77,7 @@ class BackendBehaviors ); } - public static function adminPostsActionsCallback(dcPostsActions $pa, ArrayObject $post): void + public static function adminPostsActionsCallback(ActionsPosts $pa, ArrayObject $post): void { # No entry $posts_ids = $pa->getIDs(); @@ -91,7 +96,7 @@ class BackendBehaviors } } - dcPage::addSuccessNotice(__('Entries template updated.')); + Notices::addSuccessNotice(__('Entries template updated.')); $pa->redirect(true); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -99,7 +104,7 @@ class BackendBehaviors } $pa->beginPage( - dcPage::breadcrumb([ + Page::breadcrumb([ Html::escapeHTML((string) dcCore::app()->blog?->name) => '', $pa->getCallerTitle() => $pa->getRedirection(true), __('Entry template') => '', diff --git a/src/Frontend.php b/src/Frontend.php index 23e64dc..a75ce8e 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,24 +15,22 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; use Dotclear\Database\MetaRecord; /** * Frontend prepend. */ -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = defined('DC_RC_PATH'); - - return static::$init; + return self::status(My::checkContext(My::FRONTEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/Manage.php b/src/Manage.php index 8daaf27..77e0208 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -14,41 +14,34 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; -use adminGenericFilterV2; -use adminPostList; -use dcAdminFilters; use dcCore; -use dcNsProcess; -use dcPage; -use dcPager; +use Dotclear\Core\Backend\Filter\{ + Filters, + FiltersLibrary +}; +use Dotclear\Core\Backend\Listing\ListingPosts; +use Dotclear\Core\Backend\Listing\Pager as corePager; +use Dotclear\Core\Backend\{ + Notices, + Page +}; +use Dotclear\Core\Process; use Dotclear\Helper\File\Files; use Dotclear\Helper\Html\Html; use Exception; use form; -class Manage extends dcNsProcess +class Manage extends Process { public static function init(): bool { - static::$init == defined('DC_CONTEXT_ADMIN') - && !is_null(dcCore::app()->blog) - && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, - My::PERMISSION_TEMPLATOR, - ]), dcCore::app()->blog->id); - - return static::$init; + return self::status(My::checkContext(My::MANAGE)); } public static function process(): bool { - if (!static::$init) { - return false; - } - - // nullsafe - if (is_null(dcCore::app()->blog)) { + if (!self::status()) { return false; } @@ -71,8 +64,8 @@ class Manage extends dcNsProcess $t->initializeTpl($name, $_POST['filesource']); if (!dcCore::app()->error->flag()) { - dcPage::addSuccessNotice(__('The new template has been successfully created.')); - dcCore::app()->adminurl->redirect('admin.plugin.' . My::id()); + Notices::addSuccessNotice(__('The new template has been successfully created.')); + My::redirect(); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -90,8 +83,8 @@ class Manage extends dcNsProcess ); if (!dcCore::app()->error->flag()) { - dcPage::addSuccessNotice(__('The template has been successfully copied.')); - dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']); + Notices::addSuccessNotice(__('The template has been successfully copied.')); + My::redirect(['part' => 'files']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -109,8 +102,8 @@ class Manage extends dcNsProcess ); if (!dcCore::app()->error->flag()) { - dcPage::addSuccessNotice(__('The template has been successfully copied.')); - dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']); + Notices::addSuccessNotice(__('The template has been successfully copied.')); + My::redirect(['part' => 'files']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -127,8 +120,8 @@ class Manage extends dcNsProcess dcCore::app()->meta->delMeta($file, 'template'); if (!dcCore::app()->error->flag()) { - dcPage::addSuccessNotice(__('The template has been successfully removed.')); - dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']); + Notices::addSuccessNotice(__('The template has been successfully removed.')); + My::redirect(['part' => 'files']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -140,7 +133,7 @@ class Manage extends dcNsProcess public static function render(): void { - if (!static::$init) { + if (!self::status()) { return; } @@ -159,28 +152,28 @@ class Manage extends dcNsProcess if (!$t->canUseRessources(true)) { dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.')); - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), ]) . - dcPage::notices(); + Notices::getNotices(); /* * Duplicate dotclear template */ } elseif ('new' == $v->part) { - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . - '
' . + '' . '

' . $v->name . '

' . '

' . form::combo('filesource', $v->sources) . '

' . @@ -197,7 +190,7 @@ class Manage extends dcNsProcess echo '

' . - dcCore::app()->formNonce() . + My::parsedHiddenFields() . '

' . '
'; @@ -205,16 +198,16 @@ class Manage extends dcNsProcess * Copy templator template */ } elseif ('copy' == $v->part && !empty($_REQUEST['file'])) { - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . - '
' . + '' . '

' . $v->name . '

' . '

' . form::field('filename', 25, 255) . '' . Html::escapeHTML('.html') . '

' . @@ -224,9 +217,8 @@ class Manage extends dcNsProcess ) . '

' . '

' . ' ' . - '' . __('Cancel') . '' . - dcCore::app()->formNonce() . - form::hidden('file', Html::escapeHTML($_REQUEST['file'])) . '

' . + '' . __('Cancel') . '' . + My::parsedHiddenFields(['file' => Html::escapeHTML($_REQUEST['file'])]) . '

' . '
'; /* @@ -241,16 +233,16 @@ class Manage extends dcNsProcess }; $name = $full_name . dcCore::app()->blog->getCategory($category_id)->f('cat_title'); - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . - '
' . + '' . '

' . $v->name . '

' . '

' . form::combo('filecat', $v->categories, '') . '

' . @@ -260,60 +252,58 @@ class Manage extends dcNsProcess $name ) . '

' . ' ' . - '' . __('Cancel') . '' . - dcCore::app()->formNonce() . - form::hidden('file', Html::escapeHTML($_REQUEST['file'])) . '

' . + '' . __('Cancel') . '' . + My::parsedHiddenFields(['file' => Html::escapeHTML($_REQUEST['file'])]) . '

' . '
'; /* * Delete templator template */ } elseif ('delete' == $v->part && !empty($_REQUEST['file'])) { - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . - '
' . + '' . '

' . $v->name . '

' . '

' . sprintf( __('Are you sure you want to remove the template "%s"?'), Html::escapeHTML($_GET['file']) ) . '

' . '

' . - '' . __('Cancel') . '' . - dcCore::app()->formNonce() . - form::hidden('file', Html::escapeHTML($_GET['file'])) . '

' . + '' . __('Cancel') . '' . + My::parsedHiddenFields(['file' => Html::escapeHTML($_GET['file'])]) . '

' . '
'; /* * List templator templates */ } elseif ('files' == $v->part) { - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . '

' . $v->name . '

'; if (count($v->items) == 0) { echo '

' . __('No template.') . '

'; } else { // reuse "used templatro template" filter settings - $filter = new adminGenericFilterV2(My::id()); - $filter->add(dcAdminFilters::getPageFilter()); + $filter = new Filters(My::id()); + $filter->add(FiltersLibrary::getPageFilter()); $page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1; $nb = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 1; - $pager = new dcPager($page, count($v->items), $nb, 10); + $pager = new corePager($page, count($v->items), $nb, 10); echo '
' . @@ -361,11 +351,11 @@ class Manage extends dcNsProcess $cols[$col] .= '' . '' . $meta_id . ' ' . $img_status . '' . + 'redir' => My::manageUrl(['part' => 'used'], '&'), + ], '&') . '">' . $meta_id . ' ' . $img_status . '' . '' . $count . ' ' . (($count == 1) ? __('entry') : __('entries')) . '' . ''; @@ -375,17 +365,17 @@ class Manage extends dcNsProcess $table = '
%s
'; - dcPage::openModule( + Page::openModule( My::name(), - dcPage::cssModuleLoad('tags/style.css') + Page::cssModuleLoad('tags/style.css') ); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . '

' . $v->name . '

'; if ($cols[0]) { @@ -437,38 +427,38 @@ class Manage extends dcNsProcess $ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'); - dcPage::openModule( + Page::openModule( My::name(), ( dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ? - dcPage::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')]) : '' + Page::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')]) : '' ) . - dcPage::jsJson('theme_editor_msg', [ + Page::jsJson('theme_editor_msg', [ 'saving_document' => __('Saving document...'), 'document_saved' => __('Document saved'), 'error_occurred' => __('An error occurred:'), 'confirm_reset_file' => __('Are you sure you want to reset this file?'), ]) . - dcPage::jsModuleLoad('themeEditor/js/script.js') . - dcPage::jsConfirmClose('file-form') . + Page::jsModuleLoad('themeEditor/js/script.js') . + Page::jsConfirmClose('file-form') . ( dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ? - dcPage::jsLoadCodeMirror(is_string($ict) ? $ict : '') : '' + Page::jsLoadCodeMirror(is_string($ict) ? $ict : '') : '' ) . - dcPage::cssModuleLoad('themeEditor/style.css') + Page::cssModuleLoad('themeEditor/style.css') ); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices(); + Notices::getNotices(); if (($file['c'] !== null)) { echo - '
' . + '' . '

' . '

' . form::textarea('file_content', 72, 25, [ 'default' => Html::escapeHTML($file['c']), @@ -479,9 +469,8 @@ class Manage extends dcNsProcess if ($file['w']) { echo '

' . - '' . __('Cancel') . '' . - dcCore::app()->formNonce() . - form::hidden(['file_id'], Html::escapeHTML($file['f'])) . + '' . __('Cancel') . '' . + My::parsedHiddenFields(['file_id' => Html::escapeHTML($file['f'])]) . '

'; } else { echo '

' . __('This file is not writable. Please check your files permissions.') . '

'; @@ -492,9 +481,9 @@ class Manage extends dcNsProcess if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) { $ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'); echo - dcPage::jsJson('theme_editor_mode', ['mode' => 'html']) . - dcPage::jsModuleLoad('themeEditor/js/mode.js') . - dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', is_string($ict) ? $ict : ''); + Page::jsJson('theme_editor_mode', ['mode' => 'html']) . + Page::jsModuleLoad('themeEditor/js/mode.js') . + Page::jsRunCodeMirror('editor', 'file_content', 'dotclear', is_string($ict) ? $ict : ''); } } @@ -503,7 +492,7 @@ class Manage extends dcNsProcess */ } elseif ('posts' == $v->part && (!empty($_REQUEST['file']) || $_REQUEST['file'] == '0')) { $file = $_REQUEST['file']; - $redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'used']); + $redir = $_REQUEST['redir'] ?? My::manageUrl(['part' => 'used']); # Unselect the template if (!empty($_POST['action']) && 'unselecttpl' == $_POST['action'] && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ @@ -512,14 +501,14 @@ class Manage extends dcNsProcess ]), dcCore::app()->blog->id)) { try { dcCore::app()->meta->delMeta($file, 'template'); - dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'posts', 'file' => $file]); + My::redirect(['part' => 'posts', 'file' => $file]); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } - $filter = new adminGenericFilterV2('templator'); - $filter->add(dcAdminFilters::getPageFilter()); + $filter = new Filters('templator'); + $filter->add(FiltersLibrary::getPageFilter()); $filter->add('part', 'posts'); $filter->add('file', $file); $filter->add('post_type', ''); @@ -537,25 +526,25 @@ class Manage extends dcNsProcess } $counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0); $counter = is_numeric($counter) ? (int) $counter : 0; - $post_list = new adminPostList($posts, $counter); + $post_list = new ListingPosts($posts, $counter); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } - dcPage::openModule( + Page::openModule( My::name(), - dcPage::jsFilterControl($filter->show()) . - dcPage::jsModuleLoad(My::id() . '/js/posts.js') . - $filter->js(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'posts', 'file' => $file])) + Page::jsFilterControl($filter->show()) . + My::jsLoad('posts') . + $filter->js(My::manageUrl(['part' => 'posts', 'file' => $file])) ); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', - My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), + My::name() => My::manageUrl(), $v->name => '', ]) . - dcPage::notices() . + Notices::getNotices() . '

' . sprintf(__('Unselect template "%s"'), '' . $file . '') . '

' . '

' . __('Back') . '

'; @@ -574,7 +563,7 @@ class Manage extends dcNsProcess $post_list->display( $page, $nb, - '' . + '' . '%s' . @@ -598,13 +587,13 @@ class Manage extends dcNsProcess * Default page */ } else { - dcPage::openModule(My::name()); + Page::openModule(My::name()); echo - dcPage::breadcrumb([ + Page::breadcrumb([ __('Plugins') => '', My::name() => '', ]) . - dcPage::notices(); + Notices::getNotices(); $line = '
  • %s
  • '; echo ' @@ -613,24 +602,24 @@ class Manage extends dcNsProcess '

      %s

    ', sprintf( $line, - dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']), + My::manageUrl(['part' => 'files']), __('Available templates') ) . sprintf( $line, - dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'used']), + My::manageUrl(['part' => 'used']), __('Used templates') ) . sprintf( $line, - dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'new']), + My::manageUrl(['part' => 'new']), __('New template') ) ); } - dcPage::helpBlock('templator'); + Page::helpBlock('templator'); - dcPage::closeModule(); + Page::closeModule(); } } diff --git a/src/My.php b/src/My.php index 3caafdb..9a7ccbf 100644 --- a/src/My.php +++ b/src/My.php @@ -15,38 +15,27 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; use dcCore; +use Dotclear\Module\MyPlugin; /** * This module definitions. */ -class My +class My extends MyPlugin { /** @var string This module permission */ public const PERMISSION_TEMPLATOR = 'templator'; - /** - * This module id. - */ - public static function id(): string + public static function checkCustomContext(int $context): ?bool { - return basename(dirname(__DIR__)); - } + if (in_array($context, [My::BACKEND, My::MENU, My::MANAGE])) { + return defined('DC_CONTEXT_ADMIN') + && !is_null(dcCore::app()->blog) + && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ + My::PERMISSION_TEMPLATOR, + dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, + ]), dcCore::app()->blog->id); + } - /** - * This module name. - */ - public static function name(): string - { - $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name'); - - return __(is_string($name) ? $name : self::id()); - } - - /** - * This module path. - */ - public static function path(): string - { - return dirname(__DIR__); + return null; } } diff --git a/src/Pager.php b/src/Pager.php index 866484d..7f988c0 100644 --- a/src/Pager.php +++ b/src/Pager.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; use dcCore; -use dcPage; use Dotclear\Helper\File\File; use Dotclear\Helper\File\Files; use Exception; @@ -33,8 +32,8 @@ class Pager $count = ''; $params = []; $link = 'media_item.php?id=' . $f->media_id; - $link_edit = dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'edit', 'file' => $f->basename]); - $icon = dcPage::getPF('templator/img/template.png'); + $link_edit = My::manageUrl(['part' => 'edit', 'file' => $f->basename]); + $icon = My::fileURL('img/template.png'); $class = 'media-item media-col-' . ($i % 2); $details = $special = ''; $widget_icon = ''; @@ -51,7 +50,7 @@ class Pager $fname = '' . __('Category') . ' : ' . $full_name . $category->f('cat_title'); $params['cat_id'] = $cat_id; $params['post_type'] = ''; - $icon = dcPage::getPF('templator/img/template-alt.png'); + $icon = My::fileURL('img/template-alt.png'); $part = 'copycat'; try { @@ -68,7 +67,7 @@ class Pager } } elseif (preg_match('/^widget-(.+)$/', $f->basename)) { $count = ' '; - $icon = dcPage::getPF('templator/img/template-widget.png'); + $icon = My::fileURL('img/template-widget.png'); $special = $widget_icon; } else { $params['meta_id'] = $f->basename; @@ -78,11 +77,11 @@ class Pager try { $counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0); $counter = is_numeric($counter) ? (int) $counter : 0; - $url = dcCore::app()->adminurl->get('admin.plugin.templator', [ + $url = My::manageUrl([ 'part' => 'posts', 'file' => $fname, - 'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']), - ]); + 'redir' => My::manageUrl(['part' => 'files'], '&'), + ], '&'); if ($counter == 0) { $count = __('No entry'); } elseif ($counter == 1) { @@ -119,12 +118,12 @@ class Pager $res .= '
  •  '; $res .= '' . + My::manageUrl(['part' => $part, 'file' => $f->basename]) . '">' . '' . __('copy') . ' '; if ($f->del) { $res .= '' . + My::manageUrl(['part' => 'delete', 'file' => $f->basename]) . '">' . '' . __('delete') . ''; } diff --git a/src/Prepend.php b/src/Prepend.php index 59ed1d4..6e4af64 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\templator; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Prepend extends dcNsProcess +class Prepend extends Process { public static function init(): bool { - static::$init = defined('DC_RC_PATH'); - - return static::$init; + return self::status(My::checkContext(My::PREPEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; }