upgrade to Dotclear 2.27
This commit is contained in:
parent
b3edda6cc8
commit
73f9b6f83a
8 changed files with 155 additions and 204 deletions
|
@ -2,6 +2,6 @@ $(function(){
|
||||||
/* toogle admin form sidebar */
|
/* toogle admin form sidebar */
|
||||||
$('#templator h5').toggleWithLegend(
|
$('#templator h5').toggleWithLegend(
|
||||||
$('#templator').children().not('h5'),
|
$('#templator').children().not('h5'),
|
||||||
{cookie:'dcx_templator_admin_form_sidebar',legend_click:true}
|
{user_pref:'dcx_templator_admin_form_sidebar',legend_click:true}
|
||||||
);
|
);
|
||||||
});
|
});
|
|
@ -14,50 +14,23 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use dcAdmin;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcMenu;
|
use Dotclear\Core\Process;
|
||||||
use dcNsProcess;
|
|
||||||
use dcPage;
|
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init == defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::BACKEND));
|
||||||
&& !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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullsafe
|
My::addBackendMenuItem();
|
||||||
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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
'adminPostHeaders' => [BackendBehaviors::class,'adminPostHeaders'],
|
'adminPostHeaders' => [BackendBehaviors::class,'adminPostHeaders'],
|
||||||
|
|
|
@ -16,10 +16,15 @@ namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcPage;
|
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||||
use dcPostsActions;
|
use Dotclear\Core\Backend\{
|
||||||
use Dotclear\Database\Cursor;
|
Notices,
|
||||||
use Dotclear\Database\MetaRecord;
|
Page
|
||||||
|
};
|
||||||
|
use Dotclear\Database\{
|
||||||
|
Cursor,
|
||||||
|
MetaRecord
|
||||||
|
};
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
|
@ -29,7 +34,7 @@ class BackendBehaviors
|
||||||
{
|
{
|
||||||
public static function adminPostHeaders(): string
|
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
|
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(
|
$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
|
# No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
|
@ -91,7 +96,7 @@ class BackendBehaviors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Entries template updated.'));
|
Notices::addSuccessNotice(__('Entries template updated.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -99,7 +104,7 @@ class BackendBehaviors
|
||||||
}
|
}
|
||||||
|
|
||||||
$pa->beginPage(
|
$pa->beginPage(
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Entry template') => '',
|
__('Entry template') => '',
|
||||||
|
|
|
@ -15,24 +15,22 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Database\MetaRecord;
|
use Dotclear\Database\MetaRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frontend prepend.
|
* Frontend prepend.
|
||||||
*/
|
*/
|
||||||
class Frontend extends dcNsProcess
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_RC_PATH');
|
return self::status(My::checkContext(My::FRONTEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
223
src/Manage.php
223
src/Manage.php
|
@ -14,41 +14,34 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use adminGenericFilterV2;
|
|
||||||
use adminPostList;
|
|
||||||
use dcAdminFilters;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Backend\Filter\{
|
||||||
use dcPage;
|
Filters,
|
||||||
use dcPager;
|
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\File\Files;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
use form;
|
use form;
|
||||||
|
|
||||||
class Manage extends dcNsProcess
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init == defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::MANAGE));
|
||||||
&& !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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// nullsafe
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +64,8 @@ class Manage extends dcNsProcess
|
||||||
$t->initializeTpl($name, $_POST['filesource']);
|
$t->initializeTpl($name, $_POST['filesource']);
|
||||||
|
|
||||||
if (!dcCore::app()->error->flag()) {
|
if (!dcCore::app()->error->flag()) {
|
||||||
dcPage::addSuccessNotice(__('The new template has been successfully created.'));
|
Notices::addSuccessNotice(__('The new template has been successfully created.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
My::redirect();
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -90,8 +83,8 @@ class Manage extends dcNsProcess
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!dcCore::app()->error->flag()) {
|
if (!dcCore::app()->error->flag()) {
|
||||||
dcPage::addSuccessNotice(__('The template has been successfully copied.'));
|
Notices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']);
|
My::redirect(['part' => 'files']);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -109,8 +102,8 @@ class Manage extends dcNsProcess
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!dcCore::app()->error->flag()) {
|
if (!dcCore::app()->error->flag()) {
|
||||||
dcPage::addSuccessNotice(__('The template has been successfully copied.'));
|
Notices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']);
|
My::redirect(['part' => 'files']);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -127,8 +120,8 @@ class Manage extends dcNsProcess
|
||||||
dcCore::app()->meta->delMeta($file, 'template');
|
dcCore::app()->meta->delMeta($file, 'template');
|
||||||
|
|
||||||
if (!dcCore::app()->error->flag()) {
|
if (!dcCore::app()->error->flag()) {
|
||||||
dcPage::addSuccessNotice(__('The template has been successfully removed.'));
|
Notices::addSuccessNotice(__('The template has been successfully removed.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'files']);
|
My::redirect(['part' => 'files']);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
@ -140,7 +133,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,28 +152,28 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
if (!$t->canUseRessources(true)) {
|
if (!$t->canUseRessources(true)) {
|
||||||
dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
|
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
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
Notices::getNotices();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Duplicate dotclear template
|
* Duplicate dotclear template
|
||||||
*/
|
*/
|
||||||
} elseif ('new' == $v->part) {
|
} elseif ('new' == $v->part) {
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'new']) . '" method="post" id="add-template">' .
|
'<form action="' . My::manageUrl(['part' => 'new']) . '" method="post" id="add-template">' .
|
||||||
'<h3>' . $v->name . '</h3>' .
|
'<h3>' . $v->name . '</h3>' .
|
||||||
'<p><label for="filesource" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Template source:') . '</label> ' .
|
'<p><label for="filesource" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Template source:') . '</label> ' .
|
||||||
form::combo('filesource', $v->sources) . '</p>' .
|
form::combo('filesource', $v->sources) . '</p>' .
|
||||||
|
@ -197,7 +190,7 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<p>' .
|
'<p>' .
|
||||||
dcCore::app()->formNonce() .
|
My::parsedHiddenFields() .
|
||||||
'<input type="submit" value="' . __('Create') . '" /></p>' .
|
'<input type="submit" value="' . __('Create') . '" /></p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
|
@ -205,16 +198,16 @@ class Manage extends dcNsProcess
|
||||||
* Copy templator template
|
* Copy templator template
|
||||||
*/
|
*/
|
||||||
} elseif ('copy' == $v->part && !empty($_REQUEST['file'])) {
|
} elseif ('copy' == $v->part && !empty($_REQUEST['file'])) {
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'copy']) . '" method="post">' .
|
'<form action="' . My::manageUrl(['part' => 'copy']) . '" method="post">' .
|
||||||
'<h3>' . $v->name . '</h3>' .
|
'<h3>' . $v->name . '</h3>' .
|
||||||
'<p><label for="filename" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New filename:') . '</label> ' .
|
'<p><label for="filename" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New filename:') . '</label> ' .
|
||||||
form::field('filename', 25, 255) . '<code>' . Html::escapeHTML('.html') . '</code></p> ' .
|
form::field('filename', 25, 255) . '<code>' . Html::escapeHTML('.html') . '</code></p> ' .
|
||||||
|
@ -224,9 +217,8 @@ class Manage extends dcNsProcess
|
||||||
) . '</p>' .
|
) . '</p>' .
|
||||||
'<p>' .
|
'<p>' .
|
||||||
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
||||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
'<a class="button" href="' . My::manageUrl(['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||||
dcCore::app()->formNonce() .
|
My::parsedHiddenFields(['file' => Html::escapeHTML($_REQUEST['file'])]) . '</p>' .
|
||||||
form::hidden('file', Html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -241,16 +233,16 @@ class Manage extends dcNsProcess
|
||||||
};
|
};
|
||||||
$name = $full_name . dcCore::app()->blog->getCategory($category_id)->f('cat_title');
|
$name = $full_name . dcCore::app()->blog->getCategory($category_id)->f('cat_title');
|
||||||
|
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'copycat']) . '" method="post">' .
|
'<form action="' . My::manageUrl(['part' => 'copycat']) . '" method="post">' .
|
||||||
'<h3>' . $v->name . '</h3>' .
|
'<h3>' . $v->name . '</h3>' .
|
||||||
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Target category:') . '</label> ' .
|
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Target category:') . '</label> ' .
|
||||||
form::combo('filecat', $v->categories, '') . '</p>' .
|
form::combo('filecat', $v->categories, '') . '</p>' .
|
||||||
|
@ -260,60 +252,58 @@ class Manage extends dcNsProcess
|
||||||
$name
|
$name
|
||||||
) . '</p>' .
|
) . '</p>' .
|
||||||
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
||||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
'<a class="button" href="' . My::manageUrl(['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||||
dcCore::app()->formNonce() .
|
My::parsedHiddenFields(['file' => Html::escapeHTML($_REQUEST['file'])]) . '</p>' .
|
||||||
form::hidden('file', Html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete templator template
|
* Delete templator template
|
||||||
*/
|
*/
|
||||||
} elseif ('delete' == $v->part && !empty($_REQUEST['file'])) {
|
} elseif ('delete' == $v->part && !empty($_REQUEST['file'])) {
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'delete']) . '" method="post">' .
|
'<form action="' . My::manageUrl(['part' => 'delete']) . '" method="post">' .
|
||||||
'<h3>' . $v->name . '</h3>' .
|
'<h3>' . $v->name . '</h3>' .
|
||||||
'<p>' . sprintf(
|
'<p>' . sprintf(
|
||||||
__('Are you sure you want to remove the template "%s"?'),
|
__('Are you sure you want to remove the template "%s"?'),
|
||||||
Html::escapeHTML($_GET['file'])
|
Html::escapeHTML($_GET['file'])
|
||||||
) . '</p>' .
|
) . '</p>' .
|
||||||
'<p><input type="submit" class="delete" value="' . __('Delete') . '" /> ' .
|
'<p><input type="submit" class="delete" value="' . __('Delete') . '" /> ' .
|
||||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
'<a class="button" href="' . My::manageUrl(['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||||
dcCore::app()->formNonce() .
|
My::parsedHiddenFields(['file' => Html::escapeHTML($_GET['file'])]) . '</p>' .
|
||||||
form::hidden('file', Html::escapeHTML($_GET['file'])) . '</p>' .
|
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List templator templates
|
* List templator templates
|
||||||
*/
|
*/
|
||||||
} elseif ('files' == $v->part) {
|
} elseif ('files' == $v->part) {
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
'<h3>' . $v->name . '</h3>';
|
'<h3>' . $v->name . '</h3>';
|
||||||
|
|
||||||
if (count($v->items) == 0) {
|
if (count($v->items) == 0) {
|
||||||
echo '<p><strong>' . __('No template.') . '</strong></p>';
|
echo '<p><strong>' . __('No template.') . '</strong></p>';
|
||||||
} else {
|
} else {
|
||||||
// reuse "used templatro template" filter settings
|
// reuse "used templatro template" filter settings
|
||||||
$filter = new adminGenericFilterV2(My::id());
|
$filter = new Filters(My::id());
|
||||||
$filter->add(dcAdminFilters::getPageFilter());
|
$filter->add(FiltersLibrary::getPageFilter());
|
||||||
$page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1;
|
$page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1;
|
||||||
$nb = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 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
|
echo
|
||||||
'<div class="media-list">' .
|
'<div class="media-list">' .
|
||||||
|
@ -361,11 +351,11 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
$cols[$col] .= '<tr class="line">' .
|
$cols[$col] .= '<tr class="line">' .
|
||||||
'<td class="maximal"><a href="' .
|
'<td class="maximal"><a href="' .
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), [
|
My::manageUrl([
|
||||||
'part' => 'posts',
|
'part' => 'posts',
|
||||||
'file' => $meta_id,
|
'file' => $meta_id,
|
||||||
'redir' => dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'used']),
|
'redir' => My::manageUrl(['part' => 'used'], '&'),
|
||||||
]) . '">' . $meta_id . '</a> ' . $img_status . '</td>' .
|
], '&') . '">' . $meta_id . '</a> ' . $img_status . '</td>' .
|
||||||
'<td class="nowrap"><strong>' . $count . '</strong> ' .
|
'<td class="nowrap"><strong>' . $count . '</strong> ' .
|
||||||
(($count == 1) ? __('entry') : __('entries')) . '</td>' .
|
(($count == 1) ? __('entry') : __('entries')) . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
@ -375,17 +365,17 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
$table = '<div class="col"><table class="tags">%s</table></div>';
|
$table = '<div class="col"><table class="tags">%s</table></div>';
|
||||||
|
|
||||||
dcPage::openModule(
|
Page::openModule(
|
||||||
My::name(),
|
My::name(),
|
||||||
dcPage::cssModuleLoad('tags/style.css')
|
Page::cssModuleLoad('tags/style.css')
|
||||||
);
|
);
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
'<h3>' . $v->name . '</h3>';
|
'<h3>' . $v->name . '</h3>';
|
||||||
|
|
||||||
if ($cols[0]) {
|
if ($cols[0]) {
|
||||||
|
@ -437,38 +427,38 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
$ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
$ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||||
|
|
||||||
dcPage::openModule(
|
Page::openModule(
|
||||||
My::name(),
|
My::name(),
|
||||||
(
|
(
|
||||||
dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ?
|
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...'),
|
'saving_document' => __('Saving document...'),
|
||||||
'document_saved' => __('Document saved'),
|
'document_saved' => __('Document saved'),
|
||||||
'error_occurred' => __('An error occurred:'),
|
'error_occurred' => __('An error occurred:'),
|
||||||
'confirm_reset_file' => __('Are you sure you want to reset this file?'),
|
'confirm_reset_file' => __('Are you sure you want to reset this file?'),
|
||||||
]) .
|
]) .
|
||||||
dcPage::jsModuleLoad('themeEditor/js/script.js') .
|
Page::jsModuleLoad('themeEditor/js/script.js') .
|
||||||
dcPage::jsConfirmClose('file-form') .
|
Page::jsConfirmClose('file-form') .
|
||||||
(
|
(
|
||||||
dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ?
|
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
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
Notices::getNotices();
|
||||||
|
|
||||||
if (($file['c'] !== null)) {
|
if (($file['c'] !== null)) {
|
||||||
echo
|
echo
|
||||||
'<form id="file-form" action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'edit', 'file' => $name]) . '" method="post">' .
|
'<form id="file-form" action="' . My::manageUrl(['part' => 'edit', 'file' => $name]) . '" method="post">' .
|
||||||
'<div><h3><label for="file_content">' . sprintf(__('Editing file %s'), '<strong>' . $name) . '</strong></label></h3>' .
|
'<div><h3><label for="file_content">' . sprintf(__('Editing file %s'), '<strong>' . $name) . '</strong></label></h3>' .
|
||||||
'<p>' . form::textarea('file_content', 72, 25, [
|
'<p>' . form::textarea('file_content', 72, 25, [
|
||||||
'default' => Html::escapeHTML($file['c']),
|
'default' => Html::escapeHTML($file['c']),
|
||||||
|
@ -479,9 +469,8 @@ class Manage extends dcNsProcess
|
||||||
if ($file['w']) {
|
if ($file['w']) {
|
||||||
echo
|
echo
|
||||||
'<p><input type="submit" name="write" value="' . __('Save') . '" accesskey="s" /> ' .
|
'<p><input type="submit" name="write" value="' . __('Save') . '" accesskey="s" /> ' .
|
||||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
'<a class="button" href="' . My::manageUrl(['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||||
dcCore::app()->formNonce() .
|
My::parsedHiddenFields(['file_id' => Html::escapeHTML($file['f'])]) .
|
||||||
form::hidden(['file_id'], Html::escapeHTML($file['f'])) .
|
|
||||||
'</p>';
|
'</p>';
|
||||||
} else {
|
} else {
|
||||||
echo '<p>' . __('This file is not writable. Please check your files permissions.') . '</p>';
|
echo '<p>' . __('This file is not writable. Please check your files permissions.') . '</p>';
|
||||||
|
@ -492,9 +481,9 @@ class Manage extends dcNsProcess
|
||||||
if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) {
|
if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) {
|
||||||
$ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
$ict = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||||
echo
|
echo
|
||||||
dcPage::jsJson('theme_editor_mode', ['mode' => 'html']) .
|
Page::jsJson('theme_editor_mode', ['mode' => 'html']) .
|
||||||
dcPage::jsModuleLoad('themeEditor/js/mode.js') .
|
Page::jsModuleLoad('themeEditor/js/mode.js') .
|
||||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', is_string($ict) ? $ict : '');
|
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')) {
|
} elseif ('posts' == $v->part && (!empty($_REQUEST['file']) || $_REQUEST['file'] == '0')) {
|
||||||
$file = $_REQUEST['file'];
|
$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
|
# Unselect the template
|
||||||
if (!empty($_POST['action']) && 'unselecttpl' == $_POST['action'] && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
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)) {
|
]), dcCore::app()->blog->id)) {
|
||||||
try {
|
try {
|
||||||
dcCore::app()->meta->delMeta($file, 'template');
|
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) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter = new adminGenericFilterV2('templator');
|
$filter = new Filters('templator');
|
||||||
$filter->add(dcAdminFilters::getPageFilter());
|
$filter->add(FiltersLibrary::getPageFilter());
|
||||||
$filter->add('part', 'posts');
|
$filter->add('part', 'posts');
|
||||||
$filter->add('file', $file);
|
$filter->add('file', $file);
|
||||||
$filter->add('post_type', '');
|
$filter->add('post_type', '');
|
||||||
|
@ -537,25 +526,25 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0);
|
$counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0);
|
||||||
$counter = is_numeric($counter) ? (int) $counter : 0;
|
$counter = is_numeric($counter) ? (int) $counter : 0;
|
||||||
$post_list = new adminPostList($posts, $counter);
|
$post_list = new ListingPosts($posts, $counter);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::openModule(
|
Page::openModule(
|
||||||
My::name(),
|
My::name(),
|
||||||
dcPage::jsFilterControl($filter->show()) .
|
Page::jsFilterControl($filter->show()) .
|
||||||
dcPage::jsModuleLoad(My::id() . '/js/posts.js') .
|
My::jsLoad('posts') .
|
||||||
$filter->js(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'posts', 'file' => $file]))
|
$filter->js(My::manageUrl(['part' => 'posts', 'file' => $file]))
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
$v->name => '',
|
$v->name => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
'<h3>' . sprintf(__('Unselect template "%s"'), '<strong>' . $file . '</strong>') . '</h3>' .
|
'<h3>' . sprintf(__('Unselect template "%s"'), '<strong>' . $file . '</strong>') . '</h3>' .
|
||||||
'<p><a class ="back" href="' . $redir . '">' . __('Back') . '</a></p>';
|
'<p><a class ="back" href="' . $redir . '">' . __('Back') . '</a></p>';
|
||||||
|
@ -574,7 +563,7 @@ class Manage extends dcNsProcess
|
||||||
$post_list->display(
|
$post_list->display(
|
||||||
$page,
|
$page,
|
||||||
$nb,
|
$nb,
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" method="post" id="form-entries">' .
|
'<form action="' . My::manageUrl() . '" method="post" id="form-entries">' .
|
||||||
|
|
||||||
'%s' .
|
'%s' .
|
||||||
|
|
||||||
|
@ -598,13 +587,13 @@ class Manage extends dcNsProcess
|
||||||
* Default page
|
* Default page
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => '',
|
My::name() => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
Notices::getNotices();
|
||||||
|
|
||||||
$line = '<li><a href="%s">%s</a></li>';
|
$line = '<li><a href="%s">%s</a></li>';
|
||||||
echo '
|
echo '
|
||||||
|
@ -613,24 +602,24 @@ class Manage extends dcNsProcess
|
||||||
'<h3><ul class="nice">%s</ul></h3>',
|
'<h3><ul class="nice">%s</ul></h3>',
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'files']),
|
My::manageUrl(['part' => 'files']),
|
||||||
__('Available templates')
|
__('Available templates')
|
||||||
) .
|
) .
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'used']),
|
My::manageUrl(['part' => 'used']),
|
||||||
__('Used templates')
|
__('Used templates')
|
||||||
) .
|
) .
|
||||||
sprintf(
|
sprintf(
|
||||||
$line,
|
$line,
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'new']),
|
My::manageUrl(['part' => 'new']),
|
||||||
__('New template')
|
__('New template')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::helpBlock('templator');
|
Page::helpBlock('templator');
|
||||||
|
|
||||||
dcPage::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
src/My.php
35
src/My.php
|
@ -15,38 +15,27 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* This module definitions.
|
||||||
*/
|
*/
|
||||||
class My
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/** @var string This module permission */
|
/** @var string This module permission */
|
||||||
public const PERMISSION_TEMPLATOR = 'templator';
|
public const PERMISSION_TEMPLATOR = 'templator';
|
||||||
|
|
||||||
/**
|
public static function checkCustomContext(int $context): ?bool
|
||||||
* This module id.
|
|
||||||
*/
|
|
||||||
public static function id(): string
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return null;
|
||||||
* 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__);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcPage;
|
|
||||||
use Dotclear\Helper\File\File;
|
use Dotclear\Helper\File\File;
|
||||||
use Dotclear\Helper\File\Files;
|
use Dotclear\Helper\File\Files;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -33,8 +32,8 @@ class Pager
|
||||||
$count = '';
|
$count = '';
|
||||||
$params = [];
|
$params = [];
|
||||||
$link = 'media_item.php?id=' . $f->media_id;
|
$link = 'media_item.php?id=' . $f->media_id;
|
||||||
$link_edit = dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'edit', 'file' => $f->basename]);
|
$link_edit = My::manageUrl(['part' => 'edit', 'file' => $f->basename]);
|
||||||
$icon = dcPage::getPF('templator/img/template.png');
|
$icon = My::fileURL('img/template.png');
|
||||||
$class = 'media-item media-col-' . ($i % 2);
|
$class = 'media-item media-col-' . ($i % 2);
|
||||||
$details = $special = '';
|
$details = $special = '';
|
||||||
$widget_icon = '<span class="widget" title="' . __('Template widget') . '">♦</span>';
|
$widget_icon = '<span class="widget" title="' . __('Template widget') . '">♦</span>';
|
||||||
|
@ -51,7 +50,7 @@ class Pager
|
||||||
$fname = '<strong>' . __('Category') . '</strong> : ' . $full_name . $category->f('cat_title');
|
$fname = '<strong>' . __('Category') . '</strong> : ' . $full_name . $category->f('cat_title');
|
||||||
$params['cat_id'] = $cat_id;
|
$params['cat_id'] = $cat_id;
|
||||||
$params['post_type'] = '';
|
$params['post_type'] = '';
|
||||||
$icon = dcPage::getPF('templator/img/template-alt.png');
|
$icon = My::fileURL('img/template-alt.png');
|
||||||
$part = 'copycat';
|
$part = 'copycat';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -68,7 +67,7 @@ class Pager
|
||||||
}
|
}
|
||||||
} elseif (preg_match('/^widget-(.+)$/', $f->basename)) {
|
} elseif (preg_match('/^widget-(.+)$/', $f->basename)) {
|
||||||
$count = ' ';
|
$count = ' ';
|
||||||
$icon = dcPage::getPF('templator/img/template-widget.png');
|
$icon = My::fileURL('img/template-widget.png');
|
||||||
$special = $widget_icon;
|
$special = $widget_icon;
|
||||||
} else {
|
} else {
|
||||||
$params['meta_id'] = $f->basename;
|
$params['meta_id'] = $f->basename;
|
||||||
|
@ -78,11 +77,11 @@ class Pager
|
||||||
try {
|
try {
|
||||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0);
|
$counter = dcCore::app()->meta->getPostsByMeta($params, true)?->f(0);
|
||||||
$counter = is_numeric($counter) ? (int) $counter : 0;
|
$counter = is_numeric($counter) ? (int) $counter : 0;
|
||||||
$url = dcCore::app()->adminurl->get('admin.plugin.templator', [
|
$url = My::manageUrl([
|
||||||
'part' => 'posts',
|
'part' => 'posts',
|
||||||
'file' => $fname,
|
'file' => $fname,
|
||||||
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']),
|
'redir' => My::manageUrl(['part' => 'files'], '&'),
|
||||||
]);
|
], '&');
|
||||||
if ($counter == 0) {
|
if ($counter == 0) {
|
||||||
$count = __('No entry');
|
$count = __('No entry');
|
||||||
} elseif ($counter == 1) {
|
} elseif ($counter == 1) {
|
||||||
|
@ -119,12 +118,12 @@ class Pager
|
||||||
$res .= '<li class="media-action"> ';
|
$res .= '<li class="media-action"> ';
|
||||||
|
|
||||||
$res .= '<a class="media-remove" href="' .
|
$res .= '<a class="media-remove" href="' .
|
||||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => $part, 'file' => $f->basename]) . '">' .
|
My::manageUrl(['part' => $part, 'file' => $f->basename]) . '">' .
|
||||||
'<img src="images/plus.png" alt="' . __('copy') . '" title="' . __('copy the template') . '" /></a> ';
|
'<img src="images/plus.png" alt="' . __('copy') . '" title="' . __('copy the template') . '" /></a> ';
|
||||||
|
|
||||||
if ($f->del) {
|
if ($f->del) {
|
||||||
$res .= '<a class="media-remove" href="' .
|
$res .= '<a class="media-remove" href="' .
|
||||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'delete', 'file' => $f->basename]) . '">' .
|
My::manageUrl(['part' => 'delete', 'file' => $f->basename]) . '">' .
|
||||||
'<img src="images/trash.png" alt="' . __('delete') . '" title="' . __('delete the template') . '" /></a>';
|
'<img src="images/trash.png" alt="' . __('delete') . '" title="' . __('delete the template') . '" /></a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\templator;
|
namespace Dotclear\Plugin\templator;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Prepend extends dcNsProcess
|
class Prepend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_RC_PATH');
|
return self::status(My::checkContext(My::PREPEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue