refresh admin, group index (WIP)
This commit is contained in:
parent
a051f78816
commit
57fee61b96
11 changed files with 598 additions and 558 deletions
15
_admin.php
15
_admin.php
|
@ -7,7 +7,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
dcCore::app()->auth->setPermissionType(initTemplator::PERMISSION_TEMPLATOR, __('manage templates'));
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Templates'),
|
||||
__('Templates engine'),
|
||||
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']),
|
||||
|
@ -34,6 +34,19 @@ if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
|||
dcCore::app()->addBehavior('adminPostsActions', ['templatorBehaviors','adminPostsActions']);
|
||||
dcCore::app()->addBehavior('adminPagesActions', ['templatorBehaviors','adminPostsActions']);
|
||||
|
||||
dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
|
||||
$sorts['templator'] = [
|
||||
__('Templates engine'),
|
||||
[
|
||||
__('Date') => 'post_upddt',
|
||||
__('Title') => 'post_title',
|
||||
__('Category') => 'cat_id',
|
||||
],
|
||||
'post_upddt',
|
||||
'desc',
|
||||
[__('Entries per page'), 30],
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
class templatorBehaviors
|
||||
|
|
|
@ -5,6 +5,7 @@ if (!defined('DC_RC_PATH')) {
|
|||
}
|
||||
Clearbricks::lib()->autoload([
|
||||
'dcTemplator' => __DIR__ . '/inc/class.templator.php',
|
||||
'templatorMedia' => __DIR__ . '/inc/class.templator.media.php',
|
||||
'pagerTemplator' => __DIR__ . '/inc/admin.pager.templator.php',
|
||||
]);
|
||||
|
||||
|
|
71
advanced.php
71
advanced.php
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tags = dcCore::app()->meta->getMetadata(['meta_type' => 'template']);
|
||||
$tags = dcCore::app()->meta->computeMetaStats($tags);
|
||||
$tags->sort('meta_id_lower', 'asc');
|
||||
|
||||
$last_letter = null;
|
||||
$cols = ['',''];
|
||||
$col = 0;
|
||||
|
||||
while ($tags->fetch()) {
|
||||
$letter = mb_strtoupper(mb_substr($tags->meta_id, 0, 1));
|
||||
|
||||
if ($last_letter != $letter) {
|
||||
if ($tags->index() >= round($tags->count() / 2)) {
|
||||
$col = 1;
|
||||
}
|
||||
$cols[$col] .= '<tr class="tagLetter"><td colspan="2"><span>' . $letter . '</span></td></tr>';
|
||||
}
|
||||
|
||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||
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">' .
|
||||
'<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> ' .
|
||||
(($tags->count == 1) ? __('entry') : __('entries')) . '</td>' .
|
||||
'</tr>';
|
||||
|
||||
$last_letter = $letter;
|
||||
}
|
||||
|
||||
$table = '<div class="col"><table class="tags">%s</table></div>';
|
||||
|
||||
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 {
|
||||
echo '<p>' . __('No specific templates on this blog.') . '</p>';
|
||||
}
|
||||
|
||||
dcPage::helpBlock('templator');
|
||||
|
||||
echo '</body></html>';
|
81
edit.php
81
edit.php
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
if (!empty($_GET['edit'])) {
|
||||
$name = rawurldecode($_GET['edit']);
|
||||
$file = dcCore::app()->templator->getSourceContent($name);
|
||||
$name = $file['f'];
|
||||
}
|
||||
|
||||
if (preg_match('/^category-(.+).html$/', $name, $cat_id)) {
|
||||
$category = dcCore::app()->blog->getCategory($cat_id[1]);
|
||||
$full_name = '';
|
||||
$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) {
|
||||
$file = $file_default;
|
||||
|
||||
throw $e;
|
||||
}
|
||||
# Write file
|
||||
if (!empty($_POST['write'])) {
|
||||
$file['c'] = $_POST['file_content'];
|
||||
dcCore::app()->templator->writeTpl($file['f'], $file['c']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Templator'); ?></title>
|
||||
<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:')); ?>
|
||||
//]]>
|
||||
</script>
|
||||
<?php echo dcPage::jsLoad(dcPage::getPF('templator/js/script.js'));?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
echo
|
||||
'<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)) {
|
||||
echo
|
||||
'<div id="file-templator">' .
|
||||
'<form id="file-form" action="' . $p_url . '&edit=' . $name . '" method="post">' .
|
||||
'<fieldset><legend>' . __('File editor') . '</legend>' .
|
||||
'<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']) {
|
||||
echo
|
||||
'<p><input type="submit" name="write" value="' . __('Save') . '" accesskey="s" /> ' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['file_id'], html::escapeHTML($file['f'])) .
|
||||
'</p>';
|
||||
} else {
|
||||
echo '<p>' . __('This file is not writable. Please check your files permissions.') . '</p>';
|
||||
}
|
||||
|
||||
echo
|
||||
'</fieldset></form></div>';
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -23,12 +23,12 @@ class pagerTemplator
|
|||
$count = '';
|
||||
$params = [];
|
||||
$link = 'media_item.php?id=' . $f->media_id;
|
||||
$link_edit = $p_url . '&edit=' . $fname;
|
||||
$link_edit = dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'edit', 'file' => $f->basename]);
|
||||
$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>';
|
||||
$copy_url = '&copy=';
|
||||
$part = 'copy';
|
||||
|
||||
if (preg_match('/^category-(.+)$/', $f->basename)) {
|
||||
// That is ugly.
|
||||
|
@ -43,7 +43,7 @@ class pagerTemplator
|
|||
$params['cat_id'] = $cat_id;
|
||||
$params['post_type'] = '';
|
||||
$icon = dcPage::getPF('templator/img/template-alt.png');
|
||||
$copy_url = '&copycat=';
|
||||
$part = 'copycat';;
|
||||
|
||||
try {
|
||||
$counter = dcCore::app()->blog->getPosts($params, true);
|
||||
|
@ -72,12 +72,17 @@ class pagerTemplator
|
|||
} catch (Exception $e) {
|
||||
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 = ' ';
|
||||
$count = __('No entry');
|
||||
} elseif ($counter->f(0) == 1) {
|
||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $p_url . '&m=template_posts&template=' . $fname . '">' . __('entry') . '</a>';
|
||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entry') . '</a>';
|
||||
} else {
|
||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $p_url . '&m=template_posts&template=' . $fname . '">' . __('entries') . '</a>';
|
||||
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entries') . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,14 +90,14 @@ class pagerTemplator
|
|||
'<img src="' . $icon . '" alt="" /></a>' .
|
||||
'<ul>' .
|
||||
'<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>';
|
||||
|
||||
/*
|
||||
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>' .
|
||||
'<li>' .
|
||||
|
@ -104,13 +109,13 @@ class pagerTemplator
|
|||
|
||||
$res .= '<li class="media-action"> ';
|
||||
|
||||
$res .= '<a class="media-remove" ' .
|
||||
'href="' . $p_url . $copy_url . rawurlencode($f->basename) . '">' .
|
||||
$res .= '<a class="media-remove" href="' .
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => $part, 'file' => $f->basename]) . '">' .
|
||||
'<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) . '">' .
|
||||
$res .= '<a class="media-remove" href="' .
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'delete', 'file' => $f->basename]) . '">' .
|
||||
'<img src="' . dcPage::getPF('templator/img/delete.png') . '" alt="' . __('delete') . '" title="' . __('delete the template') . '" /></a>';
|
||||
}
|
||||
|
||||
|
|
10
inc/class.templator.media.php
Normal file
10
inc/class.templator.media.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
class templatorMedia extends dcMedia
|
||||
{
|
||||
// limit to html files
|
||||
protected function isFileExclude(string $file): bool
|
||||
{
|
||||
return !preg_match('/\.html$/i', $file);
|
||||
}
|
||||
}
|
647
index.php
647
index.php
|
@ -8,44 +8,25 @@ dcPage::check(dcCore::app()->auth->makePermissions([
|
|||
initTemplator::PERMISSION_TEMPLATOR,
|
||||
]));
|
||||
|
||||
$p_url = dcCore::app()->admin->getPageURL();
|
||||
$part = $_REQUEST['part'] ?? '';
|
||||
|
||||
if ((!empty($_REQUEST['m'])) && ($_REQUEST['m'] = 'template_posts')) {
|
||||
require dirname(__FILE__) . '/' . $_REQUEST['m'] . '.php';
|
||||
### grab info ###
|
||||
|
||||
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 = ['c' => null, 'w' => false, 'type' => null, 'f' => null, 'default_file' => false];
|
||||
if (in_array($part, ['files', 'delete'])) {
|
||||
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
|
||||
$nb_per_page = 20;
|
||||
$msg = '';
|
||||
$remove_confirm = false;
|
||||
|
||||
// Load infos.
|
||||
$ressources = dcCore::app()->templator->canUseRessources(true);
|
||||
$files = dcCore::app()->templator->tpl;
|
||||
|
||||
// Media
|
||||
$media = new dcMedia();
|
||||
$media = new templatorMedia();
|
||||
$media->chdir(dcCore::app()->templator->template_dir_name);
|
||||
// For users with only templator permission, we use sudo.
|
||||
dcCore::app()->auth->sudo([$media,'getDir']);
|
||||
$dir = & $media->dir;
|
||||
$dir = $media->dir;
|
||||
//if files did not appear in this list, check blog->settings->media_exclusion
|
||||
$items = array_values($dir['files']);
|
||||
}
|
||||
|
||||
// Categories
|
||||
if (in_array($part, ['new', 'copycat'])) {
|
||||
$has_categories = false;
|
||||
try {
|
||||
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
|
||||
|
||||
|
@ -65,12 +46,12 @@ try {
|
|||
|
||||
$l = $categories->level;
|
||||
}
|
||||
$has_categories = !$categories->isEmpty();
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$hasCategories = ($categories->isEmpty()) ? false : true;
|
||||
|
||||
$combo_source = [
|
||||
' — ' => 'empty',
|
||||
'post.html' => 'post',
|
||||
];
|
||||
|
||||
|
@ -78,29 +59,26 @@ if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcPages::PE
|
|||
$combo_source['page.html'] = 'page';
|
||||
}
|
||||
|
||||
if (!$categories->isEmpty()) {
|
||||
if ($has_categories) {
|
||||
$combo_source['category.html'] = 'category';
|
||||
}
|
||||
|
||||
$combo_source[' — '] = 'empty';
|
||||
|
||||
$add_template = $copy_confirm = $copycat_confirm = false;
|
||||
|
||||
if (!$ressources) {
|
||||
dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
|
||||
}
|
||||
|
||||
if (!empty($_POST['filesource'])) {
|
||||
### Action ###
|
||||
|
||||
/**
|
||||
* Duplicate dc template
|
||||
*/
|
||||
if ('new' == $part && !empty($_POST['filesource'])) {
|
||||
try {
|
||||
$source = $_POST['filesource'];
|
||||
if (empty($_POST['filename']) && $source != 'category') {
|
||||
if ('category' == $_POST['filesource']) {
|
||||
$name = 'category-' . $_POST['filecat'] . '.html';
|
||||
} elseif (!empty($_POST['filename'])) {
|
||||
$name = files::tidyFileName($_POST['filename']) . '.html';
|
||||
} else {
|
||||
throw new Exception(__('Filename is empty.'));
|
||||
}
|
||||
$name = files::tidyFileName($_POST['filename']) . '.html';
|
||||
if ($source == 'category') {
|
||||
$name = 'category-' . $_POST['filecat'] . '.html';
|
||||
}
|
||||
dcCore::app()->templator->initializeTpl($name, $source);
|
||||
dcCore::app()->templator->initializeTpl($name, $_POST['filesource']);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The new template has been successfully created.'));
|
||||
|
@ -111,152 +89,222 @@ if (!empty($_POST['filesource'])) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['rmyes']) && !empty($_POST['remove'])) {
|
||||
/**
|
||||
* Copy tempaltor template
|
||||
*/
|
||||
if ('copy' == $part && !empty($_POST['filename'])) {
|
||||
try {
|
||||
$file = rawurldecode($_POST['remove']);
|
||||
dcCore::app()->templator->copypasteTpl(
|
||||
rawurldecode($_POST['filename']) . '.html',
|
||||
rawurldecode($_POST['file'])
|
||||
);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator', ['part' => 'files']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy templator category template
|
||||
*/
|
||||
if ('copycat' == $part && !empty($_POST['filecat'])) {
|
||||
try {
|
||||
dcCore::app()->templator->copypasteTpl(
|
||||
'category-' . rawurldecode($_POST['filecat']) . '.html',
|
||||
rawurldecode($_POST['file'])
|
||||
);
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator', ['part' => 'files']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete tempaltor template
|
||||
*/
|
||||
if ('delete' == $part && !empty($_POST['file'])) {
|
||||
try {
|
||||
$file = rawurldecode($_POST['file']);
|
||||
$media->removeItem($file);
|
||||
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');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator', ['part' => 'files']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['cpyes']) && !empty($_POST['copy']) && !empty($_POST['newfile'])) {
|
||||
try {
|
||||
$file = rawurldecode($_POST['copy']);
|
||||
$newfile = rawurldecode($_POST['newfile']) . '.html';
|
||||
dcCore::app()->templator->copypasteTpl($newfile, $file);
|
||||
### Display ###
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.'));
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['cpyes']) && !empty($_POST['copycat']) && !empty($_POST['copcat'])) {
|
||||
try {
|
||||
$file = rawurldecode($_POST['copycat']);
|
||||
$newfile = 'category-' . rawurldecode($_POST['copcat']) . '.html';
|
||||
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) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['remove'])) {
|
||||
$remove_confirm = true;
|
||||
}
|
||||
if (!empty($_GET['copy'])) {
|
||||
$copy_confirm = true;
|
||||
}
|
||||
if (!empty($_GET['copycat'])) {
|
||||
$copycat_confirm = true;
|
||||
}
|
||||
/**
|
||||
* Check
|
||||
*/
|
||||
|
||||
if (!dcCore::app()->templator->canUseRessources(true)) {
|
||||
dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
|
||||
echo
|
||||
'<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') => '',
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('New template') => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
if ($remove_confirm) {
|
||||
/**
|
||||
* Duplicate dotclear template
|
||||
*/
|
||||
} elseif ('new' == $part) {
|
||||
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><input type="submit" class="delete" value="' . __('Cancel') . '" /> ' .
|
||||
' <input type="submit" name="rmyes" value="' . __('Yes') . '" />' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden('remove', html::escapeHTML($_GET['remove'])) . '</p>' .
|
||||
'</form>';
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('New template') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'new']) . '" method="post" id="add-template">' .
|
||||
'<h3>' . __('New template') . '</h3>' .
|
||||
'<p><label for="filesource" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Template source:') . '</label> ' .
|
||||
form::combo('filesource', $combo_source) . '</p>' .
|
||||
'<p><label for="filename" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Filename:') . '</label> ' .
|
||||
form::field('filename', 25, 255) . '</p>' .
|
||||
'<p class="form-note">' . __('Extension .html is automatically added to filename.') . '</p>';
|
||||
|
||||
if ($has_categories) {
|
||||
echo
|
||||
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr>' . __('Category:') .'</label> ' .
|
||||
form::combo('filecat', $categories_combo, '') . '</p>' .
|
||||
'<p class="form-note">' . __('Required only for category template.') . '</p>';
|
||||
}
|
||||
|
||||
if ($copy_confirm) {
|
||||
echo
|
||||
'<form action="' . $p_url . '" method="post">' .
|
||||
'<p>' . sprintf(
|
||||
'<p>' .
|
||||
dcCore::app()->formNonce() .
|
||||
'<input type="submit" value="' . __('Create') . '" /></p>' .
|
||||
'</form>';
|
||||
|
||||
/**
|
||||
* Copy templator template
|
||||
*/
|
||||
} elseif ('copy' == $part && !empty($_REQUEST['file'])) {
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Copy available template') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'copy']) . '" method="post">' .
|
||||
'<h3>' . __('Copy available template') . '</h3>' .
|
||||
'<p><label for="filename" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New filename:') . '</label> ' .
|
||||
form::field('filename', 25, 255) . '<code>' . html::escapeHTML('.html') . '</code></p> ' .
|
||||
'<p class="form-note">' . sprintf(
|
||||
__('To copy the template <strong>%s</strong>, you need to fill a new filename.'),
|
||||
html::escapeHTML($_GET['copy'])
|
||||
html::escapeHTML($_REQUEST['file'])
|
||||
) . '</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') . '" />' .
|
||||
'<p>' .
|
||||
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden('copy', html::escapeHTML($_GET['copy'])) . '</p>' .
|
||||
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
|
||||
if ($copycat_confirm) {
|
||||
$category_id = str_replace('category-', '', $_GET['copycat']);
|
||||
$category_id = str_replace('.html', '', $category_id);
|
||||
/**
|
||||
* Copy templator category template
|
||||
*/
|
||||
} elseif ('copycat' == $part && !empty($_REQUEST['file'])) {
|
||||
$category_id = str_replace(['category-','.html'], '', $_REQUEST['file']);
|
||||
$cat_parents = dcCore::app()->blog->getCategoryParents($category_id);
|
||||
$full_name = '';
|
||||
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(
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Copy available template') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'copycat']) . '" method="post">' .
|
||||
'<h3>' . __('Copy available template') . '</h3>' .
|
||||
'<p><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Target category:') . '</label> ' .
|
||||
form::combo('filecat', $categories_combo, '') . '</p>' .
|
||||
'<p class="form-note">' . sprintf(
|
||||
__('To copy the template <strong>%s</strong> (%s), you need to choose a category.'),
|
||||
html::escapeHTML($_GET['copycat']),
|
||||
html::escapeHTML($_GET['file']),
|
||||
$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') . '" />' .
|
||||
$dcCore::app()->formNonce() .
|
||||
form::hidden('copycat', html::escapeHTML($_GET['copycat'])) .
|
||||
'</form>';
|
||||
}
|
||||
|
||||
if (!$add_template) {
|
||||
echo '<p class="top-add"><a class="button add" id="templator-control" href="#">' .
|
||||
__('New template') . '</a></p>';
|
||||
}
|
||||
|
||||
echo
|
||||
'<form action="' . $p_url . '" method="post" id="add-template">' .
|
||||
'<h3>' . __('New template') . '</h3>' .
|
||||
'<p class="field"><label for="filesource" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Template source:') . ' ' .
|
||||
form::combo('filesource', $combo_source) . '</label></p>' .
|
||||
'<p class="field two-cols"><label for="filename" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Filename:') . ' ' .
|
||||
form::field('filename', 25, 255) . '</label></p></br />
|
||||
<p class="form-note warn">' . __('Extension <strong><code>.html</code></strong> is automatically added to filename') . '</p>
|
||||
';
|
||||
|
||||
if ($hasCategories) {
|
||||
echo '<p class="field"><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr>' . __('Category:') .
|
||||
form::combo('filecat', $categories_combo, '') . '</label></p>';
|
||||
}
|
||||
|
||||
echo
|
||||
'<p>' . form::hidden(['p'], 'templator') .
|
||||
'<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
|
||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||
dcCore::app()->formNonce() .
|
||||
'<input type="submit" name="add_message" value="' . __('Create') . '" /></p>' .
|
||||
form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
|
||||
'</form>';
|
||||
|
||||
/**
|
||||
* Delete templator template
|
||||
*/
|
||||
} elseif ('delete' == $part && !empty($_REQUEST['file'])) {
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Delete available template') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'delete']) . '" method="post">' .
|
||||
'<h3>' . __('Delete available template') . '</h3>' .
|
||||
'<p>' . sprintf(
|
||||
__('Are you sure you want to remove the template "%s"?'),
|
||||
html::escapeHTML($_GET['file'])
|
||||
) . '</p>' .
|
||||
'<p><input type="submit" class="delete" value="' . __('Delete') . '" /> ' .
|
||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden('file', html::escapeHTML($_GET['file'])) . '</p>' .
|
||||
'</form>';
|
||||
|
||||
/**
|
||||
* List templator templates
|
||||
*/
|
||||
} elseif ('files' == $part) {
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Available templates') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
'<h3>' . __('Available templates') . '</h3>';
|
||||
|
||||
if (count($items) == 0) {
|
||||
echo '<p><strong>' . __('No template.') . '</strong></p>';
|
||||
} else {
|
||||
|
@ -280,15 +328,296 @@ if (count($items) == 0) {
|
|||
'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* List Used templator template
|
||||
*/
|
||||
} elseif ('used' == $part) {
|
||||
$tags = dcCore::app()->meta->getMetadata(['meta_type' => 'template']);
|
||||
$tags = dcCore::app()->meta->computeMetaStats($tags);
|
||||
$tags->sort('meta_id_lower', 'asc');
|
||||
|
||||
$last_letter = null;
|
||||
$cols = ['',''];
|
||||
$col = 0;
|
||||
|
||||
while ($tags->fetch()) {
|
||||
$letter = mb_strtoupper(mb_substr($tags->meta_id, 0, 1));
|
||||
|
||||
if ($last_letter != $letter) {
|
||||
if ($tags->index() >= round($tags->count() / 2)) {
|
||||
$col = 1;
|
||||
}
|
||||
$cols[$col] .= '<tr class="tagLetter"><td colspan="2"><span>' . $letter . '</span></td></tr>';
|
||||
}
|
||||
|
||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||
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">' .
|
||||
'<td class="maximal"><a href="' .
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', [
|
||||
'part' => 'posts',
|
||||
'file' => $tags->meta_id,
|
||||
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']),
|
||||
]) .'">' . $tags->meta_id . '</a> ' . $img_status . '</td>' .
|
||||
'<td class="nowrap"><strong>' . $tags->count . '</strong> ' .
|
||||
(($tags->count == 1) ? __('entry') : __('entries')) . '</td>' .
|
||||
'</tr>';
|
||||
|
||||
$last_letter = $letter;
|
||||
}
|
||||
|
||||
$table = '<div class="col"><table class="tags">%s</table></div>';
|
||||
|
||||
echo
|
||||
'<p class="clear">
|
||||
<a class="button"
|
||||
href="' . $p_url . '&database=on"
|
||||
title="' . __('Display templates used for entries in base') . '"
|
||||
>' .
|
||||
__('Display templates used for entries in base') . '
|
||||
</a>
|
||||
</p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Used templates') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
'<h3>' . __('Used templates') . '</h3>';
|
||||
|
||||
if ($cols[0]) {
|
||||
echo '<div class="two-cols">';
|
||||
printf($table, $cols[0]);
|
||||
if ($cols[1]) {
|
||||
printf($table, $cols[1]);
|
||||
}
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<p>' . __('No specific templates on this blog.') . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit emplator template
|
||||
*/
|
||||
} elseif ('edit' == $part && !empty($_REQUEST['file'])) {
|
||||
try {
|
||||
try {
|
||||
$name = rawurldecode($_REQUEST['file']);
|
||||
$file = dcCore::app()->templator->getSourceContent($name);
|
||||
$name = $file['f'];
|
||||
|
||||
if (preg_match('/^category-(.+).html$/', $name, $cat_id)) {
|
||||
$category = dcCore::app()->blog->getCategory($cat_id[1]);
|
||||
$full_name = '';
|
||||
$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) {
|
||||
$file = $file_default;
|
||||
|
||||
throw $e;
|
||||
}
|
||||
# Write file
|
||||
if (!empty($_POST['write'])) {
|
||||
$file['c'] = $_POST['file_content'];
|
||||
dcCore::app()->templator->writeTpl($file['f'], $file['c']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>';
|
||||
|
||||
if (dcCore::app()->auth->user_prefs->interface->colorsyntax) {
|
||||
echo
|
||||
dcPage::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->interface->colorsyntax]);
|
||||
}
|
||||
echo
|
||||
dcPage::jsJson('theme_editor_msg', [
|
||||
'saving_document' => __('Saving document...'),
|
||||
'document_saved' => __('Document saved'),
|
||||
'error_occurred' => __('An error occurred:'),
|
||||
'confirm_reset_file' => __('Are you sure you want to reset this file?'),
|
||||
]) .
|
||||
dcPage::jsModuleLoad('themeEditor/js/script.js') .
|
||||
dcPage::jsConfirmClose('file-form');
|
||||
if (dcCore::app()->auth->user_prefs->interface->colorsyntax) {
|
||||
echo
|
||||
dcPage::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->interface->colorsyntax_theme);
|
||||
}
|
||||
echo
|
||||
dcPage::cssModuleLoad('themeEditor/style.css') .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Edit template') => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
if (($file['c'] !== null)) {
|
||||
echo
|
||||
'<form id="file-form" action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'edit', 'file' => $name]) . '" method="post">' .
|
||||
'<div><h3><label for="file_content">' . sprintf(__('Editing file %s'), '<strong>' . $name) . '</strong></label></h3>' .
|
||||
'<p>' . form::textarea('file_content', 72, 25, [
|
||||
'default' => html::escapeHTML($file['c']),
|
||||
'class' => 'maximal',
|
||||
'disabled' => !$file['w'],
|
||||
]) . '</p>';
|
||||
|
||||
if ($file['w']) {
|
||||
echo
|
||||
'<p><input type="submit" name="write" value="' . __('Save') . '" accesskey="s" /> ' .
|
||||
'<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['file_id'], html::escapeHTML($file['f'])) .
|
||||
'</p>';
|
||||
} else {
|
||||
echo '<p>' . __('This file is not writable. Please check your files permissions.') . '</p>';
|
||||
}
|
||||
|
||||
echo
|
||||
'</div></form>';
|
||||
if (dcCore::app()->auth->user_prefs->interface->colorsyntax) {
|
||||
echo
|
||||
dcPage::jsJson('theme_editor_mode', ['mode' => 'html']) .
|
||||
dcPage::jsModuleLoad('themeEditor/js/mode.js') .
|
||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', dcCore::app()->auth->user_prefs->interface->colorsyntax_theme);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit posts options linked to a template
|
||||
*/
|
||||
} elseif ('posts' == $part && (!empty($_REQUEST['file']) || $_REQUEST['file'] == '0')) {
|
||||
$file = $_REQUEST['file'];
|
||||
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']);
|
||||
|
||||
# Unselect the template
|
||||
if (!empty($_POST['action']) && 'unselecttpl' == $_POST['action'] && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_PUBLISH,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id)) {
|
||||
try {
|
||||
dcCore::app()->meta->delMeta($file, 'template');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.templator', ['part' => 'posts', 'file' => $file]);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$filter = new adminGenericFilterV2('templator');
|
||||
$filter->add(dcAdminFilters::getPageFilter());
|
||||
$filter->add('part', 'posts');
|
||||
$filter->add('file', $file);
|
||||
$filter->add('post_type', '');
|
||||
|
||||
$params = $filter->params();
|
||||
$params['no_content'] = true;
|
||||
$params['meta_id'] = $file;
|
||||
$params['meta_type'] = 'template';
|
||||
|
||||
# Get posts
|
||||
try {
|
||||
$posts = dcCore::app()->meta->getPostsByMeta($params);
|
||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
||||
$post_list = new adminPostList($posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
dcPage::jsFilterControl($filter->show()) .
|
||||
dcPage::jsLoad(dcPage::getPF('templator/js/posts.js')) .
|
||||
$filter->js(dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'posts', 'file' => $file])) .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
|
||||
__('Unselect template') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<h3>' . __('Unselect template') . '</h3>' .
|
||||
'<p><a class ="back" href="' . $redir . '">' . __('Back') . '</a></p>';
|
||||
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
if ($posts->isEmpty() && !$filter->show()) {
|
||||
echo '<p>' . __('There is no entries') . '</p>';
|
||||
} else {
|
||||
$filter->display(
|
||||
'admin.plugin.templator',
|
||||
form::hidden('p', 'templator') . form::hidden('part', 'posts') . form::hidden('file', $file)
|
||||
);
|
||||
# Show posts
|
||||
$post_list->display(
|
||||
$filter->page,
|
||||
$filter->nb,
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator') . '" method="post" id="form-entries">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
|
||||
'<p class="col right">' .
|
||||
'<input type="submit" value="' . __('Unselect template for selcted entries') . '" /></p>' .
|
||||
form::hidden('action', 'unselecttpl') .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.templator', $filter->values()) .
|
||||
form::hidden('redir', $redir) .
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>',
|
||||
$filter->show(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', $filter->values())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default page
|
||||
*/
|
||||
} else {
|
||||
echo
|
||||
'<html><head><title>' . __('Templator') . '</title>' .
|
||||
'</head><body>' .
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Templates engine') => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
$line = '<li><a href="%s">%s</a></li>';
|
||||
echo '
|
||||
<h4><i>' . __('Manage additional templates') . '</i></h4>' .
|
||||
sprintf(
|
||||
'<h3><ul class="nice">%s</ul></h3>',
|
||||
sprintf(
|
||||
$line,
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']),
|
||||
__('Available templates')
|
||||
) .
|
||||
sprintf(
|
||||
$line,
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'used']),
|
||||
__('Used templates')
|
||||
) .
|
||||
sprintf(
|
||||
$line,
|
||||
dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'new']),
|
||||
__('New template')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
dcPage::helpBlock('templator');
|
||||
|
||||
echo '</body></html>';
|
14
js/form.js
14
js/form.js
|
@ -1,14 +0,0 @@
|
|||
$(function() {
|
||||
var t = $('#templator-control');
|
||||
t.css('display','inline');
|
||||
$('#add-template').hide();
|
||||
t.click(function() {
|
||||
$('#add-template').show();
|
||||
$(this).hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
10
js/posts.js
Normal file
10
js/posts.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*global $, dotclear */
|
||||
'use strict';
|
||||
|
||||
$(function () {
|
||||
$('.checkboxes-helpers').each(function () {
|
||||
dotclear.checkboxesHelpers(this, undefined, '#form-entries td input[type=checkbox]', '#form-entries #do-action');
|
||||
});
|
||||
$('#form-entries td input[type=checkbox]').enableShiftClick();
|
||||
dotclear.condSubmit('#form-entries td input[type=checkbox]', '#form-entries #do-action');
|
||||
});
|
15
js/script.js
15
js/script.js
|
@ -1,15 +0,0 @@
|
|||
$(function(){var msg=false;$('#file-form input[name="write"]').click(function(){var f=this.form;var data={file_content:$(f).find('#file_content').get(0).value,xd_check:$(f).find('input[name="xd_check"]').get(0).value,write:1};if(msg==false){msg=$('<p style="font-weight:bold; color:red;"></p>');$('#file_content').parent().after(msg);}
|
||||
msg.text(dotclear.msg.saving_document);$.post(document.location.href,data,function(res,status){var err=$(res).find('div.error li:first');if(err.length>0){msg.text(dotclear.msg.error_occurred+' '+err.text());return;}else{msg.text(dotclear.msg.document_saved);$('#file-chooser').empty();$(res).find('#file-chooser').children().appendTo('#file-chooser');}});return false;});
|
||||
$("#filecat").parent().parent().hide();
|
||||
$("#filesource").change(function() {
|
||||
var f = $(this).val();
|
||||
if (f == 'category') {
|
||||
$("#filename, #filetitle").parent().parent().hide();
|
||||
$("#filecat").parent().parent().show();
|
||||
}
|
||||
else {
|
||||
$("#filename, #filetitle").parent().parent().show();
|
||||
$("#filecat").parent().parent().hide();
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,147 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
$template = (!empty($_REQUEST['template']) || $_REQUEST['template'] == '0') ? $_REQUEST['template'] : '';
|
||||
|
||||
$this_url = $p_url . '&m=template_posts&template=' . rawurlencode($template);
|
||||
|
||||
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
|
||||
$nb_per_page = 30;
|
||||
|
||||
# Unselect the template
|
||||
if (!empty($_POST['initialise']) && dcCore::app()->auth->check('publish,contentadmin', dcCore::app()->blog->id)) {
|
||||
try {
|
||||
dcCore::app()->meta->delMeta($template, 'template');
|
||||
http::redirect($p_url . '&del=' . $template);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$params = [];
|
||||
$params['limit'] = [(($page - 1) * $nb_per_page),$nb_per_page];
|
||||
$params['no_content'] = true;
|
||||
|
||||
$params['meta_id'] = $template;
|
||||
$params['meta_type'] = 'template';
|
||||
$params['post_type'] = '';
|
||||
|
||||
# Get posts
|
||||
try {
|
||||
$posts = dcCore::app()->meta->getPostsByMeta($params);
|
||||
$counter = dcCore::app()->meta->getPostsByMeta($params, true);
|
||||
$post_list = new adminPostList($posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
# Actions combo box
|
||||
$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',
|
||||
];
|
||||
}
|
||||
$combo_action[__('Mark')] = [
|
||||
__('Mark as selected') => 'selected',
|
||||
__('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']
|
||||
);
|
||||
}
|
||||
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
|
||||
dcCore::app()->callBehavior('adminPostsActionsCombo', [&$combo_action]);
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo __('Templator'); ?></title>
|
||||
<script type="text/javascript" src="js/_posts_list.js"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
dotclear.msg.confirm_template_unselect = '<?php echo html::escapeJS(__('Are you sure you want to unselect the template?')) ?>';
|
||||
$(function() {
|
||||
$('#template_change').submit(function() {
|
||||
return window.confirm(dotclear.msg.confirm_template_unselect);
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<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 (!dcCore::app()->error->flag()) {
|
||||
# Show posts
|
||||
$post_list->display(
|
||||
$page,
|
||||
$nb_per_page,
|
||||
'<form action="posts_actions.php" method="post" id="form-entries">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
|
||||
'<p class="col right">' . __('Selected entries action:') . ' ' .
|
||||
form::combo('action', $combo_action) .
|
||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||
form::hidden('post_type', '') .
|
||||
form::hidden('redir', $p_url . '&m=template_posts&tag=' .
|
||||
str_replace('%', '%%', rawurlencode($template)) . '&page=' . $page) .
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
|
||||
# Remove tag
|
||||
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') . '" />' .
|
||||
dcCore::app()->formNonce() . '</p>' .
|
||||
'</form>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue