prepare to DC 2.24

master
Jean-Christian Paul Denis 2022-11-13 21:30:48 +01:00
parent bf88d37dcf
commit 4bb22b0dbc
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
13 changed files with 186 additions and 206 deletions

View File

@ -14,12 +14,12 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$core->blog->settings->addNamespace('enhancePostContent'); dcCore::app()->blog->settings->addNamespace('enhancePostContent');
require dirname(__FILE__) . '/_widgets.php'; require __DIR__ . '/_widgets.php';
# Admin menu # Admin menu
$_menu['Plugins']->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Enhance post content'), __('Enhance post content'),
'plugin.php?p=enhancePostContent', 'plugin.php?p=enhancePostContent',
'index.php?pf=enhancePostContent/icon.png', 'index.php?pf=enhancePostContent/icon.png',
@ -27,40 +27,40 @@ $_menu['Plugins']->addItem(
'/plugin.php\?p=enhancePostContent(&.*)?$/', '/plugin.php\?p=enhancePostContent(&.*)?$/',
$_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']
), ),
$core->auth->check('contentadmin', $core->blog->id) dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id)
); );
$core->addBehavior( dcCore::app()->addBehavior(
'adminDashboardFavorites', 'adminDashboardFavoritesV2',
['epcAdminBehaviors', 'adminDashboardFavorites'] ['epcAdminBehaviors', 'adminDashboardFavorites']
); );
$core->addBehavior( dcCore::app()->addBehavior(
'adminBlogPreferencesForm', 'adminBlogPreferencesFormV2',
['epcAdminBehaviors', 'adminBlogPreferencesForm'] ['epcAdminBehaviors', 'adminBlogPreferencesForm']
); );
$core->addBehavior( dcCore::app()->addBehavior(
'adminBeforeBlogSettingsUpdate', 'adminBeforeBlogSettingsUpdate',
['epcAdminBehaviors', 'adminBeforeBlogSettingsUpdate'] ['epcAdminBehaviors', 'adminBeforeBlogSettingsUpdate']
); );
$core->addBehavior( dcCore::app()->addBehavior(
'adminFiltersLists', 'adminFiltersListsV2',
['epcAdminBehaviors', 'adminFiltersLists'] ['epcAdminBehaviors', 'adminFiltersLists']
); );
class epcAdminBehaviors class epcAdminBehaviors
{ {
public static function adminDashboardFavorites($core, $favs) public static function adminDashboardFavorites(dcFavorites $favs)
{ {
$favs->register('enhancePostContent', [ $favs->register('enhancePostContent', [
'title' => __('Enhance post content'), 'title' => __('Enhance post content'),
'url' => 'plugin.php?p=enhancePostContent', 'url' => 'plugin.php?p=enhancePostContent',
'small-icon' => 'index.php?pf=enhancePostContent/icon.png', 'small-icon' => 'index.php?pf=enhancePostContent/icon.png',
'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png', 'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png',
'permissions' => $core->auth->check('contentadmin', $core->blog->id), 'permissions' => dcCore::app()->auth->check('contentadmin', dcCore::app()->blog->id),
'active_cb' => [ 'active_cb' => [
'epcAdminBehaviors', 'epcAdminBehaviors',
'adminDashboardFavoritesActive' 'adminDashboardFavoritesActive',
] ],
]); ]);
} }
@ -77,11 +77,11 @@ class epcAdminBehaviors
__('Date') => 'epc_upddt', __('Date') => 'epc_upddt',
__('Key') => 'epc_key', __('Key') => 'epc_key',
__('Value') => 'epc_value', __('Value') => 'epc_value',
__('ID') => 'epc_id' __('ID') => 'epc_id',
]; ];
} }
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings) public static function adminBlogPreferencesForm(dcSettings $blog_settings)
{ {
$active = (bool) $blog_settings->enhancePostContent->enhancePostContent_active; $active = (bool) $blog_settings->enhancePostContent->enhancePostContent_active;
$allowedtplvalues = libEPC::blogAllowedTplValues(); $allowedtplvalues = libEPC::blogAllowedTplValues();
@ -97,7 +97,7 @@ class epcAdminBehaviors
'<p class="form-note">' . '<p class="form-note">' .
__('This enable public widgets and contents filter.') . __('This enable public widgets and contents filter.') .
'</p>' . '</p>' .
'<p><a href="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '">' . '<p><a href="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '">' .
__('Set content filters') . '</a></p>' . __('Set content filters') . '</a></p>' .
'</div>' . '</div>' .
'<div class="col">' . '<div class="col">' .
@ -126,14 +126,14 @@ class epcAdminBehaviors
$blog_settings->enhancePostContent->put('enhancePostContent_allowedpubpages', serialize($allowedpubpages)); $blog_settings->enhancePostContent->put('enhancePostContent_allowedpubpages', serialize($allowedpubpages));
} }
public static function adminFiltersLists(dcCore $core, $sorts) public static function adminFiltersLists($sorts)
{ {
$sorts['epc'] = [ $sorts['epc'] = [
__('Enhance post content'), __('Enhance post content'),
self::sortbyCombo(), self::sortbyCombo(),
'epc_upddt', 'epc_upddt',
'desc', 'desc',
[__('records per page'), 20] [__('records per page'), 20],
]; ];
} }
} }

View File

@ -18,16 +18,16 @@ $this->registerModule(
'Enhance post content', 'Enhance post content',
'Add features to words in post content', 'Add features to words in post content',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'2021.11.13', '2021.12.11',
[ [
'requires' => [['core', '2.20']], 'requires' => [['core', '2.24']],
'permissions' => 'contentadmin', 'permissions' => dcAuth::PERMISSION_CONTENT_ADMIN,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/enhancePostContent', 'support' => 'https://github.com/JcDenis/enhancePostContent',
'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent', 'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent',
'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml',
'settings' => [ 'settings' => [
'blog' => '#params.epc_params' 'blog' => '#params.epc_params',
] ],
] ]
); );

View File

@ -14,10 +14,10 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$dc_min = '2.18'; $dc_min = '2.24';
$mod_id = 'enhancePostContent'; $mod_id = 'enhancePostContent';
$new_version = $core->plugins->moduleInfo($mod_id, 'version'); $new_version = dcCore::app()->plugins->moduleInfo($mod_id, 'version');
$old_version = $core->getVersion($mod_id); $old_version = dcCore::app()->getVersion($mod_id);
if (version_compare($old_version, $new_version, '>=')) { if (version_compare($old_version, $new_version, '>=')) {
return null; return null;
@ -35,7 +35,7 @@ try {
} }
# Database # Database
$s = new dbStruct($core->con, $core->prefix); $s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$s->epc $s->epc
->epc_id('bigint', 0, false) ->epc_id('bigint', 0, false)
->blog_id('varchar', 32, false) ->blog_id('varchar', 32, false)
@ -51,13 +51,13 @@ try {
->index('idx_epc_filter', 'btree', 'epc_filter') ->index('idx_epc_filter', 'btree', 'epc_filter')
->index('idx_epc_key', 'btree', 'epc_key'); ->index('idx_epc_key', 'btree', 'epc_key');
$si = new dbStruct($core->con, $core->prefix); $si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$changes = $si->synchronize($s); $changes = $si->synchronize($s);
$s = null; $s = null;
# Settings # Settings
$core->blog->settings->addNamespace($mod_id); dcCore::app()->blog->settings->addNamespace($mod_id);
$s = $core->blog->settings->enhancePostContent; $s = dcCore::app()->blog->settings->enhancePostContent;
$s->put('enhancePostContent_active', false, 'boolean', 'Enable enhancePostContent', false, true); $s->put('enhancePostContent_active', false, 'boolean', 'Enable enhancePostContent', false, true);
$s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true); $s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
@ -76,7 +76,7 @@ try {
'style' => $filter->style, 'style' => $filter->style,
'notag' => $filter->notag, 'notag' => $filter->notag,
'tplValues' => $filter->tplValues, 'tplValues' => $filter->tplValues,
'pubPages' => $filter->pubPages 'pubPages' => $filter->pubPages,
]; ];
$s->put('enhancePostContent_' . $id, serialize($opt), 'string', 'Settings for ' . $id, false, true); $s->put('enhancePostContent_' . $id, serialize($opt), 'string', 'Settings for ' . $id, false, true);
/* # only tables /* # only tables
@ -92,11 +92,11 @@ try {
} }
# Version # Version
$core->setVersion($mod_id, $new_version); dcCore::app()->setVersion($mod_id, $new_version);
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
return false; return false;

View File

@ -24,22 +24,22 @@ $filters = [
'Link', 'Link',
'Replace', 'Replace',
'Update', 'Update',
'Twitter' 'Twitter',
]; ];
$d = dirname(__FILE__) . '/inc/'; $d = __DIR__ . '/inc/';
$__autoload['libEPC'] = $d . 'lib.epc.php'; Clearbricks::lib()->autoload(['libEPC' => $d . 'lib.epc.php']);
$__autoload['epcFilter'] = $d . 'lib.epc.filter.php'; Clearbricks::lib()->autoload(['epcFilter' => $d . 'lib.epc.filter.php']);
$__autoload['epcRecords'] = $d . 'lib.epc.records.php'; Clearbricks::lib()->autoload(['epcRecords' => $d . 'lib.epc.records.php']);
$__autoload['adminEpcList'] = $d . 'lib.epc.pager.php'; Clearbricks::lib()->autoload(['adminEpcList' => $d . 'lib.epc.pager.php']);
foreach ($filters as $f) { foreach ($filters as $f) {
$__autoload['epcFilter' . $f] = $d . 'lib.epc.filters.php'; Clearbricks::lib()->autoload(['epcFilter' . $f => $d . 'lib.epc.filters.php']);
$core->addBehavior('enhancePostContentFilters', ['epcFilter' . $f, 'create']); dcCore::app()->addBehavior('enhancePostContentFilters', ['epcFilter' . $f, 'create']);
} }
$core->url->register( dcCore::app()->url->register(
'epccss', 'epccss',
'epc.css', 'epc.css',
'^epc\.css', '^epc\.css',

View File

@ -14,17 +14,17 @@ if (!defined('DC_RC_PATH')) {
return null; return null;
} }
require dirname(__FILE__) . '/_widgets.php'; require __DIR__ . '/_widgets.php';
$core->blog->settings->addNamespace('enhancePostContent'); dcCore::app()->blog->settings->addNamespace('enhancePostContent');
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) { if (dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active) {
$core->addBehavior( dcCore::app()->addBehavior(
'publicHeadContent', 'publicHeadContentV2',
['publicEnhancePostContent', 'publicHeadContent'] ['publicEnhancePostContent', 'publicHeadContent']
); );
$core->addBehavior( dcCore::app()->addBehavior(
'publicBeforeContentFilter', 'publicBeforeContentFilterV2',
['publicEnhancePostContent', 'publicContentFilter'] ['publicEnhancePostContent', 'publicContentFilter']
); );
} }
@ -38,12 +38,10 @@ class publicEnhancePostContent
{ {
/** /**
* Add filters CSS to page header * Add filters CSS to page header
*
* @param dcCore $core dcCore instance
*/ */
public static function publicHeadContent(dcCore $core) public static function publicHeadContent()
{ {
echo dcUtils::cssLoad($core->blog->url . $core->url->getURLFor('epccss')); echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('epccss'));
} }
public static function css($args) public static function css($args)
@ -80,11 +78,10 @@ class publicEnhancePostContent
/** /**
* Filter template blocks content * Filter template blocks content
* *
* @param dcCore $core dcCore instance
* @param string $tag Tempalte block name * @param string $tag Tempalte block name
* @param array $args Tempalte Block arguments * @param array $args Tempalte Block arguments
*/ */
public static function publicContentFilter(dcCore $core, $tag, $args) public static function publicContentFilter($tag, $args)
{ {
$filters = libEPC::getFilters(); $filters = libEPC::getFilters();

View File

@ -14,7 +14,7 @@ if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$core->addBehavior( dcCore::app()->addBehavior(
'initWidgets', 'initWidgets',
['enhancePostContentWidget', 'adminContentList'] ['enhancePostContentWidget', 'adminContentList']
); );
@ -33,8 +33,6 @@ class enhancePostContentWidget
*/ */
public static function adminContentList($w) public static function adminContentList($w)
{ {
global $core;
$w->create( $w->create(
'epclist', 'epclist',
__('Enhance post content'), __('Enhance post content'),
@ -109,17 +107,15 @@ class enhancePostContentWidget
*/ */
public static function publicContentList($w) public static function publicContentList($w)
{ {
global $core, $_ctx;
if ($w->offline) { if ($w->offline) {
return null; return null;
} }
$core->blog->settings->addNamespace('enhancePostContent'); dcCore::app()->blog->settings->addNamespace('enhancePostContent');
# Page # Page
if (!$core->blog->settings->enhancePostContent->enhancePostContent_active if (!dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active
|| !in_array($_ctx->current_tpl, ['post.html', 'page.html']) || !in_array(dcCore::app()->ctx->current_tpl, ['post.html', 'page.html'])
) { ) {
return null; return null;
} }
@ -131,7 +127,7 @@ class enhancePostContentWidget
if ($w->$ns && is_callable($v['cb'])) { if ($w->$ns && is_callable($v['cb'])) {
$content .= call_user_func_array( $content .= call_user_func_array(
$v['cb'], $v['cb'],
[$core, $w] [dcCore::app(), $w]
); );
} }
} }

View File

@ -12,8 +12,6 @@
*/ */
abstract class epcFilter abstract class epcFilter
{ {
public $core;
private $id = 'undefined'; private $id = 'undefined';
private $records = null; private $records = null;
@ -25,7 +23,7 @@ abstract class epcFilter
'htmltag' => '', 'htmltag' => '',
'class' => [], 'class' => [],
'replace' => '', 'replace' => '',
'widget' => '' 'widget' => '',
]; ];
private $settings = [ private $settings = [
'nocase' => false, 'nocase' => false,
@ -34,21 +32,20 @@ abstract class epcFilter
'style' => [], 'style' => [],
'notag' => '', 'notag' => '',
'tplValues' => [], 'tplValues' => [],
'pubPages' => [] 'pubPages' => [],
]; ];
final public function __construct(dcCore $core) final public function __construct()
{ {
$this->core = $core;
$this->id = $this->init(); $this->id = $this->init();
$this->blogSettings(); $this->blogSettings();
} }
public static function create(arrayObject $o, dcCore $core) public static function create(arrayObject $o)
{ {
$c = get_called_class(); $c = get_called_class();
$o->append(new $c($core)); $o->append(new $c());
} }
final public function id() final public function id()
@ -112,7 +109,7 @@ abstract class epcFilter
private function blogSettings() private function blogSettings()
{ {
$ns = 'enhancePostContent_' . $this->id; $ns = 'enhancePostContent_' . $this->id;
$opt = @unserialize($this->core->blog->settings->enhancePostContent->$ns); $opt = @unserialize(dcCore::app()->blog->settings->enhancePostContent->$ns);
if (!is_array($opt)) { if (!is_array($opt)) {
$opt = []; $opt = [];
@ -143,7 +140,7 @@ abstract class epcFilter
final public function records() final public function records()
{ {
if ($this->records === null && $this->has_list) { if ($this->records === null && $this->has_list) {
$records = new epcRecords($this->core); $records = new epcRecords();
$this->records = $records->getRecords(['epc_filter' => $this->id()]); $this->records = $records->getRecords(['epc_filter' => $this->id()]);
} }

View File

@ -21,14 +21,14 @@ class epcFilterTag extends epcFilter
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-tag'], 'class' => ['a.epc-tag'],
'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>', 'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>',
'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>' 'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['text-decoration: none; border-bottom: 3px double #CCCCCC;'], 'style' => ['text-decoration: none; border-bottom: 3px double #CCCCCC;'],
'notag' => 'a,h1,h2,h3', 'notag' => 'a,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'tag'; return 'tag';
@ -36,16 +36,16 @@ class epcFilterTag extends epcFilter
public function publicContent($tag, $args) public function publicContent($tag, $args)
{ {
if (!$this->core->plugins->moduleExists('tags')) { if (!dcCore::app()->plugins->moduleExists('tags')) {
return null; return null;
} }
$metas = $this->core->meta->getMetadata(['meta_type' => 'tag']); $metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
while ($metas->fetch()) { while ($metas->fetch()) {
$args[0] = libEPC::replaceString( $args[0] = libEPC::replaceString(
$metas->meta_id, $metas->meta_id,
sprintf($this->replace, $this->core->blog->url . $this->core->url->getBase('tag') . '/' . $metas->meta_id, '\\1'), sprintf($this->replace, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
$args[0], $args[0],
$this $this
); );
@ -56,16 +56,16 @@ class epcFilterTag extends epcFilter
public function widgetList($content, $w, &$list) public function widgetList($content, $w, &$list)
{ {
if (!$this->core->plugins->moduleExists('tags')) { if (!dcCore::app()->plugins->moduleExists('tags')) {
return null; return null;
} }
$metas = $this->core->meta->getMetadata(['meta_type' => 'tag']); $metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
while ($metas->fetch()) { while ($metas->fetch()) {
$list[] = libEPC::matchString( $list[] = libEPC::matchString(
$metas->meta_id, $metas->meta_id,
sprintf($this->widget, $this->core->blog->url . $this->core->url->getBase('tag') . '/' . $metas->meta_id, '\\1'), sprintf($this->widget, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
$content, $content,
$this $this
); );
@ -85,7 +85,7 @@ class epcFilterSearch extends epcFilter
'help' => __('Highlight searched words.'), 'help' => __('Highlight searched words.'),
'htmltag' => '', 'htmltag' => '',
'class' => ['span.epc-search'], 'class' => ['span.epc-search'],
'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>' 'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>',
]); ]);
$this->setSettings([ $this->setSettings([
@ -94,7 +94,7 @@ class epcFilterSearch extends epcFilter
'style' => ['color: #FFCC66;'], 'style' => ['color: #FFCC66;'],
'notag' => 'h1,h2,h3', 'notag' => 'h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['search.html'] 'pubPages' => ['search.html'],
]); ]);
return 'search'; return 'search';
@ -102,11 +102,11 @@ class epcFilterSearch extends epcFilter
public function publicContent($tag, $args) public function publicContent($tag, $args)
{ {
if (!isset($GLOBALS['_search'])) { if (empty(dcCore::app()->public->search)) {
return null; return null;
} }
$searchs = explode(' ', $GLOBALS['_search']); $searchs = explode(' ', dcCore::app()->public->search);
foreach ($searchs as $k => $v) { foreach ($searchs as $k => $v) {
$args[0] = libEPC::replaceString( $args[0] = libEPC::replaceString(
@ -133,14 +133,14 @@ class epcFilterAcronym extends epcFilter
'htmltag' => 'acronym', 'htmltag' => 'acronym',
'class' => ['acronym.epc-acronym'], 'class' => ['acronym.epc-acronym'],
'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>', 'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>',
'widget' => '<acronym title="%s">%s</acronym>' 'widget' => '<acronym title="%s">%s</acronym>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['font-weight: bold;'], 'style' => ['font-weight: bold;'],
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3', 'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'acronym'; return 'acronym';
@ -187,14 +187,14 @@ class epcFilterAbbreviation extends epcFilter
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['abbr.epc-abbr'], 'class' => ['abbr.epc-abbr'],
'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>', 'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>',
'widget' => '<abbr title="%s">%s</abbr>' 'widget' => '<abbr title="%s">%s</abbr>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['font-weight: bold;'], 'style' => ['font-weight: bold;'],
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3', 'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'abbreviation'; return 'abbreviation';
@ -241,14 +241,14 @@ class epcFilterDefinition extends epcFilter
'htmltag' => 'dfn', 'htmltag' => 'dfn',
'class' => ['dfn.epc-dfn'], 'class' => ['dfn.epc-dfn'],
'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>', 'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>' 'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['font-weight: bold;'], 'style' => ['font-weight: bold;'],
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3', 'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'definition'; return 'definition';
@ -295,7 +295,7 @@ class epcFilterCitation extends epcFilter
'htmltag' => 'cite', 'htmltag' => 'cite',
'class' => ['cite.epc-cite'], 'class' => ['cite.epc-cite'],
'replace' => '<cite class="epc-cite" title="%s">%s</cite>', 'replace' => '<cite class="epc-cite" title="%s">%s</cite>',
'widget' => '<cite title="%s">%s</cite>' 'widget' => '<cite title="%s">%s</cite>',
]); ]);
$this->setSettings([ $this->setSettings([
@ -303,7 +303,7 @@ class epcFilterCitation extends epcFilter
'style' => ['font-style: italic;'], 'style' => ['font-style: italic;'],
'notag' => 'a,h1,h2,h3', 'notag' => 'a,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'citation'; return 'citation';
@ -350,14 +350,14 @@ class epcFilterLink extends epcFilter
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-link'], 'class' => ['a.epc-link'],
'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>', 'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>',
'widget' => '<a title="%s" href="%s">%s</a>' 'widget' => '<a title="%s" href="%s">%s</a>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['text-decoration: none; font-style: italic; color: #0000FF;'], 'style' => ['text-decoration: none; font-style: italic; color: #0000FF;'],
'notag' => 'a,h1,h2,h3', 'notag' => 'a,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'link'; return 'link';
@ -403,7 +403,7 @@ class epcFilterReplace extends epcFilter
'has_list' => true, 'has_list' => true,
'htmltag' => '', 'htmltag' => '',
'class' => ['span.epc-replace'], 'class' => ['span.epc-replace'],
'replace' => '<span class="epc-replace">%s</span>' 'replace' => '<span class="epc-replace">%s</span>',
]); ]);
$this->setSettings([ $this->setSettings([
@ -412,7 +412,7 @@ class epcFilterReplace extends epcFilter
'style' => ['font-style: italic;'], 'style' => ['font-style: italic;'],
'notag' => 'h1,h2,h3', 'notag' => 'h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'replace'; return 'replace';
@ -444,7 +444,7 @@ class epcFilterUpdate extends epcFilter
'has_list' => true, 'has_list' => true,
'htmltag' => 'del,ins', 'htmltag' => 'del,ins',
'class' => ['del.epc-update', 'ins.epc-update'], 'class' => ['del.epc-update', 'ins.epc-update'],
'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>' 'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>',
]); ]);
$this->setSettings([ $this->setSettings([
@ -453,7 +453,7 @@ class epcFilterUpdate extends epcFilter
'style' => ['text-decoration: line-through;', 'font-style: italic;'], 'style' => ['text-decoration: line-through;', 'font-style: italic;'],
'notag' => 'h1,h2,h3', 'notag' => 'h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'update'; return 'update';
@ -484,14 +484,14 @@ class epcFilterTwitter extends epcFilter
'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'), 'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'),
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-twitter'], 'class' => ['a.epc-twitter'],
'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>' 'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>',
]); ]);
$this->setSettings([ $this->setSettings([
'style' => ['text-decoration: none; font-weight: bold; font-style: italic; color: #0000FF;'], 'style' => ['text-decoration: none; font-weight: bold; font-style: italic; color: #0000FF;'],
'notag' => 'a,h1,h2,h3', 'notag' => 'a,h1,h2,h3',
'tplValues' => ['EntryContent'], 'tplValues' => ['EntryContent'],
'pubPages' => ['post.html'] 'pubPages' => ['post.html'],
]); ]);
return 'twitter'; return 'twitter';

View File

@ -43,7 +43,7 @@ class adminEpcList extends adminGenericList
$cols = [ $cols = [
'key' => '<th colspan="2" class="first">' . __('Key') . '</th>', 'key' => '<th colspan="2" class="first">' . __('Key') . '</th>',
'value' => '<th scope="col">' . __('Value') . '</th>', 'value' => '<th scope="col">' . __('Value') . '</th>',
'date' => '<th scope="col">' . __('Date') . '</th>' 'date' => '<th scope="col">' . __('Date') . '</th>',
]; ];
$html_block = '<div class="table-outer"><table><caption>' . $html_block = '<div class="table-outer"><table><caption>' .
@ -75,7 +75,7 @@ class adminEpcList extends adminGenericList
'check' => '<td class="nowrap">' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . '</td>', 'check' => '<td class="nowrap">' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . '</td>',
'key' => '<td class="nowrap">' . html::escapeHTML($this->rs->epc_key) . '</td>', 'key' => '<td class="nowrap">' . html::escapeHTML($this->rs->epc_key) . '</td>',
'value' => '<td class="maximal">' . html::escapeHTML($this->rs->epc_value) . '</td>', 'value' => '<td class="maximal">' . html::escapeHTML($this->rs->epc_value) . '</td>',
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . '</td>' 'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . '</td>',
]; ];
return return

View File

@ -11,9 +11,15 @@
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
# l10n # l10n
__('entry excerpt');__('entry content');__('comment content'); __('entry excerpt');
__('home page');__('post page');__('category page');__('search results page'); __('entry content');
__('atom feeds');__('RSS feeds'); __('comment content');
__('home page');
__('post page');
__('category page');
__('search results page');
__('atom feeds');
__('RSS feeds');
class libEPC class libEPC
{ {
@ -26,91 +32,79 @@ class libEPC
public static function defaultAllowedTplValues() public static function defaultAllowedTplValues()
{ {
global $core;
$rs = new arrayObject([ $rs = new arrayObject([
'entry excerpt' => 'EntryExcerpt', 'entry excerpt' => 'EntryExcerpt',
'entry content' => 'EntryContent', 'entry content' => 'EntryContent',
'comment content' => 'CommentContent', 'comment content' => 'CommentContent',
]); ]);
$core->callBehavior('enhancePostContentAllowedTplValues', $rs); dcCore::app()->callBehavior('enhancePostContentAllowedTplValues', $rs);
return iterator_to_array($rs, true); return iterator_to_array($rs, true);
} }
public static function blogAllowedTplValues() public static function blogAllowedTplValues()
{ {
global $core; dcCore::app()->blog->settings->addNamespace('enhancePostContent');
$rs = @unserialize(dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_allowedtplvalues);
$core->blog->settings->addNamespace('enhancePostContent');
$rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedtplvalues);
return is_array($rs) ? $rs : self::defaultAllowedTplValues(); return is_array($rs) ? $rs : self::defaultAllowedTplValues();
} }
public static function defaultAllowedWidgetValues() public static function defaultAllowedWidgetValues()
{ {
global $core;
$rs = new arrayObject([ $rs = new arrayObject([
'entry excerpt' => [ 'entry excerpt' => [
'id' => 'entryexcerpt', 'id' => 'entryexcerpt',
'cb' => ['libEPC','widgetContentEntryExcerpt'] 'cb' => ['libEPC','widgetContentEntryExcerpt'],
], ],
'entry content' => [ 'entry content' => [
'id' => 'entrycontent', 'id' => 'entrycontent',
'cb' => ['libEPC','widgetContentEntryContent'] 'cb' => ['libEPC','widgetContentEntryContent'],
], ],
'comment content' => [ 'comment content' => [
'id' => 'commentcontent', 'id' => 'commentcontent',
'cb' => ['libEPC','widgetContentCommentContent'] 'cb' => ['libEPC','widgetContentCommentContent'],
] ],
]); ]);
$core->callBehavior('enhancePostContentAllowedWidgetValues', $rs); dcCore::app()->callBehavior('enhancePostContentAllowedWidgetValues', $rs);
return iterator_to_array($rs, true); return iterator_to_array($rs, true);
} }
public static function defaultAllowedPubPages() public static function defaultAllowedPubPages()
{ {
global $core;
$rs = new arrayObject([ $rs = new arrayObject([
'home page' => 'home.html', 'home page' => 'home.html',
'post page' => 'post.html', 'post page' => 'post.html',
'category page' => 'category.html', 'category page' => 'category.html',
'search results page' => 'search.html', 'search results page' => 'search.html',
'atom feeds' => 'atom.xml', 'atom feeds' => 'atom.xml',
'RSS feeds' => 'rss2.xml' 'RSS feeds' => 'rss2.xml',
]); ]);
$core->callBehavior('enhancePostContentAllowedPubPages', $rs); dcCore::app()->callBehavior('enhancePostContentAllowedPubPages', $rs);
return iterator_to_array($rs, true); return iterator_to_array($rs, true);
} }
public static function blogAllowedPubPages() public static function blogAllowedPubPages()
{ {
global $core; dcCore::app()->blog->settings->addNamespace('enhancePostContent');
$rs = @unserialize(dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_allowedpubpages);
$core->blog->settings->addNamespace('enhancePostContent');
$rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedpubpages);
return is_array($rs) ? $rs : self::defaultAllowedPubPages(); return is_array($rs) ? $rs : self::defaultAllowedPubPages();
} }
public static function getFilters() public static function getFilters()
{ {
global $core;
if (self::$default_filters === null) { if (self::$default_filters === null) {
$final = $sort = []; $final = $sort = [];
$filters = new arrayObject(); $filters = new arrayObject();
try { try {
$core->callBehavior('enhancePostContentFilters', $filters, $core); dcCore::app()->callBehavior('enhancePostContentFilters', $filters);
foreach ($filters as $filter) { foreach ($filters as $filter) {
if ($filter instanceof epcFilter && !isset($final[$filter->id()])) { if ($filter instanceof epcFilter && !isset($final[$filter->id()])) {
@ -119,7 +113,7 @@ class libEPC
} }
} }
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
array_multisort($sort, $final); array_multisort($sort, $final);
self::$default_filters = $final; self::$default_filters = $final;
@ -131,7 +125,7 @@ class libEPC
public static function testContext($tag, $args, $filter) public static function testContext($tag, $args, $filter)
{ {
return is_array($filter->pubPages) return is_array($filter->pubPages)
&& in_array($GLOBALS['_ctx']->current_tpl, $filter->pubPages) && in_array(dcCore::app()->ctx->current_tpl, $filter->pubPages)
&& is_array($filter->tplValues) && is_array($filter->tplValues)
&& in_array($tag, $filter->tplValues) && in_array($tag, $filter->tplValues)
&& $args[0] != '' //content && $args[0] != '' //content
@ -279,17 +273,15 @@ class libEPC
# Widgets # Widgets
# #
public static function widgetContentEntryExcerpt($core, $w) public static function widgetContentEntryExcerpt($w)
{ {
global $_ctx; if (!dcCore::app()->ctx->exists('posts')) {
if (!$_ctx->exists('posts')) {
return null; return null;
} }
$res = ''; $res = '';
while ($_ctx->posts->fetch()) { while (dcCore::app()->ctx->posts->fetch()) {
$res .= $_ctx->posts->post_excerpt; $res .= dcCore::app()->ctx->posts->post_excerpt;
} }
return $res; return $res;
@ -297,15 +289,13 @@ class libEPC
public static function widgetContentEntryContent() public static function widgetContentEntryContent()
{ {
global $_ctx; if (!dcCore::app()->ctx->exists('posts')) {
if (!$_ctx->exists('posts')) {
return null; return null;
} }
$res = ''; $res = '';
while ($_ctx->posts->fetch()) { while (dcCore::app()->ctx->posts->fetch()) {
$res .= $_ctx->posts->post_content; $res .= dcCore::app()->ctx->posts->post_content;
} }
return $res; return $res;
@ -313,16 +303,14 @@ class libEPC
public static function widgetContentCommentContent() public static function widgetContentCommentContent()
{ {
global $core, $_ctx; if (!dcCore::app()->ctx->exists('posts')) {
if (!$_ctx->exists('posts')) {
return null; return null;
} }
$res = ''; $res = '';
$post_ids = []; $post_ids = [];
while ($_ctx->posts->fetch()) { while (dcCore::app()->ctx->posts->fetch()) {
$comments = $core->blog->getComments(['post_id' => $_ctx->posts->post_id]); $comments = dcCore::app()->blog->getComments(['post_id' => dcCore::app()->ctx->posts->post_id]);
while ($comments->fetch()) { while ($comments->fetch()) {
$res .= $comments->getContent(); $res .= $comments->getContent();
} }

View File

@ -12,17 +12,15 @@
*/ */
class epcRecords class epcRecords
{ {
public $core;
public $con; public $con;
public $table; public $table;
public $blog; public $blog;
public function __construct($core) public function __construct()
{ {
$this->core = $core; $this->con = dcCore::app()->con;
$this->con = $core->con; $this->table = dcCore::app()->prefix . 'epc';
$this->table = $core->prefix . 'epc'; $this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
$this->blog = $core->con->escape($core->blog->id);
} }
public function getRecords($params, $count_only = false) public function getRecords($params, $count_only = false)
@ -124,7 +122,7 @@ class epcRecords
$this->trigger(); $this->trigger();
# --BEHAVIOR-- enhancePostContentAfterAddRecord # --BEHAVIOR-- enhancePostContentAfterAddRecord
$this->core->callBehavior('enhancePostContentAfterAddRecord', $cur); dcCore::app()->callBehavior('enhancePostContentAfterAddRecord', $cur);
return $cur->epc_id; return $cur->epc_id;
} }
@ -143,7 +141,7 @@ class epcRecords
$this->trigger(); $this->trigger();
# --BEHAVIOR-- enhancePostContentAfterUpdRecord # --BEHAVIOR-- enhancePostContentAfterUpdRecord
$this->core->callBehavior('enhancePostContentAfterUpdRecord', $cur, $id); dcCore::app()->callBehavior('enhancePostContentAfterUpdRecord', $cur, $id);
} }
public function isRecord($filter, $key, $not_id = null) public function isRecord($filter, $key, $not_id = null)
@ -151,7 +149,7 @@ class epcRecords
return 0 < $this->getRecords([ return 0 < $this->getRecords([
'epc_filter' => $filter, 'epc_filter' => $filter,
'epc_key' => $key, 'epc_key' => $key,
'not_id' => $not_id 'not_id' => $not_id,
], true)->f(0); ], true)->f(0);
} }
@ -164,7 +162,7 @@ class epcRecords
} }
# --BEHAVIOR-- enhancePostContentBeforeDelRecord # --BEHAVIOR-- enhancePostContentBeforeDelRecord
$this->core->callBehavior('enhancePostContentbeforeDelRecord', $id); dcCore::app()->callBehavior('enhancePostContentbeforeDelRecord', $id);
$this->con->execute( $this->con->execute(
'DELETE FROM ' . $this->table . ' ' . 'DELETE FROM ' . $this->table . ' ' .
@ -203,6 +201,6 @@ class epcRecords
private function trigger() private function trigger()
{ {
$this->core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
} }
} }

View File

@ -10,41 +10,45 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!isset($old_version)) {
return null;
}
# Move old filters lists from settings to database # Move old filters lists from settings to database
if ($old_version && version_compare('0.6.6', $old_version, '>=')) { if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
$f = $core->con->select('SELECT * FROM ' . $core->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL "); $f = dcCore::app()->con->select('SELECT * FROM ' . dcCore::app()->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
while ($f->fetch()) { while ($f->fetch()) {
if (preg_match('#enhancePostContent_(.*?)List#', $f->setting_id, $m)) { if (preg_match('#enhancePostContent_(.*?)List#', $f->setting_id, $m)) {
$curlist = @unserialize($f->setting_value); $curlist = @unserialize($f->setting_value);
if (is_array($curlist)) { if (is_array($curlist)) {
foreach ($curlist as $k => $v) { foreach ($curlist as $k => $v) {
$cur = $core->con->openCursor($core->prefix . 'epc'); $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'epc');
$core->con->writeLock($core->prefix . 'epc'); dcCore::app()->con->writeLock(dcCore::app()->prefix . 'epc');
$cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM ' . $core->prefix . 'epc' . ' ')->f(0) + 1; $cur->epc_id = dcCore::app()->con->select('SELECT MAX(epc_id) FROM ' . dcCore::app()->prefix . 'epc' . ' ')->f(0) + 1;
$cur->blog_id = $f->blog_id; $cur->blog_id = $f->blog_id;
$cur->epc_filter = strtolower($m[1]); $cur->epc_filter = strtolower($m[1]);
$cur->epc_key = $k; $cur->epc_key = $k;
$cur->epc_value = $v; $cur->epc_value = $v;
$cur->insert(); $cur->insert();
$core->con->unlock(); dcCore::app()->con->unlock();
} }
} }
$core->con->execute('DELETE FROM ' . $core->prefix . "setting WHERE setting_id='" . $f->setting_id . "' AND setting_ns='enhancePostContent' AND blog_id='" . $f->blog_id . "' "); dcCore::app()->con->execute('DELETE FROM ' . dcCore::app()->prefix . "setting WHERE setting_id='" . $f->setting_id . "' AND setting_ns='enhancePostContent' AND blog_id='" . $f->blog_id . "' ");
} }
} }
# Move old filter name to filter id # Move old filter name to filter id
} elseif ($old_version && version_compare('2021.10.05', $old_version, '>=')) { } elseif ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
$rs = $core->con->select('SELECT epc_id, epc_filter FROM ' . $core->prefix . 'epc'); $rs = dcCore::app()->con->select('SELECT epc_id, epc_filter FROM ' . dcCore::app()->prefix . 'epc');
while ($rs->fetch()) { while ($rs->fetch()) {
$cur = $core->con->openCursor($core->prefix . 'epc'); $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'epc');
$cur->epc_filter = strtolower($rs->epc_filter); $cur->epc_filter = strtolower($rs->epc_filter);
$cur->update('WHERE epc_id = ' . $rs->epc_id . ' '); $cur->update('WHERE epc_id = ' . $rs->epc_id . ' ');
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
} }
} }

View File

@ -35,13 +35,13 @@ if (!isset($filters_id[$part])) {
$header = ''; $header = '';
$filter = $_filters[$part]; $filter = $_filters[$part];
$records = new epcRecords($core); $records = new epcRecords();
# -- Action -- # -- Action --
if (!empty($action)) { if (!empty($action)) {
# --BEHAVIOR-- enhancePostContentAdminSave # --BEHAVIOR-- enhancePostContentAdminSave
$core->callBehavior('enhancePostContentAdminSave', $core); dcCore::app()->callBehavior('enhancePostContentAdminSave');
} }
try { try {
@ -55,19 +55,19 @@ try {
'style' => (array) $_POST['filter_style'], 'style' => (array) $_POST['filter_style'],
'notag' => (string) $_POST['filter_notag'], 'notag' => (string) $_POST['filter_notag'],
'tplValues' => (array) $_POST['filter_tplValues'], 'tplValues' => (array) $_POST['filter_tplValues'],
'pubPages' => (array) $_POST['filter_pubPages'] 'pubPages' => (array) $_POST['filter_pubPages'],
]; ];
$core->blog->settings->addNamespace('enhancePostContent'); dcCore::app()->blog->settings->addNamespace('enhancePostContent');
$core->blog->settings->enhancePostContent->put('enhancePostContent_' . $filter->id(), serialize($f)); dcCore::app()->blog->settings->enhancePostContent->put('enhancePostContent_' . $filter->id(), serialize($f));
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Filter successfully updated.') __('Filter successfully updated.')
); );
$core->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugin.enhancePostContent', 'admin.plugin.enhancePostContent',
['part' => $part], ['part' => $part],
'#settings' '#settings'
@ -89,13 +89,13 @@ try {
} else { } else {
$records->addRecord($cur); $records->addRecord($cur);
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Filter successfully updated.') __('Filter successfully updated.')
); );
} }
$core->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugin.enhancePostContent', 'admin.plugin.enhancePostContent',
['part' => $part], ['part' => $part],
'#record' '#record'
@ -110,7 +110,7 @@ try {
$records->delRecord($id); $records->delRecord($id);
} }
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Filter successfully updated.') __('Filter successfully updated.')
@ -119,7 +119,7 @@ try {
if (!empty($_REQUEST['redir'])) { if (!empty($_REQUEST['redir'])) {
http::redirect($_REQUEST['redir']); http::redirect($_REQUEST['redir']);
} else { } else {
$core->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugin.enhancePostContent', 'admin.plugin.enhancePostContent',
['part' => $part], ['part' => $part],
'#record' '#record'
@ -127,13 +127,13 @@ try {
} }
} }
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
# -- Prepare page -- # -- Prepare page --
if ($filter->has_list) { if ($filter->has_list) {
$sorts = new adminGenericFilter($core, 'epc'); $sorts = new adminGenericFilter(dcCore::app(), 'epc');
$sorts->add(dcAdminFilters::getPageFilter()); $sorts->add(dcAdminFilters::getPageFilter());
$sorts->add('part', $part); $sorts->add('part', $part);
@ -143,12 +143,12 @@ if ($filter->has_list) {
try { try {
$list = $records->getRecords($params); $list = $records->getRecords($params);
$counter = $records->getRecords($params, true); $counter = $records->getRecords($params, true);
$pager = new adminEpcList($core, $list, $counter->f(0)); $pager = new adminEpcList(dcCore::app(), $list, $counter->f(0));
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
$header = $sorts->js($core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&') . '#record'); $header = $sorts->js(dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&') . '#record');
} }
# -- Display page -- # -- Display page --
@ -161,7 +161,7 @@ dcPage::jsLoad(dcPage::getPF('enhancePostContent/js/index.js')) .
$header . $header .
# --BEHAVIOR-- enhancePostContentAdminHeader # --BEHAVIOR-- enhancePostContentAdminHeader
$core->callBehavior('enhancePostContentAdminHeader', $core) . ' dcCore::app()->callBehavior('enhancePostContentAdminHeader') . '
</head><body>' . </head><body>' .
@ -169,12 +169,12 @@ $core->callBehavior('enhancePostContentAdminHeader', $core) . '
dcPage::breadcrumb([ dcPage::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
__('Enhance post content') => '', __('Enhance post content') => '',
$filter->name => '' $filter->name => '',
]) . ]) .
dcPage::notices() . dcPage::notices() .
# Filters select menu list # Filters select menu list
'<form method="get" action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '" id="filters_menu">' . '<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '" id="filters_menu">' .
'<p class="anchor-nav"><label for="part" class="classic">' . __('Select filter:') . ' </label>' . '<p class="anchor-nav"><label for="part" class="classic">' . __('Select filter:') . ' </label>' .
form::combo('part', $filters_combo, $part) . ' ' . form::combo('part', $filters_combo, $part) . ' ' .
'<input type="submit" value="' . __('Ok') . '" />' . '<input type="submit" value="' . __('Ok') . '" />' .
@ -189,7 +189,7 @@ echo '
# Filter settings # Filter settings
echo ' echo '
<div class="multi-part" id="setting" title="' . __('Settings') . '"> <div class="multi-part" id="setting" title="' . __('Settings') . '">
<form method="post" action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#setting"> <form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#setting">
<div class="two-boxes odd"> <div class="two-boxes odd">
<h4>' . __('Pages to be filtered') . '</h4>'; <h4>' . __('Pages to be filtered') . '</h4>';
@ -265,7 +265,7 @@ form::field('filter_notag', 60, 255, html::escapeHTML($filter->notag)) . '
</div> </div>
<div class="clear"> <div class="clear">
<p>' . <p>' .
$core->formNonce() . dcCore::app()->formNonce() .
form::hidden(['action'], 'savefiltersetting') . form::hidden(['action'], 'savefiltersetting') .
form::hidden(['part'], $part) . ' form::hidden(['part'], $part) . '
<input type="submit" name="save" value="' . __('Save') . '" /> <input type="submit" name="save" value="' . __('Save') . '" />
@ -276,8 +276,8 @@ form::hidden(['part'], $part) . '
</div>'; </div>';
# Filter records list # Filter records list
if ($filter->has_list) { if ($filter->has_list && isset($sorts) && isset($pager)) {
$pager_url = $core->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])) . '&page=%s#record'; $pager_url = dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])) . '&page=%s#record';
echo ' echo '
<div class="multi-part" id="record" title="' . __('Records') . '">'; <div class="multi-part" id="record" title="' . __('Records') . '">';
@ -287,7 +287,7 @@ if ($filter->has_list) {
$pager->display( $pager->display(
$sorts, $sorts,
$pager_url, $pager_url,
'<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' . '<form action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' .
'%s' . '%s' .
'<div class="two-cols">' . '<div class="two-cols">' .
@ -296,9 +296,9 @@ if ($filter->has_list) {
'<p class="col right">' . '<p class="col right">' .
form::hidden('action', 'deleterecords') . form::hidden('action', 'deleterecords') .
'<input id="del-action" type="submit" name="save" value="' . __('Delete selected records') . '" /></p>' . '<input id="del-action" type="submit" name="save" value="' . __('Delete selected records') . '" /></p>' .
$core->adminurl->getHiddenFormFields('admin.plugin.enhancePostContent', array_merge(['p' => 'enhancePostContent'], $sorts->values(true))) . dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.enhancePostContent', array_merge(['p' => 'enhancePostContent'], $sorts->values(true))) .
form::hidden('redir', $core->adminurl->get('admin.plugin.enhancePostContent', $sorts->values(true))) . form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', $sorts->values(true))) .
$core->formNonce() . dcCore::app()->formNonce() .
'</div>' . '</div>' .
'</form>' '</form>'
); );
@ -308,7 +308,7 @@ if ($filter->has_list) {
# New record # New record
echo ' echo '
<div class="multi-part" id="newrecord" title="' . __('New record') . '"> <div class="multi-part" id="newrecord" title="' . __('New record') . '">
<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-create">' . <form action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-create">' .
'<p><label for="new_key">' . __('Key:') . '</label>' . '<p><label for="new_key">' . __('Key:') . '</label>' .
form::field('new_key', 60, 255, ['extra_html' => 'required']) . form::field('new_key', 60, 255, ['extra_html' => 'required']) .
@ -321,7 +321,7 @@ if ($filter->has_list) {
<p class="clear">' . <p class="clear">' .
form::hidden(['action'], 'savenewrecord') . form::hidden(['action'], 'savenewrecord') .
form::hidden(['part'], $part) . form::hidden(['part'], $part) .
$core->formNonce() . ' dcCore::app()->formNonce() . '
<input id="new-action" type="submit" name="save" value="' . __('Save') . '" /> <input id="new-action" type="submit" name="save" value="' . __('Save') . '" />
</p> </p>
</form> </form>
@ -329,7 +329,7 @@ if ($filter->has_list) {
} }
# --BEHAVIOR-- enhancePostContentAdminPage # --BEHAVIOR-- enhancePostContentAdminPage
$core->callBehavior('enhancePostContentAdminPage', $core); dcCore::app()->callBehavior('enhancePostContentAdminPage');
dcPage::helpBlock('enhancePostContent'); dcPage::helpBlock('enhancePostContent');