code review
This commit is contained in:
parent
65db1c53dd
commit
3344f71dfd
33
_admin.php
33
_admin.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -31,16 +41,16 @@ if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
|||||||
dcCore::app()->addBehavior('adminAfterPageCreate', ['templatorBehaviors','adminBeforePostUpdate']);
|
dcCore::app()->addBehavior('adminAfterPageCreate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||||
dcCore::app()->addBehavior('adminBeforePageUpdate', ['templatorBehaviors','adminBeforePostUpdate']);
|
dcCore::app()->addBehavior('adminBeforePageUpdate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminPostsActions', ['templatorBehaviors','adminPostsActions']);
|
dcCore::app()->addBehavior('adminPostsActionsV2', ['templatorBehaviors','adminPostsActionsV2']);
|
||||||
dcCore::app()->addBehavior('adminPagesActions', ['templatorBehaviors','adminPostsActions']);
|
dcCore::app()->addBehavior('adminPagesActionsV2', ['templatorBehaviors','adminPostsActionsV2']);
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
|
dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
|
||||||
$sorts['templator'] = [
|
$sorts['templator'] = [
|
||||||
__('Templates engine'),
|
__('Templates engine'),
|
||||||
[
|
[
|
||||||
__('Date') => 'post_upddt',
|
__('Date') => 'post_upddt',
|
||||||
__('Title') => 'post_title',
|
__('Title') => 'post_title',
|
||||||
__('Category') => 'cat_id',
|
__('Category') => 'cat_id',
|
||||||
],
|
],
|
||||||
'post_upddt',
|
'post_upddt',
|
||||||
'desc',
|
'desc',
|
||||||
@ -65,8 +75,7 @@ class templatorBehaviors
|
|||||||
$selected = $post_meta->isEmpty() ? '' : $post_meta->meta_id;
|
$selected = $post_meta->isEmpty() ? '' : $post_meta->meta_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sidebar_items['options-box']['items']['templator'] =
|
$sidebar_items['options-box']['items']['templator'] = '<div id="templator">' .
|
||||||
'<div id="templator">' .
|
|
||||||
'<h5>' . __('Template') . '</h5>' .
|
'<h5>' . __('Template') . '</h5>' .
|
||||||
'<p><label for="post_tpl">' . __('Select template:') . '</label>' .
|
'<p><label for="post_tpl">' . __('Select template:') . '</label>' .
|
||||||
form::combo('post_tpl', self::getTemplateCombo(), $selected) . '</p>' .
|
form::combo('post_tpl', self::getTemplateCombo(), $selected) . '</p>' .
|
||||||
@ -85,7 +94,7 @@ class templatorBehaviors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adminPostsActions(dcPostsActions $pa)
|
public static function adminPostsActionsV2(dcPostsActions $pa)
|
||||||
{
|
{
|
||||||
$pa->addAction(
|
$pa->addAction(
|
||||||
[
|
[
|
||||||
@ -114,8 +123,8 @@ class templatorBehaviors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dcAdminNotices::addSuccessNotice(__('Entries template updated.'));
|
dcAdminNotices::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());
|
||||||
}
|
}
|
||||||
@ -125,7 +134,7 @@ class templatorBehaviors
|
|||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Entry template') => '',
|
__('Entry template') => '',
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
14
_define.php
14
_define.php
@ -1,11 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Templator',
|
'Templates engine',
|
||||||
'Create and select more templates for your posts',
|
'Create and select more templates for your posts',
|
||||||
'Osku and contributors',
|
'Osku and contributors',
|
||||||
'1.4-dev',
|
'1.4-dev',
|
||||||
|
12
_init.php
12
_init.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
12
_prepend.php
12
_prepend.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
12
_public.php
12
_public.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
class templatorMedia extends dcMedia
|
class templatorMedia extends dcMedia
|
||||||
{
|
{
|
||||||
// limit to html files
|
// limit to html files
|
||||||
protected function isFileExclude(string $file): bool
|
protected function isFileExclude(string $file): bool
|
||||||
{
|
{
|
||||||
return !preg_match('/\.html$/i', $file);
|
return !preg_match('/\.html$/i', $file);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
* @brief templator, a plugin for Dotclear 2
|
||||||
#
|
*
|
||||||
# This file is part of templator a plugin for Dotclear 2.
|
* @package Dotclear
|
||||||
#
|
* @subpackage Plugin
|
||||||
# Copyright (c) 2010 Osku and contributors
|
*
|
||||||
# Licensed under the GPL version 2.0 license.
|
* @author Osku and contributors
|
||||||
# A copy of this license is available in LICENSE file or at
|
*
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
* @copyright Jean-Christian Denis
|
||||||
#
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -28,14 +28,13 @@ class templatorPager
|
|||||||
$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>';
|
||||||
$part = 'copy';
|
$part = 'copy';
|
||||||
|
|
||||||
if (preg_match('/^category-(.+)$/', $f->basename)) {
|
if (preg_match('/^category-(.+).html$/', $f->basename, $cat_id)) {
|
||||||
// That is ugly.
|
$cat_id = (int) $cat_id[1];
|
||||||
$cat_id = str_replace('category-', '', $f->basename);
|
$category = dcCore::app()->blog->getCategory($cat_id);
|
||||||
$cat_id = str_replace('.html', '', $cat_id);
|
|
||||||
$cat_parents = dcCore::app()->blog->getCategoryParents($cat_id);
|
|
||||||
$full_name = '';
|
$full_name = '';
|
||||||
|
$cat_parents = dcCore::app()->blog->getCategoryParents($cat_id);
|
||||||
while ($cat_parents->fetch()) {
|
while ($cat_parents->fetch()) {
|
||||||
$full_name = $cat_parents->cat_title . ' › ';
|
$full_name = $cat_parents->cat_title . ' › ';
|
||||||
};
|
};
|
||||||
@ -43,21 +42,20 @@ class templatorPager
|
|||||||
$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 = dcPage::getPF('templator/img/template-alt.png');
|
||||||
$part = 'copycat';;
|
$part = 'copycat';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$counter = dcCore::app()->blog->getPosts($params, true);
|
$counter = dcCore::app()->blog->getPosts($params, true);
|
||||||
|
if ($counter->f(0) == 0) {
|
||||||
|
$count = __('No entry');
|
||||||
|
} elseif ($counter->f(0) == 1) {
|
||||||
|
$count = '<strong>' . $counter->f(0) . '</strong> <a href="posts.php?cat_id=' . $cat_id . '">' . __('entry') . '</a>';
|
||||||
|
} else {
|
||||||
|
$count = '<strong>' . $counter->f(0) . '</strong> <a href="posts.php?cat_id=' . $cat_id . '">' . __('entries') . '</a>';
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($counter->f(0) == 0) {
|
|
||||||
$count = __('No entry');
|
|
||||||
} elseif ($counter->f(0) == 1) {
|
|
||||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="posts.php?cat_id=' . $cat_id . '">' . __('entry') . '</a>';
|
|
||||||
} else {
|
|
||||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="posts.php?cat_id=' . $cat_id . '">' . __('entries') . '</a>';
|
|
||||||
}
|
|
||||||
} elseif (preg_match('/^widget-(.+)$/', $f->basename)) {
|
} elseif (preg_match('/^widget-(.+)$/', $f->basename)) {
|
||||||
$count = ' ';
|
$count = ' ';
|
||||||
$icon = dcPage::getPF('templator/img/template-widget.png');
|
$icon = dcPage::getPF('templator/img/template-widget.png');
|
||||||
@ -69,35 +67,35 @@ class templatorPager
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
||||||
|
$url = dcCore::app()->adminurl->get('admin.plugin.templator', [
|
||||||
|
'part' => 'posts',
|
||||||
|
'file' => $fname,
|
||||||
|
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']),
|
||||||
|
]);
|
||||||
|
if ($counter->f(0) == 0) {
|
||||||
|
$count = __('No entry');
|
||||||
|
} elseif ($counter->f(0) == 1) {
|
||||||
|
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entry') . '</a>';
|
||||||
|
} else {
|
||||||
|
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entries') . '</a>';
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
$url = dcCore::app()->adminurl->get('admin.plugin.templator', [
|
|
||||||
'part' => 'posts',
|
|
||||||
'file' => $fname,
|
|
||||||
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']),
|
|
||||||
]);
|
|
||||||
if ($counter->f(0) == 0) {
|
|
||||||
$count = __('No entry');
|
|
||||||
} elseif ($counter->f(0) == 1) {
|
|
||||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entry') . '</a>';
|
|
||||||
} else {
|
|
||||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entries') . '</a>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = '<div class="' . $class . '"><a class="media-icon media-link" href="' . $link_edit . '">' .
|
$res = '<div class="' . $class . '"><a class="media-icon media-link" href="' . $link_edit . '">' .
|
||||||
'<img src="' . $icon . '" alt="" /></a>' .
|
'<img src="' . $icon . '" alt="" /></a>' .
|
||||||
'<ul>' .
|
'<ul>' .
|
||||||
'<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>';
|
'<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>';
|
||||||
/*
|
/*
|
||||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
initTemplator::PERMISSION_TEMPLATOR,
|
initTemplator::PERMISSION_TEMPLATOR,
|
||||||
]), dcCore::app()->blog->id)) {
|
]), dcCore::app()->blog->id)) {
|
||||||
$details = ' - <a href="' . $link . '">' . __('details') . '</a>';
|
$details = ' - <a href="' . $link . '">' . __('details') . '</a>';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (!$f->d) {
|
if (!$f->d) {
|
||||||
$res .= '<li>' . $count . '</li>' .
|
$res .= '<li>' . $count . '</li>' .
|
||||||
'<li>' .
|
'<li>' .
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -141,10 +151,10 @@ class dcTemplator
|
|||||||
$source = [
|
$source = [
|
||||||
'c' => file_get_contents($base),
|
'c' => file_get_contents($base),
|
||||||
'w' => $this->getDestinationFile($name) !== false,
|
'w' => $this->getDestinationFile($name) !== false,
|
||||||
'f' => $f, ];
|
];
|
||||||
|
|
||||||
if (!$source['w']) {
|
if (!$source['w']) {
|
||||||
throw new Exception(sprintf(__('File %s is not readable'), $source));
|
throw new Exception(sprintf(__('File %s is not readable'), $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'empty') {
|
if ($type == 'empty') {
|
||||||
@ -185,24 +195,20 @@ class dcTemplator
|
|||||||
public function copypasteTpl($name, $source)
|
public function copypasteTpl($name, $source)
|
||||||
{
|
{
|
||||||
if ($name == $source) {
|
if ($name == $source) {
|
||||||
throw new Exception(__('Why copy file content in the same file?'));
|
throw new Exception(__('File already exists.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $this->getSourceContent($source);
|
$file = $this->getSourceContent($source);
|
||||||
|
|
||||||
$source = [
|
$data = [
|
||||||
'c' => $file['c'],
|
'c' => $file['c'],
|
||||||
'w' => $this->getDestinationFile($name) !== false,
|
'w' => $this->getDestinationFile($name) !== false,
|
||||||
'f' => $f, ];
|
];
|
||||||
|
|
||||||
if (!$source['w']) {
|
if (!$data['w']) {
|
||||||
throw new Exception(sprintf(__('File %s is not readable'), $source));
|
throw new Exception(sprintf(__('File %s is not readable'), $source));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'empty') {
|
|
||||||
$source['c'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dest = $this->getDestinationFile($name);
|
$dest = $this->getDestinationFile($name);
|
||||||
|
|
||||||
@ -210,7 +216,7 @@ class dcTemplator
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $source['c'];
|
$content = $data['c'];
|
||||||
|
|
||||||
if (!is_dir(dirname($dest))) {
|
if (!is_dir(dirname($dest))) {
|
||||||
files::makeDir(dirname($dest));
|
files::makeDir(dirname($dest));
|
||||||
|
142
index.php
142
index.php
@ -1,4 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief templator, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Osku and contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -24,6 +35,7 @@ if (in_array($part, ['files', 'delete'])) {
|
|||||||
|
|
||||||
if (in_array($part, ['new', 'copycat'])) {
|
if (in_array($part, ['new', 'copycat'])) {
|
||||||
$has_categories = false;
|
$has_categories = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
|
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
|
||||||
|
|
||||||
@ -63,7 +75,7 @@ if (in_array($part, ['new', 'copycat'])) {
|
|||||||
|
|
||||||
### Action ###
|
### Action ###
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Duplicate dc template
|
* Duplicate dc template
|
||||||
*/
|
*/
|
||||||
if ('new' == $part && !empty($_POST['filesource'])) {
|
if ('new' == $part && !empty($_POST['filesource'])) {
|
||||||
@ -86,7 +98,7 @@ if ('new' == $part && !empty($_POST['filesource'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Copy tempaltor template
|
* Copy tempaltor template
|
||||||
*/
|
*/
|
||||||
if ('copy' == $part && !empty($_POST['filename'])) {
|
if ('copy' == $part && !empty($_POST['filename'])) {
|
||||||
@ -105,7 +117,7 @@ if ('copy' == $part && !empty($_POST['filename'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Copy templator category template
|
* Copy templator category template
|
||||||
*/
|
*/
|
||||||
if ('copycat' == $part && !empty($_POST['filecat'])) {
|
if ('copycat' == $part && !empty($_POST['filecat'])) {
|
||||||
@ -124,7 +136,7 @@ if ('copycat' == $part && !empty($_POST['filecat'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Delete tempaltor template
|
* Delete tempaltor template
|
||||||
*/
|
*/
|
||||||
if ('delete' == $part && !empty($_POST['file'])) {
|
if ('delete' == $part && !empty($_POST['file'])) {
|
||||||
@ -144,7 +156,7 @@ if ('delete' == $part && !empty($_POST['file'])) {
|
|||||||
|
|
||||||
### Display ###
|
### Display ###
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Check
|
* Check
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -154,23 +166,23 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('New template') => '',
|
__('New template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Duplicate dotclear template
|
* Duplicate dotclear template
|
||||||
*/
|
*/
|
||||||
} elseif ('new' == $part) {
|
} elseif ('new' == $part) {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('New template') => '',
|
__('New template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
@ -184,7 +196,7 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
|
|
||||||
if ($has_categories) {
|
if ($has_categories) {
|
||||||
echo
|
echo
|
||||||
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr>' . __('Category:') .'</label> ' .
|
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr>' . __('Category:') . '</label> ' .
|
||||||
form::combo('filecat', $categories_combo, '') . '</p>' .
|
form::combo('filecat', $categories_combo, '') . '</p>' .
|
||||||
'<p class="form-note">' . __('Required only for category template.') . '</p>';
|
'<p class="form-note">' . __('Required only for category template.') . '</p>';
|
||||||
}
|
}
|
||||||
@ -195,16 +207,16 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
'<input type="submit" value="' . __('Create') . '" /></p>' .
|
'<input type="submit" value="' . __('Create') . '" /></p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Copy templator template
|
* Copy templator template
|
||||||
*/
|
*/
|
||||||
} elseif ('copy' == $part && !empty($_REQUEST['file'])) {
|
} elseif ('copy' == $part && !empty($_REQUEST['file'])) {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Copy available template') => '',
|
__('Copy available template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
@ -224,11 +236,11 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Copy templator category template
|
* Copy templator category template
|
||||||
*/
|
*/
|
||||||
} elseif ('copycat' == $part && !empty($_REQUEST['file'])) {
|
} elseif ('copycat' == $part && !empty($_REQUEST['file'])) {
|
||||||
$category_id = str_replace(['category-','.html'], '', $_REQUEST['file']);
|
$category_id = (int) str_replace(['category-','.html'], '', $_REQUEST['file']);
|
||||||
$cat_parents = dcCore::app()->blog->getCategoryParents($category_id);
|
$cat_parents = dcCore::app()->blog->getCategoryParents($category_id);
|
||||||
$full_name = '';
|
$full_name = '';
|
||||||
while ($cat_parents->fetch()) {
|
while ($cat_parents->fetch()) {
|
||||||
@ -240,8 +252,8 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Copy available template') => '',
|
__('Copy available template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
@ -261,16 +273,16 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Delete templator template
|
* Delete templator template
|
||||||
*/
|
*/
|
||||||
} elseif ('delete' == $part && !empty($_REQUEST['file'])) {
|
} elseif ('delete' == $part && !empty($_REQUEST['file'])) {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Delete available template') => '',
|
__('Delete available template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
@ -287,16 +299,16 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
form::hidden('file', html::escapeHTML($_GET['file'])) . '</p>' .
|
form::hidden('file', html::escapeHTML($_GET['file'])) . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* List templator templates
|
* List templator templates
|
||||||
*/
|
*/
|
||||||
} elseif ('files' == $part) {
|
} elseif ('files' == $part) {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Available templates') => '',
|
__('Available templates') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
@ -309,9 +321,7 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
$filter = new adminGenericFilterV2('templator');
|
$filter = new adminGenericFilterV2('templator');
|
||||||
$filter->add(dcAdminFilters::getPageFilter());
|
$filter->add(dcAdminFilters::getPageFilter());
|
||||||
|
|
||||||
$pager = new dcPager($filter->page, count($items), $filter->nb, 10);
|
$pager = new dcPager($filter->page, count($items), $filter->nb, 10);
|
||||||
$pager->html_prev = __('«prev.');
|
|
||||||
$pager->html_next = __('next»');
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="media-list">' .
|
'<div class="media-list">' .
|
||||||
@ -326,9 +336,9 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* List Used templator template
|
* List Used templator template
|
||||||
*/
|
*/
|
||||||
} elseif ('used' == $part) {
|
} elseif ('used' == $part) {
|
||||||
$tags = dcCore::app()->meta->getMetadata(['meta_type' => 'template']);
|
$tags = dcCore::app()->meta->getMetadata(['meta_type' => 'template']);
|
||||||
$tags = dcCore::app()->meta->computeMetaStats($tags);
|
$tags = dcCore::app()->meta->computeMetaStats($tags);
|
||||||
@ -360,8 +370,8 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
dcCore::app()->adminurl->get('admin.plugin.templator', [
|
dcCore::app()->adminurl->get('admin.plugin.templator', [
|
||||||
'part' => 'posts',
|
'part' => 'posts',
|
||||||
'file' => $tags->meta_id,
|
'file' => $tags->meta_id,
|
||||||
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']),
|
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']),
|
||||||
]) .'">' . $tags->meta_id . '</a> ' . $img_status . '</td>' .
|
]) . '">' . $tags->meta_id . '</a> ' . $img_status . '</td>' .
|
||||||
'<td class="nowrap"><strong>' . $tags->count . '</strong> ' .
|
'<td class="nowrap"><strong>' . $tags->count . '</strong> ' .
|
||||||
(($tags->count == 1) ? __('entry') : __('entries')) . '</td>' .
|
(($tags->count == 1) ? __('entry') : __('entries')) . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
@ -376,9 +386,9 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
|
dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Used templates') => '',
|
__('Used templates') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
'<h3>' . __('Used templates') . '</h3>';
|
'<h3>' . __('Used templates') . '</h3>';
|
||||||
@ -394,9 +404,9 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
echo '<p>' . __('No specific templates on this blog.') . '</p>';
|
echo '<p>' . __('No specific templates on this blog.') . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Edit emplator template
|
* Edit emplator template
|
||||||
*/
|
*/
|
||||||
} elseif ('edit' == $part && !empty($_REQUEST['file'])) {
|
} elseif ('edit' == $part && !empty($_REQUEST['file'])) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@ -405,9 +415,9 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
$name = $file['f'];
|
$name = $file['f'];
|
||||||
|
|
||||||
if (preg_match('/^category-(.+).html$/', $name, $cat_id)) {
|
if (preg_match('/^category-(.+).html$/', $name, $cat_id)) {
|
||||||
$category = dcCore::app()->blog->getCategory($cat_id[1]);
|
$category = dcCore::app()->blog->getCategory((int) $cat_id[1]);
|
||||||
$full_name = '';
|
$full_name = '';
|
||||||
$cat_parents = dcCore::app()->blog->getCategoryParents($cat_id[1]);
|
$cat_parents = dcCore::app()->blog->getCategoryParents((int) $cat_id[1]);
|
||||||
while ($cat_parents->fetch()) {
|
while ($cat_parents->fetch()) {
|
||||||
$full_name = $cat_parents->cat_title . ' › ';
|
$full_name = $cat_parents->cat_title . ' › ';
|
||||||
};
|
};
|
||||||
@ -453,9 +463,9 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
dcPage::cssModuleLoad('themeEditor/style.css') .
|
dcPage::cssModuleLoad('themeEditor/style.css') .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Edit template') => '',
|
__('Edit template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
@ -490,11 +500,11 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Edit posts options linked to a template
|
* Edit posts options linked to a template
|
||||||
*/
|
*/
|
||||||
} elseif ('posts' == $part && (!empty($_REQUEST['file']) || $_REQUEST['file'] == '0')) {
|
} elseif ('posts' == $part && (!empty($_REQUEST['file']) || $_REQUEST['file'] == '0')) {
|
||||||
$file = $_REQUEST['file'];
|
$file = $_REQUEST['file'];
|
||||||
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']);
|
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']);
|
||||||
|
|
||||||
# Unselect the template
|
# Unselect the template
|
||||||
@ -516,10 +526,10 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
$filter->add('file', $file);
|
$filter->add('file', $file);
|
||||||
$filter->add('post_type', '');
|
$filter->add('post_type', '');
|
||||||
|
|
||||||
$params = $filter->params();
|
$params = $filter->params();
|
||||||
$params['no_content'] = true;
|
$params['no_content'] = true;
|
||||||
$params['meta_id'] = $file;
|
$params['meta_id'] = $file;
|
||||||
$params['meta_type'] = 'template';
|
$params['meta_type'] = 'template';
|
||||||
|
|
||||||
# Get posts
|
# Get posts
|
||||||
try {
|
try {
|
||||||
@ -537,13 +547,13 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
$filter->js(dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'posts', 'file' => $file])) .
|
$filter->js(dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'posts', 'file' => $file])) .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||||
__('Unselect template') => '',
|
__('Unselect template') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
'<h3>' . __('Unselect template') . '</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>';
|
||||||
|
|
||||||
if (!dcCore::app()->error->flag()) {
|
if (!dcCore::app()->error->flag()) {
|
||||||
@ -566,7 +576,7 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
'<p class="col checkboxes-helpers"></p>' .
|
'<p class="col checkboxes-helpers"></p>' .
|
||||||
|
|
||||||
'<p class="col right">' .
|
'<p class="col right">' .
|
||||||
'<input type="submit" value="' . __('Unselect template for selcted entries') . '" /></p>' .
|
'<input type="submit" value="' . __('Unselect template for selected entries') . '" /></p>' .
|
||||||
form::hidden('action', 'unselecttpl') .
|
form::hidden('action', 'unselecttpl') .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.templator', $filter->values()) .
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.templator', $filter->values()) .
|
||||||
form::hidden('redir', $redir) .
|
form::hidden('redir', $redir) .
|
||||||
@ -579,15 +589,15 @@ if (!dcCore::app()->templator->canUseRessources(true)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Default page
|
* Default page
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Templator') . '</title>' .
|
'<html><head><title>' . __('Templator') . '</title>' .
|
||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Templates engine') => '',
|
__('Templates engine') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
Loading…
Reference in New Issue
Block a user