refresh admin, group index (WIP)

This commit is contained in:
Jean-Christian Paul Denis 2022-12-07 01:07:56 +01:00
parent a051f78816
commit 57fee61b96
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 598 additions and 558 deletions

View File

@ -7,7 +7,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcCore::app()->auth->setPermissionType(initTemplator::PERMISSION_TEMPLATOR, __('manage templates')); dcCore::app()->auth->setPermissionType(initTemplator::PERMISSION_TEMPLATOR, __('manage templates'));
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Templates'), __('Templates engine'),
dcCore::app()->adminurl->get('admin.plugin.templator'), dcCore::app()->adminurl->get('admin.plugin.templator'),
urldecode(dcPage::getPF('templator/icon.png')), urldecode(dcPage::getPF('templator/icon.png')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.templator')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), 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('adminPostsActions', ['templatorBehaviors','adminPostsActions']);
dcCore::app()->addBehavior('adminPagesActions', ['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 class templatorBehaviors

View File

@ -5,6 +5,7 @@ if (!defined('DC_RC_PATH')) {
} }
Clearbricks::lib()->autoload([ Clearbricks::lib()->autoload([
'dcTemplator' => __DIR__ . '/inc/class.templator.php', 'dcTemplator' => __DIR__ . '/inc/class.templator.php',
'templatorMedia' => __DIR__ . '/inc/class.templator.media.php',
'pagerTemplator' => __DIR__ . '/inc/admin.pager.templator.php', 'pagerTemplator' => __DIR__ . '/inc/admin.pager.templator.php',
]); ]);

View File

@ -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 .
'&amp;m=template_posts&amp;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>';

View File

@ -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 . ' &rsaquo; ';
};
$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) . ' &rsaquo; <a href="' . $p_url . '">' . __('Supplementary templates') . '</a> &rsaquo; <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 . '&amp;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>

View File

@ -23,12 +23,12 @@ class pagerTemplator
$count = ''; $count = '';
$params = []; $params = [];
$link = 'media_item.php?id=' . $f->media_id; $link = 'media_item.php?id=' . $f->media_id;
$link_edit = $p_url . '&amp;edit=' . $fname; $link_edit = dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'edit', 'file' => $f->basename]);
$icon = dcPage::getPF('templator/img/template.png'); $icon = dcPage::getPF('templator/img/template.png');
$class = 'media-item media-col-' . ($i % 2); $class = 'media-item media-col-' . ($i % 2);
$details = $special = ''; $details = $special = '';
$widget_icon = '<span class="widget" title="' . __('Template widget') . '">&diams;</span>'; $widget_icon = '<span class="widget" title="' . __('Template widget') . '">&diams;</span>';
$copy_url = '&amp;copy='; $part = 'copy';
if (preg_match('/^category-(.+)$/', $f->basename)) { if (preg_match('/^category-(.+)$/', $f->basename)) {
// That is ugly. // That is ugly.
@ -43,7 +43,7 @@ class pagerTemplator
$params['cat_id'] = $cat_id; $params['cat_id'] = $cat_id;
$params['post_type'] = ''; $params['post_type'] = '';
$icon = dcPage::getPF('templator/img/template-alt.png'); $icon = dcPage::getPF('templator/img/template-alt.png');
$copy_url = '&amp;copycat='; $part = 'copycat';;
try { try {
$counter = dcCore::app()->blog->getPosts($params, true); $counter = dcCore::app()->blog->getPosts($params, true);
@ -72,12 +72,17 @@ class pagerTemplator
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
$url = dcCore::app()->adminurl->get('admin.plugin.templator', [
'part' => 'posts',
'file' => $fname,
'redir' => dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']),
]);
if ($counter->f(0) == 0) { if ($counter->f(0) == 0) {
$count = '&nbsp;'; $count = __('No entry');
} elseif ($counter->f(0) == 1) { } elseif ($counter->f(0) == 1) {
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $p_url . '&amp;m=template_posts&amp;template=' . $fname . '">' . __('entry') . '</a>'; $count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $url . '">' . __('entry') . '</a>';
} else { } else {
$count = '<strong>' . $counter->f(0) . '</strong> <a href="' . $p_url . '&amp;m=template_posts&amp;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>' . '<img src="' . $icon . '" alt="" /></a>' .
'<ul>' . '<ul>' .
'<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>'; '<li><a class="media-link" href="' . $link_edit . '">' . $fname . '</a> ' . $special . '</li>';
/*
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN, dcAuth::PERMISSION_CONTENT_ADMIN,
initTemplator::PERMISSION_TEMPLATOR, initTemplator::PERMISSION_TEMPLATOR,
]), dcCore::app()->blog->id)) { ]), dcCore::app()->blog->id)) {
$details = ' - <a href="' . $link . '">' . __('details') . '</a>'; $details = ' - <a href="' . $link . '">' . __('details') . '</a>';
} }
*/
if (!$f->d) { if (!$f->d) {
$res .= '<li>' . $count . '</li>' . $res .= '<li>' . $count . '</li>' .
'<li>' . '<li>' .
@ -104,13 +109,13 @@ class pagerTemplator
$res .= '<li class="media-action">&nbsp;'; $res .= '<li class="media-action">&nbsp;';
$res .= '<a class="media-remove" ' . $res .= '<a class="media-remove" href="' .
'href="' . $p_url . $copy_url . rawurlencode($f->basename) . '">' . 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>&nbsp;'; '<img src="' . dcPage::getPF('templator/img/copy.png') . '" alt="' . __('copy') . '" title="' . __('copy the template') . '" /></a>&nbsp;';
if ($f->del) { if ($f->del) {
$res .= '<a class="media-remove" ' . $res .= '<a class="media-remove" href="' .
'href="' . $p_url . '&amp;remove=' . rawurlencode($f->basename) . '">' . 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>'; '<img src="' . dcPage::getPF('templator/img/delete.png') . '" alt="' . __('delete') . '" title="' . __('delete the template') . '" /></a>';
} }

View 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);
}
}

763
index.php
View File

@ -8,99 +8,77 @@ dcPage::check(dcCore::app()->auth->makePermissions([
initTemplator::PERMISSION_TEMPLATOR, initTemplator::PERMISSION_TEMPLATOR,
])); ]));
$p_url = dcCore::app()->admin->getPageURL(); $part = $_REQUEST['part'] ?? '';
if ((!empty($_REQUEST['m'])) && ($_REQUEST['m'] = 'template_posts')) { ### grab info ###
require dirname(__FILE__) . '/' . $_REQUEST['m'] . '.php';
return; if (in_array($part, ['files', 'delete'])) {
} $page = !empty($_GET['page']) ? $_GET['page'] : 1;
if (!empty($_REQUEST['edit'])) { $nb_per_page = 20;
require dirname(__FILE__) . '/edit.php';
return; $media = new templatorMedia();
} $media->chdir(dcCore::app()->templator->template_dir_name);
if (!empty($_REQUEST['database']) && $_REQUEST['database'] = 'on') { // For users with only templator permission, we use sudo.
require dirname(__FILE__) . '/advanced.php'; dcCore::app()->auth->sudo([$media,'getDir']);
$dir = $media->dir;
return; //if files did not appear in this list, check blog->settings->media_exclusion
$items = array_values($dir['files']);
} }
$file_default = $file = ['c' => null, 'w' => false, 'type' => null, 'f' => null, 'default_file' => false]; if (in_array($part, ['new', 'copycat'])) {
$page = !empty($_GET['page']) ? $_GET['page'] : 1; $has_categories = false;
$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->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;
//if files did not appear in this list, check blog->settings->media_exclusion
$items = array_values($dir['files']);
// Categories
try {
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
$categories_combo = [];
$l = $categories->level;
$full_name = [$categories->cat_title];
while ($categories->fetch()) {
if ($categories->level < $l) {
$full_name = [];
} elseif ($categories->level == $l) {
array_pop($full_name);
}
$full_name[] = html::escapeHTML($categories->cat_title);
$categories_combo[implode(' &rsaquo; ', $full_name)] = $categories->cat_id;
$l = $categories->level;
}
} catch (Exception $e) {
}
$hasCategories = ($categories->isEmpty()) ? false : true;
$combo_source = [
'post.html' => 'post',
];
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';
}
if (!$categories->isEmpty()) {
$combo_source['category.html'] = 'category';
}
$combo_source[' &mdash; '] = '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'])) {
try { try {
$source = $_POST['filesource']; $categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
if (empty($_POST['filename']) && $source != 'category') {
$categories_combo = [];
$l = $categories->level;
$full_name = [$categories->cat_title];
while ($categories->fetch()) {
if ($categories->level < $l) {
$full_name = [];
} elseif ($categories->level == $l) {
array_pop($full_name);
}
$full_name[] = html::escapeHTML($categories->cat_title);
$categories_combo[implode(' &rsaquo; ', $full_name)] = $categories->cat_id;
$l = $categories->level;
}
$has_categories = !$categories->isEmpty();
} catch (Exception $e) {
}
$combo_source = [
' &mdash; ' => 'empty',
'post.html' => 'post',
];
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';
}
if ($has_categories) {
$combo_source['category.html'] = 'category';
}
}
### Action ###
/**
* Duplicate dc template
*/
if ('new' == $part && !empty($_POST['filesource'])) {
try {
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.')); throw new Exception(__('Filename is empty.'));
} }
$name = files::tidyFileName($_POST['filename']) . '.html'; dcCore::app()->templator->initializeTpl($name, $_POST['filesource']);
if ($source == 'category') {
$name = 'category-' . $_POST['filecat'] . '.html';
}
dcCore::app()->templator->initializeTpl($name, $source);
if (!dcCore::app()->error->flag()) { if (!dcCore::app()->error->flag()) {
dcAdminNotices::addSuccessNotice(__('The new template has been successfully created.')); dcAdminNotices::addSuccessNotice(__('The new template has been successfully created.'));
@ -111,184 +89,535 @@ if (!empty($_POST['filesource'])) {
} }
} }
if (!empty($_POST['rmyes']) && !empty($_POST['remove'])) { /**
* Copy tempaltor template
*/
if ('copy' == $part && !empty($_POST['filename'])) {
try { 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); $media->removeItem($file);
dcCore::app()->meta->delMeta($file, 'template'); dcCore::app()->meta->delMeta($file, 'template');
if (!dcCore::app()->error->flag()) { if (!dcCore::app()->error->flag()) {
dcAdminNotices::addSuccessNotice(__('The template has been successfully removed.')); 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) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
} }
if (!empty($_POST['cpyes']) && !empty($_POST['copy']) && !empty($_POST['newfile'])) { ### Display ###
try {
$file = rawurldecode($_POST['copy']);
$newfile = rawurldecode($_POST['newfile']) . '.html';
dcCore::app()->templator->copypasteTpl($newfile, $file);
if (!dcCore::app()->error->flag()) { /**
dcAdminNotices::addSuccessNotice(__('The template has been successfully copied.')); * Check
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'])) { if (!dcCore::app()->templator->canUseRessources(true)) {
try { dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
$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;
}
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') => '',
]) .
dcPage::notices();
if ($remove_confirm) {
echo echo
'<form action="' . $p_url . '" method="post">' . '<html><head><title>' . __('Templator') . '</title>' .
'<p>' . sprintf( '</head><body>' .
__('Are you sure you want to remove the template "%s"?'), dcPage::breadcrumb([
html::escapeHTML($_GET['remove']) __('Plugins') => '',
) . '</p>' . __('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
'<p><input type="submit" class="delete" value="' . __('Cancel') . '" /> ' . __('New template') => '',
' &nbsp; <input type="submit" name="rmyes" value="' . __('Yes') . '" />' . ]) .
dcPage::notices();
/**
* Duplicate dotclear template
*/
} elseif ('new' == $part) {
echo
'<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>';
}
echo
'<p>' .
dcCore::app()->formNonce() . dcCore::app()->formNonce() .
form::hidden('remove', html::escapeHTML($_GET['remove'])) . '</p>' . '<input type="submit" value="' . __('Create') . '" /></p>' .
'</form>'; '</form>';
}
if ($copy_confirm) { /**
* Copy templator template
*/
} elseif ('copy' == $part && !empty($_REQUEST['file'])) {
echo echo
'<form action="' . $p_url . '" method="post">' . '<html><head><title>' . __('Templator') . '</title>' .
'<p>' . sprintf( '</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.'), __('To copy the template <strong>%s</strong>, you need to fill a new filename.'),
html::escapeHTML($_GET['copy']) html::escapeHTML($_REQUEST['file'])
) . '</p>' . ) . '</p>' .
'<p><label for="filename" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New filename:') . ' ' . '<p>' .
form::field('newfile', 25, 255) . '</label><code>' . html::escapeHTML('.html') . '</code>&nbsp; ' . '<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
'<input type="submit" name="cpyes" value="' . __('Copy') . '" /> &nbsp;<input class="delete" type="submit" value="' . __('Cancel') . '" />' . '<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
dcCore::app()->formNonce() . dcCore::app()->formNonce() .
form::hidden('copy', html::escapeHTML($_GET['copy'])) . '</p>' . form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
'</form>'; '</form>';
}
if ($copycat_confirm) { /**
$category_id = str_replace('category-', '', $_GET['copycat']); * Copy templator category template
$category_id = str_replace('.html', '', $category_id); */
} elseif ('copycat' == $part && !empty($_REQUEST['file'])) {
$category_id = str_replace(['category-','.html'], '', $_REQUEST['file']);
$cat_parents = dcCore::app()->blog->getCategoryParents($category_id); $cat_parents = dcCore::app()->blog->getCategoryParents($category_id);
$full_name = ''; $full_name = '';
while ($cat_parents->fetch()) { while ($cat_parents->fetch()) {
$full_name = $cat_parents->cat_title . ' &rsaquo; '; $full_name = $cat_parents->cat_title . ' &rsaquo; ';
}; };
$name = $full_name . dcCore::app()->blog->getCategory($category_id)->cat_title; $name = $full_name . dcCore::app()->blog->getCategory($category_id)->cat_title;
echo echo
'<form action="' . $p_url . '" method="post">' . '<html><head><title>' . __('Templator') . '</title>' .
'<p>' . sprintf( '</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.'), __('To copy the template <strong>%s</strong> (%s), you need to choose a category.'),
html::escapeHTML($_GET['copycat']), html::escapeHTML($_GET['file']),
$name $name
) . '</p>' . ) . '</p>' .
'<p class="field"><label for="copcat" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Target category:') . '<input type="submit" name="submit" value="' . __('Copy') . '" /> ' .
form::combo('copcat', $categories_combo, '') . '</label></p>' . '<a class="button" href="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'files']) . '">' . __('Cancel') . '</a>' .
'<input type="submit" name="cpyes" value="' . __('Copy') . '" /> &nbsp;<input class="delete" type="submit" value="' . __('Cancel') . '" />' . dcCore::app()->formNonce() .
$dcCore::app()->formNonce() . form::hidden('file', html::escapeHTML($_REQUEST['file'])) . '</p>' .
form::hidden('copycat', html::escapeHTML($_GET['copycat'])) .
'</form>'; '</form>';
}
if (!$add_template) { /**
echo '<p class="top-add"><a class="button add" id="templator-control" href="#">' . * Delete templator template
__('New template') . '</a></p>'; */
} } 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() .
echo '<form action="' . dcCore::app()->adminurl->get('admin.plugin.templator', ['part' => 'delete']) . '" method="post">' .
'<form action="' . $p_url . '" method="post" id="add-template">' . '<h3>' . __('Delete available template') . '</h3>' .
'<h3>' . __('New template') . '</h3>' . '<p>' . sprintf(
'<p class="field"><label for="filesource" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Template source:') . ' ' . __('Are you sure you want to remove the template "%s"?'),
form::combo('filesource', $combo_source) . '</label></p>' . html::escapeHTML($_GET['file'])
'<p class="field two-cols"><label for="filename" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Filename:') . ' ' . ) . '</p>' .
form::field('filename', 25, 255) . '</label></p></br /> '<p><input type="submit" class="delete" value="' . __('Delete') . '" /> ' .
<p class="form-note warn">' . __('Extension <strong><code>.html</code></strong> is automatically added to filename') . '</p> '<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>';
if ($hasCategories) { /**
echo '<p class="field"><label for="filecat" class="required"><abbr title="' . __('Required field') . '">*</abbr>' . __('Category:') . * List templator templates
form::combo('filecat', $categories_combo, '') . '</label></p>'; */
} } 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>';
echo if (count($items) == 0) {
'<p>' . form::hidden(['p'], 'templator') . echo '<p><strong>' . __('No template.') . '</strong></p>';
dcCore::app()->formNonce() . } else {
'<input type="submit" name="add_message" value="' . __('Create') . '" /></p>' . $pager = new pager($page, count($items), $nb_per_page, 10);
'</form>'; $pager->html_prev = __('&#171;prev.');
$pager->html_next = __('next&#187;');
if (count($items) == 0) { echo
echo '<p><strong>' . __('No template.') . '</strong></p>'; '<form action="media.php" method="get">' .
} else { '</form>' .
$pager = new pager($page, count($items), $nb_per_page, 10);
$pager->html_prev = __('&#171;prev.'); '<div class="media-list">' .
$pager->html_next = __('next&#187;'); '<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>';
for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) {
echo pagerTemplator::templatorItemLine($items[$i], $j);
}
echo
'<p class="clear">' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>' .
'</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 echo
'<form action="media.php" method="get">' . '<html><head><title>' . __('Templator') . '</title>' .
'</form>' . 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>';
'<div class="media-list">' . if ($cols[0]) {
'<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>'; 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>';
}
for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) { /**
echo pagerTemplator::templatorItemLine($items[$i], $j); * 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 . ' &rsaquo; ';
};
$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 echo
'<p class="clear">' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>' . '<html><head><title>' . __('Templator') . '</title>' .
'</div>'; 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')
)
);
} }
echo dcPage::helpBlock('templator');
'<p class="clear">
<a class="button" echo '</body></html>';
href="' . $p_url . '&amp;database=on"
title="' . __('Display templates used for entries in base') . '"
>' .
__('Display templates used for entries in base') . '
</a>
</p>';
?>
</body>
</html>

View File

@ -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
View 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');
});

View File

@ -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();
}
});
});

View File

@ -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 . '&amp;m=template_posts&amp;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); ?> &rsaquo;
<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 . '&amp;m=template_posts&amp;tag=' .
str_replace('%', '%%', rawurlencode($template)) . '&amp;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>