diff --git a/_admin.php b/_admin.php
index c0accfd..10e8ede 100644
--- a/_admin.php
+++ b/_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
diff --git a/_prepend.php b/_prepend.php
index a4500cb..e80a1a6 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -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',
]);
diff --git a/advanced.php b/advanced.php
deleted file mode 100644
index a80c49c..0000000
--- a/advanced.php
+++ /dev/null
@@ -1,71 +0,0 @@
-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] .= '
' . $letter . ' |
';
- }
-
- $img = '';
- 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] .= '' .
- '' . $tags->meta_id . ' ' . $img_status . ' | ' .
- '' . $tags->count . ' ' .
- (($tags->count == 1) ? __('entry') : __('entries')) . ' | ' .
- '
';
-
- $last_letter = $letter;
-}
-
-$table = '';
-
-echo
-'' . __('Templator') . '' .
-dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
-'' .
-dcPage::breadcrumb([
- html::escapeHTML(dcCore::app()->blog->name) => '',
- __('Additional templates') => '',
-]) .
-dcPage::notices() .
-'' . __('New template') . '
';
-
-if ($cols[0]) {
- echo '';
- printf($table, $cols[0]);
- if ($cols[1]) {
- printf($table, $cols[1]);
- }
- echo '
';
-} else {
- echo '' . __('No specific templates on this blog.') . '
';
-}
-
-dcPage::helpBlock('templator');
-
-echo '';
\ No newline at end of file
diff --git a/edit.php b/edit.php
deleted file mode 100644
index 6a984f4..0000000
--- a/edit.php
+++ /dev/null
@@ -1,81 +0,0 @@
-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 .= ' (' . $full_name . $category->cat_title . ')';
- }
- } 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::escapeHTML(dcCore::app()->blog->name) . ' › ' . __('Supplementary templates') . ' › ' . __('Edit the template') . '';
-
-if (($file['c'] !== null)) {
- echo
- '';
-}
-
-?>
-
-
\ No newline at end of file
diff --git a/inc/admin.pager.templator.php b/inc/admin.pager.templator.php
index 3be0836..8441c15 100644
--- a/inc/admin.pager.templator.php
+++ b/inc/admin.pager.templator.php
@@ -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 = '♦';
- $copy_url = '©=';
+ $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 = '©cat=';
+ $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 = '' . $counter->f(0) . ' ' . __('entry') . '';
+ $count = '' . $counter->f(0) . ' ' . __('entry') . '';
} else {
- $count = '' . $counter->f(0) . ' ' . __('entries') . '';
+ $count = '' . $counter->f(0) . ' ' . __('entries') . '';
}
}
@@ -85,14 +90,14 @@ class pagerTemplator
'' .
'' .
'- ' . $fname . ' ' . $special . '
';
-
+/*
if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
initTemplator::PERMISSION_TEMPLATOR,
]), dcCore::app()->blog->id)) {
$details = ' - ' . __('details') . '';
}
-
+*/
if (!$f->d) {
$res .= '- ' . $count . '
' .
'- ' .
@@ -104,13 +109,13 @@ class pagerTemplator
$res .= '
- ';
- $res .= 'basename) . '">' .
+ $res .= '' .
' ';
if ($f->del) {
- $res .= 'basename) . '">' .
+ $res .= '' .
'';
}
diff --git a/inc/class.templator.media.php b/inc/class.templator.media.php
new file mode 100644
index 0000000..0cdc2f9
--- /dev/null
+++ b/inc/class.templator.media.php
@@ -0,0 +1,10 @@
+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';
+if (in_array($part, ['files', 'delete'])) {
+ $page = !empty($_GET['page']) ? $_GET['page'] : 1;
+ $nb_per_page = 20;
- return;
-}
-if (!empty($_REQUEST['database']) && $_REQUEST['database'] = 'on') {
- require dirname(__FILE__) . '/advanced.php';
-
- return;
+ $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;
+ //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];
-$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->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(' › ', $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[' — '] = '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'])) {
+if (in_array($part, ['new', 'copycat'])) {
+ $has_categories = false;
try {
- $source = $_POST['filesource'];
- if (empty($_POST['filename']) && $source != 'category') {
+ $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(' › ', $full_name)] = $categories->cat_id;
+
+ $l = $categories->level;
+ }
+ $has_categories = !$categories->isEmpty();
+ } catch (Exception $e) {
+ }
+
+ $combo_source = [
+ ' — ' => '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.'));
}
- $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,184 +89,535 @@ 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());
- }
-}
+/**
+ * Check
+ */
-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;
-}
-
-echo
-'' . __('Templator') . '' .
-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')) .
-'' .
-dcPage::breadcrumb([
- html::escapeHTML(dcCore::app()->blog->name) => '',
- __('Additional templates') => '',
-]) .
-dcPage::notices();
-
-if ($remove_confirm) {
+if (!dcCore::app()->templator->canUseRessources(true)) {
+ dcCore::app()->error->add(__('The plugin is unusable with your configuration. You have to change file permissions.'));
echo
- '';
-}
-if ($copy_confirm) {
+/**
+ * Copy templator template
+ */
+} elseif ('copy' == $part && !empty($_REQUEST['file'])) {
echo
- '';
-}
-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
- '';
-}
-if (!$add_template) {
- echo '
' .
- __('New template') . '
';
-}
+/**
+ * Delete templator template
+ */
+} elseif ('delete' == $part && !empty($_REQUEST['file'])) {
+ echo
+ '' . __('Templator') . '' .
+ '' .
+ dcPage::breadcrumb([
+ __('Plugins') => '',
+ __('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
+ __('Delete available template') => '',
+ ]) .
+ dcPage::notices() .
-echo
-'';
-if ($hasCategories) {
- echo '';
-}
+/**
+ * List templator templates
+ */
+} elseif ('files' == $part) {
+ echo
+ '' . __('Templator') . '' .
+ '' .
+ dcPage::breadcrumb([
+ __('Plugins') => '',
+ __('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
+ __('Available templates') => '',
+ ]) .
+ dcPage::notices() .
+ '' . __('Available templates') . '
';
-echo
-'' . form::hidden(['p'], 'templator') .
-dcCore::app()->formNonce() .
-'
' .
-'';
+ if (count($items) == 0) {
+ echo '' . __('No template.') . '
';
+ } else {
+ $pager = new pager($page, count($items), $nb_per_page, 10);
+ $pager->html_prev = __('«prev.');
+ $pager->html_next = __('next»');
-if (count($items) == 0) {
- echo '' . __('No template.') . '
';
-} else {
- $pager = new pager($page, count($items), $nb_per_page, 10);
- $pager->html_prev = __('«prev.');
- $pager->html_next = __('next»');
+ echo
+ '' .
+
+ '';
+ }
+
+/**
+ * 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] .= '' . $letter . ' |
';
+ }
+
+ $img = '';
+ 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] .= '' .
+ '' . $tags->meta_id . ' ' . $img_status . ' | ' .
+ '' . $tags->count . ' ' .
+ (($tags->count == 1) ? __('entry') : __('entries')) . ' | ' .
+ '
';
+
+ $last_letter = $letter;
+ }
+
+ $table = '';
echo
- '' .
+ '' . __('Templator') . '' .
+ dcPage::cssLoad(dcPage::getPF('tags/style.css')) .
+ '' .
+ dcPage::breadcrumb([
+ __('Plugins') => '',
+ __('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
+ __('Used templates') => '',
+ ]) .
+ dcPage::notices() .
+ '' . __('Used templates') . '
';
- '';
+ '' . __('Templator') . '' .
+ 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])) .
+ '' .
+ dcPage::breadcrumb([
+ __('Plugins') => '',
+ __('Templates engine') => dcCore::app()->adminurl->get('admin.plugin.templator'),
+ __('Unselect template') => '',
+ ]) .
+ dcPage::notices() .
+
+ '' . __('Unselect template') . '
' .
+ '' . __('Back') . '
';
+
+ if (!dcCore::app()->error->flag()) {
+ if ($posts->isEmpty() && !$filter->show()) {
+ echo '' . __('There is no entries') . '
';
+ } 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,
+ '',
+ $filter->show(),
+ dcCore::app()->adminurl->get('admin.plugin.templator', $filter->values())
+ );
+ }
+ }
+
+/**
+ * Default page
+ */
+} else {
+ echo
+ '' . __('Templator') . '' .
+ '' .
+ dcPage::breadcrumb([
+ __('Plugins') => '',
+ __('Templates engine') => '',
+ ]) .
+ dcPage::notices();
+
+ $line = ' - %s
';
+ echo '
+ ' . __('Manage additional templates') . '
' .
+ sprintf(
+ '',
+ 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
- '
- ' .
- __('Display templates used for entries in base') . '
-
-
';
-?>
-
-
\ No newline at end of file
+dcPage::helpBlock('templator');
+
+echo '';
\ No newline at end of file
diff --git a/js/form.js b/js/form.js
deleted file mode 100644
index e8b620b..0000000
--- a/js/form.js
+++ /dev/null
@@ -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;
- });
-
-
-
-
-});
diff --git a/js/posts.js b/js/posts.js
new file mode 100644
index 0000000..852a07a
--- /dev/null
+++ b/js/posts.js
@@ -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');
+});
\ No newline at end of file
diff --git a/js/script.js b/js/script.js
deleted file mode 100644
index 70faf2d..0000000
--- a/js/script.js
+++ /dev/null
@@ -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=$('');$('#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();
- }
- });
-});
diff --git a/template_posts.php b/template_posts.php
deleted file mode 100644
index abeeb97..0000000
--- a/template_posts.php
+++ /dev/null
@@ -1,147 +0,0 @@
-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]);
-
-?>
-
-
-
-
-
-
-
-
-blog->name); ?> ›
-
-
-' . __('Back to templates list') . '';
-
-if (!dcCore::app()->error->flag()) {
- # Show posts
- $post_list->display(
- $page,
- $nb_per_page,
- '
'
- );
-
- # Remove tag
- if (!$posts->isEmpty() && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
- dcAuth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog->id)) {
- echo
- '';
- }
-}
-?>
-
-
\ No newline at end of file