update to dotclear 2.24, refresh admin (WIP)
This commit is contained in:
parent
61939f68e1
commit
a051f78816
14 changed files with 1113 additions and 1180 deletions
204
_admin.php
204
_admin.php
|
@ -1,152 +1,148 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$_menu['Plugins']->addItem(__('Templates'),
|
||||
'plugin.php?p=templator','index.php?pf=templator/icon.png',
|
||||
preg_match('/plugin.php\?p=templator(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||
$core->auth->check('contentadmin,templator',$core->blog->id));
|
||||
dcCore::app()->auth->setPermissionType(initTemplator::PERMISSION_TEMPLATOR, __('manage templates'));
|
||||
|
||||
$core->auth->setPermissionType('templator',__('manage templates'));
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Templates'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
urldecode(dcPage::getPF('templator/icon.png')),
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.templator')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]), dcCore::app()->blog->id)
|
||||
);
|
||||
|
||||
if ($core->auth->check('templator,contentadmin',$core->blog->id)) {
|
||||
$core->addBehavior('adminPostFormSidebar',array('templatorBehaviors','adminPostFormSidebar'));
|
||||
$core->addBehavior('adminPageFormSidebar',array('templatorBehaviors','adminPostFormSidebar'));
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
dcCore::app()->addBehavior('adminPostHeaders', ['templatorBehaviors','adminPostHeaders']);
|
||||
dcCore::app()->addBehavior('adminPostFormItems', ['templatorBehaviors','adminPostFormItems']);
|
||||
dcCore::app()->addBehavior('adminPageHeaders', ['templatorBehaviors','adminPostHeaders']);
|
||||
dcCore::app()->addBehavior('adminPageFormItems', ['templatorBehaviors','adminPostFormItems']);
|
||||
|
||||
$core->addBehavior('adminAfterPostCreate',array('templatorBehaviors','adminBeforePostUpdate'));
|
||||
$core->addBehavior('adminBeforePostUpdate',array('templatorBehaviors','adminBeforePostUpdate'));
|
||||
$core->addBehavior('adminAfterPageCreate',array('templatorBehaviors','adminBeforePostUpdate'));
|
||||
$core->addBehavior('adminBeforePageUpdate',array('templatorBehaviors','adminBeforePostUpdate'));
|
||||
dcCore::app()->addBehavior('adminAfterPostCreate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||
dcCore::app()->addBehavior('adminBeforePostUpdate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||
dcCore::app()->addBehavior('adminAfterPageCreate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||
dcCore::app()->addBehavior('adminBeforePageUpdate', ['templatorBehaviors','adminBeforePostUpdate']);
|
||||
|
||||
dcCore::app()->addBehavior('adminPostsActions', ['templatorBehaviors','adminPostsActions']);
|
||||
dcCore::app()->addBehavior('adminPagesActions', ['templatorBehaviors','adminPostsActions']);
|
||||
|
||||
$core->addBehavior('adminPostsActionsCombo',array('templatorBehaviors','adminPostsActionsCombo'));
|
||||
$core->addBehavior('adminPostsActions',array('templatorBehaviors','adminPostsActions'));
|
||||
$core->addBehavior('adminPostsActionsContent',array('templatorBehaviors','adminPostsActionsContent'));
|
||||
$core->addBehavior('adminPagesActionsCombo',array('templatorBehaviors','adminPostsActionsCombo'));
|
||||
$core->addBehavior('adminPagesActions',array('templatorBehaviors','adminPostsActions'));
|
||||
$core->addBehavior('adminPagesActionsContent',array('templatorBehaviors','adminPostsActionsContent'));
|
||||
}
|
||||
|
||||
class templatorBehaviors
|
||||
{
|
||||
public static function adminPostFormSidebar($post)
|
||||
public static function adminPostHeaders()
|
||||
{
|
||||
global $core;
|
||||
return dcPage::jsLoad(dcPage::getPF('templator/js/admin.js'));
|
||||
}
|
||||
|
||||
$tpl = array(' ' => '');
|
||||
$tpl_post = array();
|
||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
|
||||
{
|
||||
$selected = '';
|
||||
|
||||
foreach ($core->templator->tpl as $k => $v) {
|
||||
if (!preg_match('/^category-(.+)$/',$k))
|
||||
{
|
||||
$tpl_post= array_merge($tpl_post, array($k => $k));
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = array_merge($tpl,$tpl_post);
|
||||
if ($post)
|
||||
{
|
||||
$params['meta_type'] = 'template';
|
||||
$params['post_id'] = $post->post_id;
|
||||
$post_meta = $core->meta->getMetadata($params);
|
||||
if ($post) {
|
||||
$post_meta = dcCore::app()->meta->getMetadata(['meta_type' => 'template', 'post_id' => $post->post_id]);
|
||||
$selected = $post_meta->isEmpty() ? '' : $post_meta->meta_id;
|
||||
}
|
||||
|
||||
echo
|
||||
'<div class="p" id="meta-edit-tpl"><label for="post_tpl">
|
||||
'.__('Entry template:').'</label>'.form::combo('post_tpl',$tpl,$selected).'</div>';
|
||||
|
||||
$sidebar_items['options-box']['items']['templator'] =
|
||||
'<div id="templator">' .
|
||||
'<h5>' . __('Template') . '</h5>' .
|
||||
'<p><label for="post_tpl">' . __('Select template:') . '</label>' .
|
||||
form::combo('post_tpl', self::getTemplateCombo(), $selected) . '</p>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public static function adminBeforePostUpdate($cur, $post_id)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$post_id = (integer) $post_id;
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if (isset($_POST['post_tpl'])) {
|
||||
$tpl = $_POST['post_tpl'];
|
||||
|
||||
$core->meta->delPostMeta($post_id,'template');
|
||||
if (!empty($_POST['post_tpl']))
|
||||
{
|
||||
$core->meta->setPostMeta($post_id,'template',$tpl);
|
||||
dcCore::app()->meta->delPostMeta($post_id, 'template');
|
||||
if (!empty($_POST['post_tpl'])) {
|
||||
dcCore::app()->meta->setPostMeta($post_id, 'template', $_POST['post_tpl']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function adminPostsActionsCombo($args)
|
||||
public static function adminPostsActions(dcPostsActions $pa)
|
||||
{
|
||||
$args[0][__('Appearance')] = array(__('Select the template') => 'tpl');
|
||||
$pa->addAction(
|
||||
[
|
||||
__('Appearance') => [
|
||||
__('Select the template') => 'tpl',
|
||||
],
|
||||
],
|
||||
['templatorBehaviors', 'adminPostsActionsCallback']
|
||||
);
|
||||
}
|
||||
|
||||
public static function adminPostsActions($core,$posts,$action,$redir)
|
||||
public static function adminPostsActionsCallback(dcPostsActions $pa, ArrayObject $post)
|
||||
{
|
||||
if ($action == 'tpl' && isset($_POST['post_tpl']))
|
||||
{
|
||||
try
|
||||
{
|
||||
$tpl = $_POST['post_tpl'];
|
||||
# No entry
|
||||
$posts_ids = $pa->getIDs();
|
||||
if (empty($posts_ids)) {
|
||||
throw new Exception(__('No entry selected'));
|
||||
}
|
||||
|
||||
while ($posts->fetch())
|
||||
{
|
||||
$core->meta->delPostMeta($posts->post_id,'template');
|
||||
if (!empty($_POST['post_tpl']))
|
||||
{
|
||||
$core->meta->setPostMeta($posts->post_id,'template',$tpl);
|
||||
if (isset($post['post_tpl'])) {
|
||||
try {
|
||||
foreach ($posts_ids as $post_id) {
|
||||
dcCore::app()->meta->delPostMeta($post_id, 'template');
|
||||
if (!empty($post['post_tpl'])) {
|
||||
dcCore::app()->meta->setPostMeta($post_id, 'template', $post['post_tpl']);
|
||||
}
|
||||
}
|
||||
|
||||
http::redirect($redir);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function adminPostsActionsContent($core,$action,$hidden_fields)
|
||||
{
|
||||
if ($action == 'tpl')
|
||||
{
|
||||
$tpl = array(' ' => '');
|
||||
$tpl_post = array();
|
||||
$selected = '';
|
||||
|
||||
foreach ($core->templator->tpl as $k => $v) {
|
||||
if (!preg_match('/^category-(.+)$/',$k) && !preg_match('/^list-(.+)$/',$k))
|
||||
{
|
||||
$tpl_post= array_merge($tpl_post, array($k => $k));
|
||||
dcAdminNotices::addSuccessNotice(__('Entries template updated.'));
|
||||
$pa->redirect(true);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = array_merge($tpl,$tpl_post);
|
||||
$pa->beginPage(
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Entry template') => '',
|
||||
])
|
||||
);
|
||||
|
||||
echo
|
||||
'<h2 class="page-title">'.__('Select template for these entries').'</h2>'.
|
||||
'<form action="posts_actions.php" method="post">'.
|
||||
'<p><label class="classic">'.__('Choose template:').' '.
|
||||
form::combo('post_tpl',$tpl).
|
||||
'</label> '.
|
||||
'<h2 class="page-title">' . __('Select template for the selection') . '</h2>' .
|
||||
'<form action="' . $pa->getURI() . '" method="post">' .
|
||||
$pa->getCheckboxes() .
|
||||
'<p><label class="classic">' . __('Select template:') . '</label> ' .
|
||||
form::combo('post_tpl', self::getTemplateCombo()) . '</p>' .
|
||||
|
||||
$hidden_fields.
|
||||
$core->formNonce().
|
||||
form::hidden(array('action'),'tpl').
|
||||
'<p>' .
|
||||
$pa->getHiddenFields() .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['action'], 'tpl') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
'</form>';
|
||||
|
||||
$pa->endPage();
|
||||
}
|
||||
|
||||
private static function getTemplateCombo()
|
||||
{
|
||||
$tpl = [__('No specific template') => ''];
|
||||
|
||||
foreach (dcCore::app()->templator->tpl as $k => $v) {
|
||||
if (!preg_match('/^category-(.+)$/', $k) && !preg_match('/^list-(.+)$/', $k)) {
|
||||
$tpl[$k] = $k;
|
||||
}
|
||||
}
|
||||
|
||||
return $tpl;
|
||||
}
|
||||
}
|
||||
?>
|
37
_define.php
37
_define.php
|
@ -1,22 +1,23 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */ 'Templator',
|
||||
/* Description*/ 'Create and select more templates for your posts',
|
||||
/* Author */ 'Osku and contributors',
|
||||
/* Version */ '1.3.3',
|
||||
/* Permissions */ 'contentadmin,templator'
|
||||
'Templator',
|
||||
'Create and select more templates for your posts',
|
||||
'Osku and contributors',
|
||||
'1.4-dev',
|
||||
[
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/templator',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/templator',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/templator/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
?>
|
10
_init.php
Normal file
10
_init.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class initTemplator
|
||||
{
|
||||
public const PERMISSION_TEMPLATOR = 'templator';
|
||||
}
|
51
_install.php
51
_install.php
|
@ -1,32 +1,35 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { exit; }
|
||||
|
||||
if (version_compare(DC_VERSION,'2.3.1','<'))
|
||||
{
|
||||
$core->error->add(__('Version 2.3.1 of Dotclear at least is required for this version of Templator.'));
|
||||
$core->plugins->deactivateModule('templator');
|
||||
return false;
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$new_version = $core->plugins->moduleInfo('templator','version');
|
||||
try {
|
||||
# Grab info
|
||||
$mod_id = basename(__DIR__);
|
||||
$dc_min = dcCore::app()->plugins->moduleInfo($mod_id, 'requires')[0][1];
|
||||
$new_version = dcCore::app()->plugins->moduleInfo($mod_id, 'version');
|
||||
|
||||
$current_version = $core->getVersion('templator');
|
||||
|
||||
if (version_compare($current_version,$new_version,'>=')) {
|
||||
return;
|
||||
if (version_compare(dcCore::app()->getVersion($mod_id), $new_version, '>=')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->setVersion('templator',$new_version);
|
||||
# Check Dotclear version
|
||||
if (!method_exists('dcUtils', 'versionsCompare')
|
||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||
throw new Exception(sprintf(
|
||||
'%s requires Dotclear %s',
|
||||
$mod_id,
|
||||
$dc_min
|
||||
));
|
||||
}
|
||||
|
||||
# Set version
|
||||
dcCore::app()->setVersion($mod_id, $new_version);
|
||||
|
||||
return true;
|
||||
?>
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
42
_prepend.php
42
_prepend.php
|
@ -1,34 +1,26 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
//if (version_compare(DC_VERSION,'2.2-beta','<')) { return; }
|
||||
$__autoload['dcTemplator'] = dirname(__FILE__).'/inc/class.templator.php';
|
||||
$__autoload['pagerTemplator'] = dirname(__FILE__).'/inc/admin.pager.templator.php';
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
Clearbricks::lib()->autoload([
|
||||
'dcTemplator' => __DIR__ . '/inc/class.templator.php',
|
||||
'pagerTemplator' => __DIR__ . '/inc/admin.pager.templator.php',
|
||||
]);
|
||||
|
||||
$core->templator = new dcTemplator($core);
|
||||
dcCore::app()->templator = new dcTemplator();
|
||||
|
||||
$core->addBehavior('initWidgets',array('templatorWidgets','initWidgets'));
|
||||
dcCore::app()->addBehavior('initWidgets', ['templatorWidgets', 'initWidgets']);
|
||||
|
||||
class templatorWidgets
|
||||
{
|
||||
public static function initWidgets($w)
|
||||
{
|
||||
$w->create('templatorWidget',__('Templator › Rendering'),array('widgetTemplator','getDataTpl'));
|
||||
$tpl = array(' .html' => '');
|
||||
foreach ($GLOBALS['core']->templator->tpl as $k => $v) {
|
||||
if (preg_match('/^widget-(.+)$/',$k))
|
||||
{
|
||||
$tpl = array_merge($tpl, array($k => $k));
|
||||
$w->create('templatorWidget', __('Templator › Rendering'), ['widgetTemplator', 'getDataTpl']);
|
||||
$tpl = [' .html' => ''];
|
||||
foreach (dcCore::app()->templator->tpl as $k => $v) {
|
||||
if (preg_match('/^widget-(.+)$/', $k)) {
|
||||
$tpl = array_merge($tpl, [$k => $k]);
|
||||
}
|
||||
}
|
||||
$w->templatorWidget->setting('template', __('Template:'), '', 'combo', $tpl);
|
||||
|
@ -39,10 +31,8 @@ class widgetTemplator
|
|||
{
|
||||
public static function getDataTpl($w)
|
||||
{
|
||||
if (($GLOBALS['core']->tpl->getFilePath($w->template)))
|
||||
{
|
||||
echo $GLOBALS['core']->tpl->getData($w->template);
|
||||
if (dcCore::app()->tpl->getFilePath($w->template)) {
|
||||
echo dcCore::app()->tpl->getData($w->template);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
44
_public.php
44
_public.php
|
@ -1,46 +1,32 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
$core->tpl->setPath($core->tpl->getPath(), $core->templator->path);
|
||||
$core->addBehavior('urlHandlerBeforeGetData',array('publicTemplatorBehaviors','BeforeGetData'));
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), dcCore::app()->templator->path);
|
||||
dcCore::app()->addBehavior('urlHandlerBeforeGetData', ['publicTemplatorBehaviors','BeforeGetData']);
|
||||
|
||||
class publicTemplatorBehaviors
|
||||
{
|
||||
public static function BeforeGetData ($_ctx)
|
||||
public static function BeforeGetData($_)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if (array_key_exists($core->url->type,$core->getPostTypes()) || ($core->url->type == 'pages'))
|
||||
{
|
||||
$params = array();
|
||||
if (array_key_exists(dcCore::app()->url->type, dcCore::app()->getPostTypes()) || dcCore::app()->url->type == 'pages') {
|
||||
$params = [];
|
||||
$params['meta_type'] = 'template';
|
||||
$params['post_id'] = $_ctx->posts->post_id;
|
||||
$post_meta = $core->meta->getMetadata($params);
|
||||
$params['post_id'] = dcCore::app()->ctx->posts->post_id;
|
||||
$post_meta = dcCore::app()->meta->getMetadata($params);
|
||||
|
||||
if (!$post_meta->isEmpty() && ($core->tpl->getFilePath($post_meta->meta_id)))
|
||||
{
|
||||
$_ctx->current_tpl = $post_meta->meta_id;
|
||||
if (!$post_meta->isEmpty() && dcCore::app()->tpl->getFilePath($post_meta->meta_id)) {
|
||||
dcCore::app()->ctx->current_tpl = $post_meta->meta_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (($_ctx->current_tpl == "category.html") && preg_match('/^[0-9]{1,}/',$_ctx->categories->cat_id,$cat_id))
|
||||
{
|
||||
if (dcCore::app()->ctx->current_tpl == 'category.html' && preg_match('/^[0-9]{1,}/', dcCore::app()->ctx->categories->cat_id, $cat_id)) {
|
||||
$tpl = 'category-' . $cat_id[0] . '.html';
|
||||
if (($core->tpl->getFilePath($tpl))) {
|
||||
$_ctx->current_tpl = $tpl;
|
||||
if (dcCore::app()->tpl->getFilePath($tpl)) {
|
||||
dcCore::app()->ctx->current_tpl = $tpl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
64
advanced.php
64
advanced.php
|
@ -1,36 +1,19 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ---------------------------------------
|
||||
#
|
||||
# This file is part of Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# See LICENSE file or
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK -----------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Templator'); ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="index.php?pf=tags/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo
|
||||
'<h2>'.html::escapeHTML($core->blog->name).' › <a href="'.$p_url.'">'.__('Supplementary templates').'</a> › <span class="page-title">'.__('Database informations').'</span></h2>';
|
||||
|
||||
$tags = $core->meta->getMetadata(array('meta_type' => 'template'));
|
||||
$tags = $core->meta->computeMetaStats($tags);
|
||||
$tags = dcCore::app()->meta->getMetadata(['meta_type' => 'template']);
|
||||
$tags = dcCore::app()->meta->computeMetaStats($tags);
|
||||
$tags->sort('meta_id_lower', 'asc');
|
||||
|
||||
$last_letter = null;
|
||||
$cols = array('','');
|
||||
$cols = ['',''];
|
||||
$col = 0;
|
||||
while ($tags->fetch())
|
||||
{
|
||||
|
||||
while ($tags->fetch()) {
|
||||
$letter = mb_strtoupper(mb_substr($tags->meta_id, 0, 1));
|
||||
|
||||
if ($last_letter != $letter) {
|
||||
|
@ -41,14 +24,13 @@ while ($tags->fetch())
|
|||
}
|
||||
|
||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||
if (array_key_exists($tags->meta_id,$core->templator->tpl)) {
|
||||
if (array_key_exists($tags->meta_id, dcCore::app()->templator->tpl)) {
|
||||
$img_status = sprintf($img, __('available template'), 'check-on.png');
|
||||
} else {
|
||||
$img_status = sprintf($img, __('missing template'), 'check-off.png');
|
||||
}
|
||||
|
||||
$cols[$col] .=
|
||||
'<tr class="line">'.
|
||||
$cols[$col] .= '<tr class="line">' .
|
||||
'<td class="maximal"><a href="' . $p_url .
|
||||
'&m=template_posts&template=' . rawurlencode($tags->meta_id) . '">' . $tags->meta_id . '</a> ' . $img_status . '</td>' .
|
||||
'<td class="nowrap"><strong>' . $tags->count . '</strong> ' .
|
||||
|
@ -60,20 +42,30 @@ while ($tags->fetch())
|
|||
|
||||
$table = '<div class="col"><table class="tags">%s</table></div>';
|
||||
|
||||
if ($cols[0])
|
||||
{
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Additional templates') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
'<p class="top-add"><a class="button add" id="templator-control" href="' .
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'new']) .
|
||||
'">' . __('New template') . '</a></p>';
|
||||
|
||||
if ($cols[0]) {
|
||||
echo '<div class="two-cols">';
|
||||
printf($table, $cols[0]);
|
||||
if ($cols[1]) {
|
||||
printf($table, $cols[1]);
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
echo '<p>' . __('No specific templates on this blog.') . '</p>';
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
dcPage::helpBlock('templator');
|
||||
|
||||
echo '</body></html>';
|
76
edit.php
76
edit.php
|
@ -1,73 +1,60 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
try {
|
||||
if (!empty($_GET['edit'])) {
|
||||
$name = rawurldecode($_GET['edit']);
|
||||
$file = $core->templator->getSourceContent($name);
|
||||
$file = dcCore::app()->templator->getSourceContent($name);
|
||||
$name = $file['f'];
|
||||
}
|
||||
|
||||
if (preg_match('/^category-(.+).html$/', $name, $cat_id)) {
|
||||
$category = $core->blog->getCategory($cat_id[1]);
|
||||
$category = dcCore::app()->blog->getCategory($cat_id[1]);
|
||||
$full_name = '';
|
||||
$cat_parents = $core->blog->getCategoryParents($cat_id[1]);
|
||||
while ($cat_parents->fetch()) {$full_name = $cat_parents->cat_title.' › ';};
|
||||
$full_name = $full_name.$core->blog->getCategory($cat_id)->cat_title;
|
||||
$cat_parents = dcCore::app()->blog->getCategoryParents($cat_id[1]);
|
||||
while ($cat_parents->fetch()) {
|
||||
$full_name = $cat_parents->cat_title . ' › ';
|
||||
};
|
||||
$full_name = $full_name . dcCore::app()->blog->getCategory($cat_id)->cat_title;
|
||||
$name .= '</strong> (' . $full_name . $category->cat_title . ')<strong>';
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$file = $file_default;
|
||||
|
||||
throw $e;
|
||||
}
|
||||
# Write file
|
||||
if (!empty($_POST['write']))
|
||||
{
|
||||
if (!empty($_POST['write'])) {
|
||||
$file['c'] = $_POST['file_content'];
|
||||
$core->templator->writeTpl($file['f'],$file['c']);
|
||||
dcCore::app()->templator->writeTpl($file['f'], $file['c']);
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Templator'); ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="index.php?pf=templator/style/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="<?php dcPage::getPF('templator/style/style.css'); ?>" />
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
<?php echo dcPage::jsVar('dotclear.msg.saving_document',__("Saving document...")); ?>
|
||||
<?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?>
|
||||
<?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?>
|
||||
<?php echo dcPage::jsVar('dotclear.msg.saving_document', __('Saving document...')); ?>
|
||||
<?php echo dcPage::jsVar('dotclear.msg.document_saved', __('Document saved')); ?>
|
||||
<?php echo dcPage::jsVar('dotclear.msg.error_occurred', __('An error occurred:')); ?>
|
||||
//]]>
|
||||
</script>
|
||||
<?php echo dcPage::jsLoad('index.php?pf=templator/js/script.js');?>
|
||||
<?php echo dcPage::jsLoad(dcPage::getPF('templator/js/script.js'));?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
echo
|
||||
'<h2>'.html::escapeHTML($core->blog->name).' › <a href="'.$p_url.'">'.__('Supplementary templates').'</a> › <span class="page-title">'.__('Edit the template').'</span></h2>';
|
||||
'<h2>' . html::escapeHTML(dcCore::app()->blog->name) . ' › <a href="' . $p_url . '">' . __('Supplementary templates') . '</a> › <span class="page-title">' . __('Edit the template') . '</span></h2>';
|
||||
|
||||
if (($file['c'] !== null))
|
||||
{
|
||||
if (($file['c'] !== null)) {
|
||||
echo
|
||||
'<div id="file-templator">' .
|
||||
'<form id="file-form" action="' . $p_url . '&edit=' . $name . '" method="post">' .
|
||||
|
@ -75,18 +62,13 @@ if (($file['c'] !== null))
|
|||
'<p>' . sprintf(__('Editing file %s'), '<strong>' . $name) . '</strong></p>' .
|
||||
'<p>' . form::textarea('file_content', 72, 30, html::escapeHTML($file['c']), 'maximal', '', !$file['w']) . '</p>';
|
||||
|
||||
if ($file['w'])
|
||||
{
|
||||
if ($file['w']) {
|
||||
echo
|
||||
'<p><input type="submit" name="write" value="' . __('Save') . '" accesskey="s" /> ' .
|
||||
$core->formNonce().
|
||||
form::hidden(array('file_id'),html::escapeHTML($file['f'])).
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['file_id'], html::escapeHTML($file['f'])) .
|
||||
'</p>';
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
echo '<p>' . __('This file is not writable. Please check your files permissions.') . '</p>';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
|
@ -9,20 +10,21 @@
|
|||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
class pagerTemplator
|
||||
{
|
||||
public static function templatorItemLine($f, $i)
|
||||
{
|
||||
global $core, $p_url;
|
||||
|
||||
$p_url = dcCore::app()->admin->getPageURL();
|
||||
$fname = $f->basename;
|
||||
$count = '';
|
||||
$params = array();
|
||||
$params = [];
|
||||
$link = 'media_item.php?id=' . $f->media_id;
|
||||
$link_edit = $p_url . '&edit=' . $fname;
|
||||
$icon = 'index.php?pf=templator/img/template.png';
|
||||
$icon = dcPage::getPF('templator/img/template.png');
|
||||
$class = 'media-item media-col-' . ($i % 2);
|
||||
$details = $special = '';
|
||||
$widget_icon = '<span class="widget" title="' . __('Template widget') . '">♦</span>';
|
||||
|
@ -32,18 +34,21 @@ class pagerTemplator
|
|||
// That is ugly.
|
||||
$cat_id = str_replace('category-', '', $f->basename);
|
||||
$cat_id = str_replace('.html', '', $cat_id);
|
||||
$cat_parents = $core->blog->getCategoryParents($cat_id);
|
||||
$cat_parents = dcCore::app()->blog->getCategoryParents($cat_id);
|
||||
$full_name = '';
|
||||
while ($cat_parents->fetch()) {$full_name = $cat_parents->cat_title.' › ';};
|
||||
$fname = '<strong>'.__('Category').'</strong> : '.$full_name.$core->blog->getCategory($cat_id)->cat_title;
|
||||
while ($cat_parents->fetch()) {
|
||||
$full_name = $cat_parents->cat_title . ' › ';
|
||||
};
|
||||
$fname = '<strong>' . __('Category') . '</strong> : ' . $full_name . dcCore::app()->blog->getCategory($cat_id)->cat_title;
|
||||
$params['cat_id'] = $cat_id;
|
||||
$params['post_type'] = '';
|
||||
$icon = 'index.php?pf=templator/img/template-alt.png';
|
||||
$icon = dcPage::getPF('templator/img/template-alt.png');
|
||||
$copy_url = '&copycat=';
|
||||
|
||||
try {
|
||||
$counter = $core->blog->getPosts($params,true);
|
||||
$counter = dcCore::app()->blog->getPosts($params, true);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
if ($counter->f(0) == 0) {
|
||||
|
@ -53,20 +58,19 @@ class pagerTemplator
|
|||
} 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 = ' ';
|
||||
$icon = 'index.php?pf=templator/img/template-widget.png';
|
||||
$icon = dcPage::getPF('templator/img/template-widget.png');
|
||||
$special = $widget_icon;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$params['meta_id'] = $f->basename;
|
||||
$params['meta_type'] = 'template';
|
||||
$params['post_type'] = '';
|
||||
|
||||
try {
|
||||
$counter = $core->meta->getPostsByMeta($params,true);
|
||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
if ($counter->f(0) == 0) {
|
||||
$count = ' ';
|
||||
|
@ -77,19 +81,20 @@ class pagerTemplator
|
|||
}
|
||||
}
|
||||
|
||||
$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>' .
|
||||
'<ul>' .
|
||||
'<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>';
|
||||
|
||||
if($core->auth->check('contentadmin,media',$core->blog->id)) {
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
$details = ' - <a href="' . $link . '">' . __('details') . '</a>';
|
||||
}
|
||||
|
||||
if (!$f->d) {
|
||||
$res .=
|
||||
'<li>'.$count.'</li>'.
|
||||
$res .= '<li>' . $count . '</li>' .
|
||||
'<li>' .
|
||||
$f->media_dtstr . ' - ' .
|
||||
files::size($f->size) .
|
||||
|
@ -101,13 +106,12 @@ class pagerTemplator
|
|||
|
||||
$res .= '<a class="media-remove" ' .
|
||||
'href="' . $p_url . $copy_url . rawurlencode($f->basename) . '">' .
|
||||
'<img src="index.php?pf=templator/img/copy.png" alt="'.__('copy').'" title="'.__('copy the template').'" /></a> ';
|
||||
|
||||
'<img src="' . dcPage::getPF('templator/img/copy.png') . '" alt="' . __('copy') . '" title="' . __('copy the template') . '" /></a> ';
|
||||
|
||||
if ($f->del) {
|
||||
$res .= '<a class="media-remove" ' .
|
||||
'href="' . $p_url . '&remove=' . rawurlencode($f->basename) . '">' .
|
||||
'<img src="index.php?pf=templator/img/delete.png" alt="'.__('delete').'" title="'.__('delete the template').'" /></a>';
|
||||
'<img src="' . dcPage::getPF('templator/img/delete.png') . '" alt="' . __('delete') . '" title="' . __('delete the template') . '" /></a>';
|
||||
}
|
||||
|
||||
$res .= '</li>';
|
||||
|
@ -117,4 +121,3 @@ class pagerTemplator
|
|||
return $res;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,18 +1,12 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class dcTemplator
|
||||
{
|
||||
protected $tpls_default_name = 'dotty';
|
||||
protected $post_default_name = 'post.html';
|
||||
protected $page_default_name = 'page.html';
|
||||
protected $category_default_name = 'category.html';
|
||||
|
@ -20,28 +14,26 @@ class dcTemplator
|
|||
public $template_dir_name = 'other-templates';
|
||||
public $path;
|
||||
|
||||
public $tpl = array();
|
||||
public $theme_tpl = array();
|
||||
public $tpl = [];
|
||||
public $theme_tpl = [];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($core)
|
||||
public function __construct()
|
||||
{
|
||||
$this->core =& $core;
|
||||
|
||||
$this->path = $this->core->blog->public_path.'/'.$this->template_dir_name;
|
||||
$this->path = dcCore::app()->blog->public_path . '/' . $this->template_dir_name;
|
||||
|
||||
// Initial templates
|
||||
$this->post_tpl = DC_ROOT.'/inc/public/default-templates/'.$this->post_default_name;
|
||||
$this->category_tpl = DC_ROOT.'/inc/public/default-templates/'.$this->category_default_name;
|
||||
$this->post_tpl = DC_ROOT . '/inc/public/default-templates/' . $this->tpls_default_name . '/' . $this->post_default_name;
|
||||
$this->category_tpl = DC_ROOT . '/inc/public/default-templates/' . $this->tpls_default_name . '/' . $this->category_default_name;
|
||||
|
||||
if ($this->core->plugins->moduleExists('pages')) {
|
||||
$plugin_page = $this->core->plugins->getModules('pages');
|
||||
$this->page_tpl = path::real($plugin_page['root'].'/default-templates/'.$this->page_default_name);
|
||||
if (dcCore::app()->plugins->moduleExists('pages')) {
|
||||
$plugin_page = dcCore::app()->plugins->getModules('pages');
|
||||
$this->page_tpl = path::real($plugin_page['root'] . '/default-templates/' . $this->tpls_default_name . '/' . $this->page_default_name);
|
||||
}
|
||||
|
||||
$this->user_theme = $this->core->blog->themes_path.'/'.$this->core->blog->settings->system->theme;
|
||||
$this->user_theme = dcCore::app()->blog->themes_path . '/' . dcCore::app()->blog->settings->system->theme;
|
||||
$this->user_post_tpl = path::real($this->user_theme . '/tpl/' . $this->post_default_name);
|
||||
$this->user_category_tpl = path::real($this->user_theme . '/tpl/' . $this->category_default_name);
|
||||
$this->user_page_tpl = path::real($this->user_theme . '/tpl/' . $this->page_default_name);
|
||||
|
@ -58,6 +50,7 @@ class dcTemplator
|
|||
if ($create) {
|
||||
files::makeDir($this->path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -68,9 +61,11 @@ class dcTemplator
|
|||
if (!is_file($this->path . '/.htaccess')) {
|
||||
try {
|
||||
file_put_contents($this->path . '/.htaccess', "Deny from all\n");
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
catch (Exception $e) {return false;}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,11 +85,11 @@ class dcTemplator
|
|||
throw new Exception(sprintf(__('File %s is not readable'), $f));
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'c' => file_get_contents($source[$f]),
|
||||
'w' => $this->getDestinationFile($f) !== false,
|
||||
'f' => $f
|
||||
);
|
||||
'f' => $f,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,8 +104,7 @@ class dcTemplator
|
|||
}
|
||||
|
||||
$list = '';
|
||||
foreach ($files as $k => $v)
|
||||
{
|
||||
foreach ($files as $k => $v) {
|
||||
$li = sprintf('<li>%s</li>', $item);
|
||||
|
||||
$list .= sprintf($li, $k, html::escapeHTML($k));
|
||||
|
@ -124,23 +118,19 @@ class dcTemplator
|
|||
*/
|
||||
public function initializeTpl($name, $type)
|
||||
{
|
||||
if ($type == 'category')
|
||||
{
|
||||
if ($type == 'category') {
|
||||
if ($this->user_category_tpl) {
|
||||
$base = $this->user_category_tpl;
|
||||
} else {
|
||||
$base = $this->category_tpl;
|
||||
}
|
||||
}
|
||||
elseif ($type == 'page')
|
||||
{
|
||||
} elseif ($type == 'page') {
|
||||
if ($this->user_page_tpl) {
|
||||
$base = $this->user_page_tpl;
|
||||
} else {
|
||||
$base = $this->page_tpl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($this->user_post_tpl) {
|
||||
$base = $this->user_post_tpl;
|
||||
} else {
|
||||
|
@ -148,23 +138,20 @@ class dcTemplator
|
|||
}
|
||||
}
|
||||
|
||||
$source = array(
|
||||
$source = [
|
||||
'c' => file_get_contents($base),
|
||||
'w' => $this->getDestinationFile($name) !== false,
|
||||
'f' => $f);
|
||||
'f' => $f, ];
|
||||
|
||||
if (!$source['w'])
|
||||
{
|
||||
if (!$source['w']) {
|
||||
throw new Exception(sprintf(__('File %s is not readable'), $source));
|
||||
}
|
||||
|
||||
if ($type == 'empty')
|
||||
{
|
||||
if ($type == 'empty') {
|
||||
$source['c'] = '';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$dest = $this->getDestinationFile($name);
|
||||
|
||||
if ($dest == false) {
|
||||
|
@ -187,12 +174,9 @@ class dcTemplator
|
|||
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,27 +184,26 @@ class dcTemplator
|
|||
*/
|
||||
public function copypasteTpl($name, $source)
|
||||
{
|
||||
if ($name == $source) {throw new Exception(__('Why copy file content in the same file?'));}
|
||||
if ($name == $source) {
|
||||
throw new Exception(__('Why copy file content in the same file?'));
|
||||
}
|
||||
|
||||
$file = $this->getSourceContent($source);
|
||||
|
||||
$source = array(
|
||||
$source = [
|
||||
'c' => $file['c'],
|
||||
'w' => $this->getDestinationFile($name) !== false,
|
||||
'f' => $f);
|
||||
'f' => $f, ];
|
||||
|
||||
if (!$source['w'])
|
||||
{
|
||||
if (!$source['w']) {
|
||||
throw new Exception(sprintf(__('File %s is not readable'), $source));
|
||||
}
|
||||
|
||||
if ($type == 'empty')
|
||||
{
|
||||
if ($type == 'empty') {
|
||||
$source['c'] = '';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$dest = $this->getDestinationFile($name);
|
||||
|
||||
if ($dest == false) {
|
||||
|
@ -243,9 +226,7 @@ class dcTemplator
|
|||
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
@ -255,8 +236,7 @@ class dcTemplator
|
|||
*/
|
||||
public function writeTpl($name, $content)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$dest = $this->getDestinationFile($name);
|
||||
|
||||
if ($dest == false) {
|
||||
|
@ -277,9 +257,7 @@ class dcTemplator
|
|||
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
@ -289,8 +267,7 @@ class dcTemplator
|
|||
*/
|
||||
public function copyTpl($name)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$file = $this->getSourceContent($name);
|
||||
$dest = $this->getDestinationFile($name, true);
|
||||
|
||||
|
@ -312,9 +289,7 @@ class dcTemplator
|
|||
|
||||
fwrite($fp, $file['c']);
|
||||
fclose($fp);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +317,7 @@ class dcTemplator
|
|||
$this->tpl = $this->getFilesInDir($this->path);
|
||||
//$this->theme_tpl = $this->getFilesInDir(path::real($this->user_theme).'/tpl');
|
||||
|
||||
uksort($this->tpl,array($this,'sortFilesHelper'));
|
||||
uksort($this->tpl, [$this,'sortFilesHelper']);
|
||||
//uksort($this->theme_tpl,array($this,'sortFilesHelper'));
|
||||
}
|
||||
|
||||
|
@ -350,13 +325,12 @@ class dcTemplator
|
|||
{
|
||||
$dir = path::real($dir);
|
||||
if (!$dir || !is_dir($dir) || !is_readable($dir)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$d = dir($dir);
|
||||
$res = array();
|
||||
while (($f = $d->read()) !== false)
|
||||
{
|
||||
$res = [];
|
||||
while (($f = $d->read()) !== false) {
|
||||
if (is_file($dir . '/' . $f) && !preg_match('/^\./', $f)) {
|
||||
$res[$f] = $dir . '/' . $f;
|
||||
}
|
||||
|
@ -377,4 +351,3 @@ class dcTemplator
|
|||
return strcmp($ext_a . '.' . $a, $ext_b . '.' . $b);
|
||||
}
|
||||
}
|
||||
?>
|
231
index.php
231
index.php
|
@ -1,60 +1,61 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of templator a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
dcPage::check('templator,contentadmin');
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcPage::check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]));
|
||||
|
||||
$p_url = dcCore::app()->admin->getPageURL();
|
||||
|
||||
if ((!empty($_REQUEST['m'])) && ($_REQUEST['m'] = 'template_posts')) {
|
||||
require dirname(__FILE__) . '/' . $_REQUEST['m'] . '.php';
|
||||
|
||||
return;
|
||||
}
|
||||
if (!empty($_REQUEST['edit'])) {
|
||||
require dirname(__FILE__) . '/edit.php';
|
||||
|
||||
return;
|
||||
}
|
||||
if (!empty($_REQUEST['database']) && $_REQUEST['database'] = 'on') {
|
||||
require dirname(__FILE__) . '/advanced.php';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$file_default = $file = array('c'=>null, 'w'=>false, 'type'=>null, 'f'=>null, 'default_file'=>false);
|
||||
$file_default = $file = ['c' => null, 'w' => false, 'type' => null, 'f' => null, 'default_file' => false];
|
||||
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
|
||||
$nb_per_page = 20;
|
||||
$msg = '';
|
||||
$remove_confirm = false;
|
||||
|
||||
// Load infos.
|
||||
$ressources = $core->templator->canUseRessources(true);
|
||||
$files= $core->templator->tpl;
|
||||
$ressources = dcCore::app()->templator->canUseRessources(true);
|
||||
$files = dcCore::app()->templator->tpl;
|
||||
|
||||
// Media
|
||||
$media = new dcMedia($core);
|
||||
$media->chdir($core->templator->template_dir_name);
|
||||
$media = new dcMedia();
|
||||
$media->chdir(dcCore::app()->templator->template_dir_name);
|
||||
// For users with only templator permission, we use sudo.
|
||||
$core->auth->sudo(array($media,'getDir'));
|
||||
dcCore::app()->auth->sudo([$media,'getDir']);
|
||||
$dir = & $media->dir;
|
||||
//if files did not appear in this list, check blog->settings->media_exclusion
|
||||
$items = array_values($dir['files']);
|
||||
|
||||
// Categories
|
||||
try {
|
||||
$categories = $core->blog->getCategories(array('post_type'=>'post'));
|
||||
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
|
||||
|
||||
$categories_combo = array();
|
||||
$categories_combo = [];
|
||||
$l = $categories->level;
|
||||
$full_name = array($categories->cat_title);
|
||||
$full_name = [$categories->cat_title];
|
||||
|
||||
while ($categories->fetch()) {
|
||||
|
||||
if ($categories->level < $l) {
|
||||
$full_name = array();
|
||||
$full_name = [];
|
||||
} elseif ($categories->level == $l) {
|
||||
array_pop($full_name);
|
||||
}
|
||||
|
@ -63,18 +64,17 @@ try {
|
|||
$categories_combo[implode(' › ', $full_name)] = $categories->cat_id;
|
||||
|
||||
$l = $categories->level;
|
||||
|
||||
}
|
||||
} catch (Exception $e) { }
|
||||
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$hasCategories = ($categories->isEmpty()) ? false : true;
|
||||
|
||||
$combo_source = array(
|
||||
'post.html' => 'post'
|
||||
);
|
||||
$combo_source = [
|
||||
'post.html' => 'post',
|
||||
];
|
||||
|
||||
if ($core->auth->check('pages',$core->blog->id) && $core->plugins->moduleExists('pages')) {
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcPages::PERMISSION_PAGES]), dcCore::app()->blog->id) && dcCore::app()->plugins->moduleExists('pages')) {
|
||||
$combo_source['page.html'] = 'page';
|
||||
}
|
||||
|
||||
|
@ -86,132 +86,108 @@ $combo_source[' — '] = 'empty';
|
|||
|
||||
$add_template = $copy_confirm = $copycat_confirm = false;
|
||||
|
||||
if (!$ressources)
|
||||
{
|
||||
$core->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
|
||||
if (!$ressources) {
|
||||
dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
|
||||
}
|
||||
|
||||
if (!empty($_POST['filesource']))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!empty($_POST['filesource'])) {
|
||||
try {
|
||||
$source = $_POST['filesource'];
|
||||
if (empty($_POST['filename']) && $source != 'category') {
|
||||
throw new Exception(__('Filename is empty.'));
|
||||
}
|
||||
$name = files::tidyFileName($_POST['filename']) . '.html';
|
||||
if ($source == 'category')
|
||||
{
|
||||
if ($source == 'category') {
|
||||
$name = 'category-' . $_POST['filecat'] . '.html';
|
||||
}
|
||||
$core->templator->initializeTpl($name,$source);
|
||||
dcCore::app()->templator->initializeTpl($name, $source);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The new template has been successfully created.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
if (!$core->error->flag()) {
|
||||
http::redirect($p_url.'&msg=new');
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['rmyes']) && !empty($_POST['remove'])) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$file = rawurldecode($_POST['remove']);
|
||||
$media->removeItem($file);
|
||||
$core->meta->delMeta($file,'template');
|
||||
dcCore::app()->meta->delMeta($file, 'template');
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully removed.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
if (!$core->error->flag()) {
|
||||
http::redirect($p_url.'&msg=del');
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['cpyes']) && !empty($_POST['copy']) && !empty($_POST['newfile'])) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$file = rawurldecode($_POST['copy']);
|
||||
$newfile = rawurldecode($_POST['newfile']) . '.html';
|
||||
$core->templator->copypasteTpl($newfile,$file);
|
||||
dcCore::app()->templator->copypasteTpl($newfile, $file);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
if (!$core->error->flag()) {
|
||||
http::redirect($p_url.'&msg=cpy');
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['cpyes']) && !empty($_POST['copycat']) && !empty($_POST['copcat'])) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$file = rawurldecode($_POST['copycat']);
|
||||
$newfile = 'category-' . rawurldecode($_POST['copcat']) . '.html';
|
||||
$core->templator->copypasteTpl($newfile,$file);
|
||||
dcCore::app()->templator->copypasteTpl($newfile, $file);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
if (!$core->error->flag()) {
|
||||
http::redirect($p_url.'&msg=cpy');
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['remove']))
|
||||
{
|
||||
if (!empty($_GET['remove'])) {
|
||||
$remove_confirm = true;
|
||||
}
|
||||
if (!empty($_GET['copy']))
|
||||
{
|
||||
if (!empty($_GET['copy'])) {
|
||||
$copy_confirm = true;
|
||||
}
|
||||
if (!empty($_GET['copycat']))
|
||||
{
|
||||
if (!empty($_GET['copycat'])) {
|
||||
$copycat_confirm = true;
|
||||
}
|
||||
|
||||
$msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : '';
|
||||
$msg_list = array(
|
||||
'new' => __('The new template has been successfully created.'),
|
||||
'del' => __('The template has been successfully removed.'),
|
||||
'cpy' => __('The template has been successfully copied.')
|
||||
);
|
||||
if (isset($msg_list[$msg])) {
|
||||
$msg = sprintf('<p class="message">%s</p>',$msg_list[$msg]);
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Templator'); ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="index.php?pf=templator/style/style.css" />
|
||||
<?php if (!$add_template) {
|
||||
echo dcPage::jsLoad('index.php?pf=templator/js/form.js');
|
||||
}?>
|
||||
<?php echo dcPage::jsLoad('index.php?pf=templator/js/script.js');?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
echo $msg;
|
||||
|
||||
echo
|
||||
'<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Supplementary templates').'</span></h2>';
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
dcPage::cssLoad(dcPage::getPF('templator/style/style.css')) .
|
||||
(!$add_template ? dcPage::jsLoad(dcPage::getPF('templator/js/form.js')) : '') .
|
||||
dcPage::jsLoad(dcPage::getPF('templator/js/script.js')) .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Additional templates') => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
if ($remove_confirm) {
|
||||
echo
|
||||
'<form action="' . $p_url . '" method="post">' .
|
||||
'<p>'.sprintf(__('Are you sure you want to remove the template "%s"?'),
|
||||
html::escapeHTML($_GET['remove'])).'</p>'.
|
||||
'<p>' . sprintf(
|
||||
__('Are you sure you want to remove the template "%s"?'),
|
||||
html::escapeHTML($_GET['remove'])
|
||||
) . '</p>' .
|
||||
'<p><input type="submit" class="delete" value="' . __('Cancel') . '" /> ' .
|
||||
' <input type="submit" name="rmyes" value="' . __('Yes') . '" />' .
|
||||
$core->formNonce().
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden('remove', html::escapeHTML($_GET['remove'])) . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
|
@ -219,12 +195,14 @@ if ($remove_confirm) {
|
|||
if ($copy_confirm) {
|
||||
echo
|
||||
'<form action="' . $p_url . '" method="post">' .
|
||||
'<p>'.sprintf(__('To copy the template <strong>%s</strong>, you need to fill a new filename.'),
|
||||
html::escapeHTML($_GET['copy'])).'</p>'.
|
||||
'<p>' . sprintf(
|
||||
__('To copy the template <strong>%s</strong>, you need to fill a new filename.'),
|
||||
html::escapeHTML($_GET['copy'])
|
||||
) . '</p>' .
|
||||
'<p><label for="filename" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New filename:') . ' ' .
|
||||
form::field('newfile', 25, 255) . '</label><code>' . html::escapeHTML('.html') . '</code> ' .
|
||||
'<input type="submit" name="cpyes" value="' . __('Copy') . '" /> <input class="delete" type="submit" value="' . __('Cancel') . '" />' .
|
||||
$core->formNonce().
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden('copy', html::escapeHTML($_GET['copy'])) . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
|
@ -232,18 +210,23 @@ form::field('newfile',25,255).'</label><code>'.html::escapeHTML('.html').'</code
|
|||
if ($copycat_confirm) {
|
||||
$category_id = str_replace('category-', '', $_GET['copycat']);
|
||||
$category_id = str_replace('.html', '', $category_id);
|
||||
$cat_parents = $core->blog->getCategoryParents($category_id);
|
||||
$cat_parents = dcCore::app()->blog->getCategoryParents($category_id);
|
||||
$full_name = '';
|
||||
while ($cat_parents->fetch()) {$full_name = $cat_parents->cat_title.' › ';};
|
||||
$name = $full_name.$core->blog->getCategory($category_id)->cat_title;
|
||||
while ($cat_parents->fetch()) {
|
||||
$full_name = $cat_parents->cat_title . ' › ';
|
||||
};
|
||||
$name = $full_name . dcCore::app()->blog->getCategory($category_id)->cat_title;
|
||||
echo
|
||||
'<form action="' . $p_url . '" method="post">' .
|
||||
'<p>'.sprintf(__('To copy the template <strong>%s</strong> (%s), you need to choose a category.'),
|
||||
html::escapeHTML($_GET['copycat']),$name).'</p>'.
|
||||
'<p>' . sprintf(
|
||||
__('To copy the template <strong>%s</strong> (%s), you need to choose a category.'),
|
||||
html::escapeHTML($_GET['copycat']),
|
||||
$name
|
||||
) . '</p>' .
|
||||
'<p class="field"><label for="copcat" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Target category:') .
|
||||
form::combo('copcat', $categories_combo, '') . '</label></p>' .
|
||||
'<input type="submit" name="cpyes" value="' . __('Copy') . '" /> <input class="delete" type="submit" value="' . __('Cancel') . '" />' .
|
||||
$core->formNonce().
|
||||
$dcCore::app()->formNonce() .
|
||||
form::hidden('copycat', html::escapeHTML($_GET['copycat'])) .
|
||||
'</form>';
|
||||
}
|
||||
|
@ -269,17 +252,14 @@ if ($hasCategories) {
|
|||
}
|
||||
|
||||
echo
|
||||
'<p>'.form::hidden(array('p'),'templator').
|
||||
$core->formNonce().
|
||||
'<p>' . form::hidden(['p'], 'templator') .
|
||||
dcCore::app()->formNonce() .
|
||||
'<input type="submit" name="add_message" value="' . __('Create') . '" /></p>' .
|
||||
'</form>';
|
||||
|
||||
if (count($items) == 0)
|
||||
{
|
||||
if (count($items) == 0) {
|
||||
echo '<p><strong>' . __('No template.') . '</strong></p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$pager = new pager($page, count($items), $nb_per_page, 10);
|
||||
$pager->html_prev = __('«prev.');
|
||||
$pager->html_next = __('next»');
|
||||
|
@ -291,8 +271,7 @@ else
|
|||
'<div class="media-list">' .
|
||||
'<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>';
|
||||
|
||||
for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++, $j++)
|
||||
{
|
||||
for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) {
|
||||
echo pagerTemplator::templatorItemLine($items[$i], $j);
|
||||
}
|
||||
|
||||
|
|
7
js/admin.js
Normal file
7
js/admin.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
$(function(){
|
||||
/* toogle admin form sidebar */
|
||||
$('#templator h5').toggleWithLegend(
|
||||
$('#templator').children().not('h5'),
|
||||
{cookie:'dcx_templator_admin_form_sidebar',legend_click:true}
|
||||
);
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Language: Français
|
||||
// Module: templator - 1.3.3
|
||||
// Date: 2012-10-02 12:59:08
|
||||
|
@ -146,5 +147,3 @@ $GLOBALS['__l10n']['Back to templates list'] = 'Retour à la liste des templates
|
|||
|
||||
#template_posts.php:128
|
||||
$GLOBALS['__l10n']['Unselect the template'] = 'Désélectionner le template';
|
||||
|
||||
?>
|
|
@ -9,7 +9,9 @@
|
|||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$template = (!empty($_REQUEST['template']) || $_REQUEST['template'] == '0') ? $_REQUEST['template'] : '';
|
||||
|
||||
|
@ -19,18 +21,17 @@ $page = !empty($_GET['page']) ? $_GET['page'] : 1;
|
|||
$nb_per_page = 30;
|
||||
|
||||
# Unselect the template
|
||||
if (!empty($_POST['initialise']) && $core->auth->check('publish,contentadmin',$core->blog->id))
|
||||
{
|
||||
if (!empty($_POST['initialise']) && dcCore::app()->auth->check('publish,contentadmin', dcCore::app()->blog->id)) {
|
||||
try {
|
||||
$core->meta->delMeta($template,'template');
|
||||
dcCore::app()->meta->delMeta($template, 'template');
|
||||
http::redirect($p_url . '&del=' . $template);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
|
||||
$params = [];
|
||||
$params['limit'] = [(($page - 1) * $nb_per_page),$nb_per_page];
|
||||
$params['no_content'] = true;
|
||||
|
||||
$params['meta_id'] = $template;
|
||||
|
@ -39,41 +40,48 @@ $params['post_type'] = '';
|
|||
|
||||
# Get posts
|
||||
try {
|
||||
$posts = $core->meta->getPostsByMeta($params);
|
||||
$counter = $core->meta->getPostsByMeta($params,true);
|
||||
$post_list = new adminPostList($core,$posts,$counter->f(0));
|
||||
$posts = dcCore::app()->meta->getPostsByMeta($params);
|
||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
||||
$post_list = new adminPostList($posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
# Actions combo box
|
||||
$combo_action = array();
|
||||
if ($core->auth->check('publish,contentadmin',$core->blog->id))
|
||||
{
|
||||
$combo_action[__('Status')] = array(
|
||||
$combo_action = [];
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_PUBLISH,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
$combo_action[__('Status')] = [
|
||||
__('Publish') => 'publish',
|
||||
__('Unpublish') => 'unpublish',
|
||||
__('Schedule') => 'schedule',
|
||||
__('Mark as pending') => 'pending'
|
||||
);
|
||||
__('Mark as pending') => 'pending',
|
||||
];
|
||||
}
|
||||
$combo_action[__('Mark')] = array(
|
||||
$combo_action[__('Mark')] = [
|
||||
__('Mark as selected') => 'selected',
|
||||
__('Mark as unselected') => 'unselected'
|
||||
__('Mark as unselected') => 'unselected',
|
||||
];
|
||||
$combo_action[__('Change')] = [__('Change category') => 'category'];
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
$combo_action[__('Change')] = array_merge(
|
||||
$combo_action[__('Change')],
|
||||
[__('Change author') => 'author']
|
||||
);
|
||||
$combo_action[__('Change')] = array(__('Change category') => 'category');
|
||||
if ($core->auth->check('admin',$core->blog->id))
|
||||
{
|
||||
$combo_action[__('Change')] = array_merge($combo_action[__('Change')],
|
||||
array(__('Change author') => 'author'));
|
||||
}
|
||||
if ($core->auth->check('delete,contentadmin',$core->blog->id))
|
||||
{
|
||||
$combo_action[__('Delete')] = array(__('Delete') => 'delete');
|
||||
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_DELETE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
$combo_action[__('Delete')] = [__('Delete') => 'delete'];
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- adminPostsActionsCombo
|
||||
$core->callBehavior('adminPostsActionsCombo',array(&$combo_action));
|
||||
dcCore::app()->callBehavior('adminPostsActionsCombo', [&$combo_action]);
|
||||
|
||||
?>
|
||||
<html>
|
||||
|
@ -93,17 +101,18 @@ $core->callBehavior('adminPostsActionsCombo',array(&$combo_action));
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<h2><?php echo html::escapeHTML($core->blog->name); ?> ›
|
||||
<h2><?php echo html::escapeHTML(dcCore::app()->blog->name); ?> ›
|
||||
<span class="page-title"><?php echo __('Unselect specific template'); ?></span></h2>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<p><a href="' . $p_url . '">' . __('Back to templates list') . '</a></p>';
|
||||
|
||||
if (!$core->error->flag())
|
||||
{
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
# Show posts
|
||||
$post_list->display($page,$nb_per_page,
|
||||
$post_list->display(
|
||||
$page,
|
||||
$nb_per_page,
|
||||
'<form action="posts_actions.php" method="post" id="form-entries">' .
|
||||
|
||||
'%s' .
|
||||
|
@ -117,16 +126,19 @@ if (!$core->error->flag())
|
|||
form::hidden('post_type', '') .
|
||||
form::hidden('redir', $p_url . '&m=template_posts&tag=' .
|
||||
str_replace('%', '%%', rawurlencode($template)) . '&page=' . $page) .
|
||||
$core->formNonce().
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>');
|
||||
'</form>'
|
||||
);
|
||||
|
||||
# Remove tag
|
||||
if (!$posts->isEmpty() && $core->auth->check('contentadmin',$core->blog->id)) {
|
||||
if (!$posts->isEmpty() && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
echo
|
||||
'<form id="template_change" action="' . $this_url . '" method="post">' .
|
||||
'<p><input type="submit" name="initialise" value="' . __('Unselect the template') . '" />' .
|
||||
$core->formNonce().'</p>'.
|
||||
dcCore::app()->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue