move settings from plugin config to blog pref
This commit is contained in:
parent
64e42494ca
commit
1788d0324e
@ -2,14 +2,14 @@ enhancePostContent xxxx.xx.xx
|
||||
* Not added priority on filters for replacement order
|
||||
* Not added priority on lists of filters for replacement order
|
||||
* Not added auto-find post title in content
|
||||
* move settings from plugin to blog
|
||||
|
||||
enhancePostContent 2021.08.xx
|
||||
enhancePostContent 2021.08.24
|
||||
* switch to Dotclear 2.19
|
||||
* switch to php 7.3+ and php 8.0.x
|
||||
* switch to Github
|
||||
* update license
|
||||
* update php code to PSR-2 and short array
|
||||
* move settings from plugin to blog
|
||||
|
||||
enhancePostContent 2013.11.08
|
||||
* Switch to Dotclear 2.6 (admin styles and settings)
|
||||
|
@ -22,8 +22,7 @@ atgs, acronyms, abbreviations, definition, citation, link, etc...
|
||||
First install enhancePostContent, manualy from a zip package or from
|
||||
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||
|
||||
Go to ''plugins manager'', expand enhancePostContent information then
|
||||
go to ''configure plugin'', fill in form.
|
||||
Go to ''blog preference'' => fieldset ''plugin preference', fill in form.
|
||||
|
||||
Once it's done you can manage filters from menu
|
||||
''Enhance Post Content'' on sidebar or you can add dashboard icon,
|
||||
|
89
_admin.php
89
_admin.php
@ -15,6 +15,8 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->blog->settings->addNamespace('enhancePostContent');
|
||||
|
||||
require dirname(__FILE__) . '/_widgets.php';
|
||||
|
||||
# Admin menu
|
||||
@ -33,6 +35,14 @@ $core->addBehavior(
|
||||
'adminDashboardFavorites',
|
||||
['epcAdminBehaviors', 'adminDashboardFavorites']
|
||||
);
|
||||
$core->addBehavior(
|
||||
'adminBlogPreferencesForm',
|
||||
['epcAdminBehaviors', 'adminBlogPreferencesForm']
|
||||
);
|
||||
$core->addBehavior(
|
||||
'adminBeforeBlogSettingsUpdate',
|
||||
['epcAdminBehaviors', 'adminBeforeBlogSettingsUpdate']
|
||||
);
|
||||
|
||||
class epcAdminBehaviors
|
||||
{
|
||||
@ -57,4 +67,83 @@ class epcAdminBehaviors
|
||||
&& isset($params['p'])
|
||||
&& $params['p'] == 'enhancePostContent';
|
||||
}
|
||||
|
||||
public static function sortbyCombo()
|
||||
{
|
||||
return [
|
||||
__('Date') => 'epc_upddt',
|
||||
__('Key') => 'epc_key',
|
||||
__('Value') => 'epc_value',
|
||||
__('ID') => 'epc_id'
|
||||
];
|
||||
}
|
||||
|
||||
public static function orderCombo()
|
||||
{
|
||||
return [
|
||||
__('Ascending') => 'asc',
|
||||
__('Descending') => 'desc'
|
||||
];
|
||||
}
|
||||
|
||||
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
|
||||
{
|
||||
$active = (boolean) $blog_settings->enhancePostContent->enhancePostContent_active;
|
||||
$list_sortby = (string) $blog_settings->enhancePostContent->enhancePostContent_list_sortby;
|
||||
$list_order = (string) $blog_settings->enhancePostContent->enhancePostContent_list_order;
|
||||
$list_nb = (integer) $blog_settings->enhancePostContent->enhancePostContent_list_nb;
|
||||
$_filters = libEPC::blogFilters();
|
||||
$allowedtplvalues = libEPC::blogAllowedTplValues();
|
||||
$allowedpubpages = libEPC::blogAllowedPubPages();
|
||||
|
||||
echo
|
||||
'<div class="fieldset"><h4 id="fac_params">' . __('Enhance post content') .'</h4>' .
|
||||
'<div class="two-cols">' .
|
||||
'<div class="col">' .
|
||||
'<p><label class="classic">' .
|
||||
form::checkbox('epc_active', '1', $active) .
|
||||
__('Enable plugin') . '</label></p>' .
|
||||
'<p class="form-note">' .
|
||||
__('This enable public widgets and contents filter.') .
|
||||
'</p>' .
|
||||
'<h5>' . __('Record list') . '</h4>' .
|
||||
'<p class="form-note">' . __('This is the default order of records lists.') . '</p>' .
|
||||
'<p><label for="epc_list_sortby">' . __('Order by:') . '</label>' .
|
||||
form::combo('epc_list_sortby', self::sortbyCombo(), $list_sortby) . '</p>' .
|
||||
'<p><label for="epc_list_order">' . __('Sort:') . '</label>' .
|
||||
form::combo('epc_list_order', self::orderCombo(), $list_order) . '</p>' .
|
||||
'<p><label for="list_nb">' . __('Records per page:') . '</label>' .
|
||||
form::field('epc_list_nb', 3, 3, $list_nb) . '</p>' .
|
||||
'</div>' .
|
||||
'<div class="col">' .
|
||||
'<h5>' . __('Extra') . '</h5>' .
|
||||
'<p>' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '</p>' .
|
||||
'<p><label for="epc_allowedtplvalues">' . __('Allowed DC template values:') . '</label>' .
|
||||
form::field('epc_allowedtplvalues', 100, 0, libEPC::implode($allowedtplvalues)) . '</p>' .
|
||||
'<p class="form-note">' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '</p>' .
|
||||
'<p><label for="epc_allowedpubpages">' . __('Allowed public pages:') . '</label>' .
|
||||
form::field('epc_allowedpubpages', 100, 0, libEPC::implode($allowedpubpages)) . '</p>' .
|
||||
'<p class="form-note">' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '</p>' .
|
||||
'</div>' .
|
||||
'</div>' .
|
||||
'<br class="clear" />' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings)
|
||||
{
|
||||
$active = !empty($_POST['epc_active']);
|
||||
$list_sortby = in_array($_POST['epc_list_sortby'], self::sortbyCombo()) ? $_POST['epc_list_sortby'] : 'epc_id';
|
||||
$list_order = in_array($_POST['epc_list_order'], self::orderCombo()) ? $_POST['epc_list_order'] : 'desc';
|
||||
$list_nb = isset($_POST['epc_list_nb']) && $_POST['epc_list_nb'] > 0 ? $_POST['epc_list_nb'] : 20;
|
||||
$allowedtplvalues = libEPC::explode($_POST['epc_allowedtplvalues']);
|
||||
$allowedpubpages = libEPC::explode($_POST['epc_allowedpubpages']);
|
||||
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_active', $active);
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_list_sortby', $list_sortby);
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_list_order', $list_order);
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_list_nb', $list_nb);
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_allowedtplvalues', serialize($allowedtplvalues));
|
||||
$blog_settings->enhancePostContent->put('enhancePostContent_allowedpubpages', serialize($allowedpubpages));
|
||||
}
|
||||
}
|
130
_config.php
130
_config.php
@ -1,130 +0,0 @@
|
||||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of enhancePostContent, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2021 Jean-Christian Denis 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_MODULE')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$redir = empty($_REQUEST['redir']) ?
|
||||
$list->getURL().'#plugins' : $_REQUEST['redir'];
|
||||
|
||||
# -- Form combos --
|
||||
$sortby_combo = array(
|
||||
__('Date') => 'epc_upddt',
|
||||
__('Key') => 'epc_key',
|
||||
__('Value') => 'epc_value',
|
||||
__('ID') => 'epc_id'
|
||||
);
|
||||
|
||||
$order_combo = array(
|
||||
__('Ascending') => 'asc',
|
||||
__('Descending') => 'desc'
|
||||
);
|
||||
|
||||
# -- Get settings --
|
||||
$core->blog->settings->addNamespace('enhancePostContent');
|
||||
$s = $core->blog->settings->enhancePostContent;
|
||||
$active = (boolean) $s->enhancePostContent_active;
|
||||
$list_sortby = (string) $s->enhancePostContent_list_sortby;
|
||||
$list_order = (string) $s->enhancePostContent_list_order;
|
||||
$list_nb = (integer) $s->enhancePostContent_list_nb;
|
||||
$_filters = libEPC::blogFilters();
|
||||
$allowedtplvalues = libEPC::blogAllowedTplValues();
|
||||
$allowedpubpages = libEPC::blogAllowedPubPages();
|
||||
|
||||
# -- Set settings --
|
||||
if (!empty($_POST['save'])) {
|
||||
|
||||
try {
|
||||
$active = !empty($_POST['active']);
|
||||
$list_sortby = in_array($_POST['list_sortby'], $sortby_combo) ?
|
||||
$_POST['list_sortby'] : 'epc_id';
|
||||
$list_order = in_array($_POST['list_order'], $order_combo) ?
|
||||
$_POST['list_order'] : 'desc';
|
||||
$list_nb = isset($_POST['list_nb']) && $_POST['list_nb'] > 0 ?
|
||||
$_POST['list_nb'] : 20;
|
||||
|
||||
$s->put('enhancePostContent_active', $active);
|
||||
$s->put('enhancePostContent_list_sortby', $list_sortby);
|
||||
$s->put('enhancePostContent_list_order', $list_order);
|
||||
$s->put('enhancePostContent_list_nb', $list_nb);
|
||||
|
||||
$allowedtplvalues = libEPC::explode($_POST['allowedtplvalues']);
|
||||
$allowedpubpages = libEPC::explode($_POST['allowedpubpages']);
|
||||
|
||||
$s->put(
|
||||
'enhancePostContent_allowedtplvalues',
|
||||
serialize($allowedtplvalues)
|
||||
);
|
||||
$s->put(
|
||||
'enhancePostContent_allowedpubpages',
|
||||
serialize($allowedpubpages)
|
||||
);
|
||||
|
||||
$core->blog->triggerBlog();
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
__('Configuration has been successfully updated.')
|
||||
);
|
||||
http::redirect(
|
||||
$list->getURL('module=enhancePostContent&conf=1&redir='.
|
||||
$list->getRedir())
|
||||
);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
# -- Display form --
|
||||
echo '
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('General').'</h4>
|
||||
<p>'.__('This enable public widgets and contents filter.').'</p>
|
||||
|
||||
<p><label class="classic" for="active">'.
|
||||
form::checkbox('active', 1, $active).
|
||||
__('Enable plugin').'</label></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Record list').'</h4>
|
||||
<p>'.__('This is the default order of records lists.').'</p>
|
||||
|
||||
<p><label for="list_sortby">'.__('Order by:').'</label>'.
|
||||
form::combo('list_sortby', $sortby_combo, $list_sortby).'</p>
|
||||
|
||||
<p><label for="list_order">'.__('Sort:').'</label>'.
|
||||
form::combo('list_order', $order_combo, $list_order).'</p>
|
||||
|
||||
<p><label for="list_nb">'.__('Records per page:').'</label>'.
|
||||
form::field('list_nb', 3, 3, $list_nb).'</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Extra').'</h4>
|
||||
<p>'.__('This is a special feature to edit list of allowed template values and public pages where this plugin works.').'</p>
|
||||
|
||||
<p><label for="allowedtplvalues">'.__('Allowed DC template values:').'</label>'.
|
||||
form::field('allowedtplvalues', 100,0, libEPC::implode($allowedtplvalues)).'</p>
|
||||
<p class="form-note">'.__('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".').'</p>
|
||||
|
||||
<p><label for="allowedpubpages">'.__('Allowed public pages:').'</label>'.
|
||||
form::field('allowedpubpages', 100, 0, libEPC::implode($allowedpubpages)).'</p>
|
||||
<p class="form-note">'.__('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".').'</p>
|
||||
|
||||
</div>';
|
@ -19,7 +19,7 @@ $this->registerModule(
|
||||
'Enhance post content',
|
||||
'Add features to words in post content',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'2021.08.0',
|
||||
'2021.08.24',
|
||||
[
|
||||
'permissions' => 'contentadmin',
|
||||
'type' => 'plugin',
|
||||
|
Loading…
Reference in New Issue
Block a user