diff --git a/_admin.php b/_admin.php
index bb7b459..641a7fb 100644
--- a/_admin.php
+++ b/_admin.php
@@ -1,16 +1,15 @@
register('enhancePostContent', [
- 'title' => __('Enhance post content'),
- 'url' => 'plugin.php?p=enhancePostContent',
- 'small-icon' => 'index.php?pf=enhancePostContent/icon.png',
- 'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png',
+ 'title' => __('Enhance post content'),
+ 'url' => 'plugin.php?p=enhancePostContent',
+ 'small-icon' => 'index.php?pf=enhancePostContent/icon.png',
+ 'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png',
'permissions' => $core->auth->check('contentadmin', $core->blog->id),
- 'active_cb' => [
- 'epcAdminBehaviors',
+ 'active_cb' => [
+ 'epcAdminBehaviors',
'adminDashboardFavoritesActive'
]
]);
@@ -67,38 +66,38 @@ class epcAdminBehaviors
public static function adminDashboardFavoritesActive($request, $params)
{
- return $request == 'plugin.php'
- && isset($params['p'])
+ return $request == 'plugin.php'
+ && isset($params['p'])
&& $params['p'] == 'enhancePostContent';
}
public static function sortbyCombo()
{
return [
- __('Date') => 'epc_upddt',
- __('Key') => 'epc_key',
+ __('Date') => 'epc_upddt',
+ __('Key') => 'epc_key',
__('Value') => 'epc_value',
- __('ID') => 'epc_id'
+ __('ID') => 'epc_id'
];
}
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
{
- $active = (boolean) $blog_settings->enhancePostContent->enhancePostContent_active;
- $allowedtplvalues = libEPC::blogAllowedTplValues();
- $allowedpubpages = libEPC::blogAllowedPubPages();
+ $active = (boolean) $blog_settings->enhancePostContent->enhancePostContent_active;
+ $allowedtplvalues = libEPC::blogAllowedTplValues();
+ $allowedpubpages = libEPC::blogAllowedPubPages();
echo
- '
' . __('Enhance post content') .'
' .
+ '
' . __('Enhance post content') . '
' .
'
' .
'
' .
'
' .
@@ -112,15 +111,15 @@ class epcAdminBehaviors
'
' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '
' .
'
' .
'
' .
- '
' .
+ '
' .
'
';
}
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings)
{
- $active = !empty($_POST['epc_active']);
+ $active = !empty($_POST['epc_active']);
$allowedtplvalues = libEPC::explode($_POST['epc_allowedtplvalues']);
- $allowedpubpages = libEPC::explode($_POST['epc_allowedpubpages']);
+ $allowedpubpages = libEPC::explode($_POST['epc_allowedpubpages']);
$blog_settings->enhancePostContent->put('enhancePostContent_active', $active);
$blog_settings->enhancePostContent->put('enhancePostContent_allowedtplvalues', serialize($allowedtplvalues));
@@ -137,4 +136,4 @@ class epcAdminBehaviors
[__('records per page'), 20]
];
}
-}
\ No newline at end of file
+}
diff --git a/_define.php b/_define.php
index 95fd1e2..1823173 100644
--- a/_define.php
+++ b/_define.php
@@ -1,16 +1,15 @@
registerModule(
'Jean-Christian Denis and Contributors',
'2021.09.05.1',
[
- 'requires' => [['core', '2.19']],
+ 'requires' => [['core', '2.19']],
'permissions' => 'contentadmin',
- 'type' => 'plugin',
- 'support' => 'https://github.com/JcDenis/enhancePostContent',
- 'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent',
- 'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml',
- 'settings' => [
+ 'type' => 'plugin',
+ 'support' => 'https://github.com/JcDenis/enhancePostContent',
+ 'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent',
+ 'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml',
+ 'settings' => [
'blog' => '#params.epc_params'
]
]
-);
\ No newline at end of file
+);
diff --git a/_install.php b/_install.php
index 95fa63d..07530b8 100644
--- a/_install.php
+++ b/_install.php
@@ -1,22 +1,21 @@
plugins->moduleInfo($mod_id, 'version');
$old_version = $core->getVersion($mod_id);
@@ -26,18 +25,20 @@ if (version_compare($old_version, $new_version, '>=')) {
try {
# Check Dotclear version
- if (!method_exists('dcUtils', 'versionsCompare')
+ if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
- '%s requires Dotclear %s', $mod_id, $dc_min
+ '%s requires Dotclear %s',
+ $mod_id,
+ $dc_min
));
}
# Database
$s = new dbStruct($core->con, $core->prefix);
$s->epc
- ->epc_id ('bigint', 0, false)
- ->blog_id ('varchar', 32, false)
+ ->epc_id('bigint', 0, false)
+ ->blog_id('varchar', 32, false)
->epc_type('varchar', 32, false, "'epc'")
->epc_filter('varchar', 64, false)
->epc_key('varchar', 255, false)
@@ -50,15 +51,15 @@ try {
->index('idx_epc_filter', 'btree', 'epc_filter')
->index('idx_epc_key', 'btree', 'epc_key');
- $si = new dbStruct($core->con, $core->prefix);
+ $si = new dbStruct($core->con, $core->prefix);
$changes = $si->synchronize($s);
- $s = null;
+ $s = null;
# Settings
$core->blog->settings->addNamespace($mod_id);
$s = $core->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_order', 'desc', 'string', 'Admin records list order', false, true);
$s->put('enhancePostContent_list_nb', 20, 'integer', 'Admin records list nb per page', false, true);
@@ -67,7 +68,7 @@ try {
# Filters settings
$filters = libEPC::getFilters();
- foreach($filters as $id => $filter) {
+ foreach ($filters as $id => $filter) {
# Only editable options
$opt = [
'nocase' => $filter->nocase,
@@ -78,11 +79,12 @@ try {
'pubPages' => $filter->pubPages
];
$s->put('enhancePostContent_' . $id, serialize($opt), 'string', 'Settings for ' . $id, false, true);
-/* # only tables
- if (isset($filter['list'])) {
- $s->put('enhancePostContent_' . $id . 'List', serialize($filter['list']), 'string', 'List for ' . $id, false, true);
- }
-*/ }
+ /* # only tables
+ if (isset($filter['list'])) {
+ $s->put('enhancePostContent_' . $id . 'List', serialize($filter['list']), 'string', 'List for ' . $id, false, true);
+ }
+ */
+ }
# Update old versions
if ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
@@ -97,4 +99,4 @@ try {
$core->error->add($e->getMessage());
}
-return false;
\ No newline at end of file
+return false;
diff --git a/_prepend.php b/_prepend.php
index 4dcebbf..7d12179 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -1,16 +1,15 @@
addBehavior('enhancePostContentFilters', ['epcFilter' . $f, 'create']);
}
@@ -45,4 +44,4 @@ $core->url->register(
'epc.css',
'^epc\.css',
['publicEnhancePostContent', 'css']
-);
\ No newline at end of file
+);
diff --git a/_public.php b/_public.php
index d919705..4dfe99d 100644
--- a/_public.php
+++ b/_public.php
@@ -1,16 +1,15 @@
blog->settings->addNamespace('enhancePostContent');
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
-
$core->addBehavior(
'publicHeadContent',
['publicEnhancePostContent', 'publicHeadContent']
@@ -40,7 +38,7 @@ class publicEnhancePostContent
{
/**
* Add filters CSS to page header
- *
+ *
* @param dcCore $core dcCore instance
*/
public static function publicHeadContent(dcCore $core)
@@ -50,26 +48,25 @@ class publicEnhancePostContent
public static function css($args)
{
- $css = [];
+ $css = [];
$filters = libEPC::getFilters();
- foreach($filters as $id => $filter) {
+ foreach ($filters as $id => $filter) {
if ('' != $filter->class || '' != $filter->style) {
continue;
}
$res = '';
- foreach($filter->class as $k => $class) {
+ foreach ($filter->class as $k => $class) {
$styles = $filter->style;
- $style = html::escapeHTML(trim($styles[$k]));
+ $style = html::escapeHTML(trim($styles[$k]));
if ('' != $style) {
- $res .= $class . " {" . $style . "} ";
+ $res .= $class . ' {' . $style . '} ';
}
}
if (!empty($res)) {
- $css[] =
- "/* CSS for enhancePostContent " . $id . " */ \n" . $res . "\n";
+ $css[] = '/* CSS for enhancePostContent ' . $id . " */ \n" . $res . "\n";
}
}
@@ -82,7 +79,7 @@ class publicEnhancePostContent
/**
* Filter template blocks content
- *
+ *
* @param dcCore $core dcCore instance
* @param string $tag Tempalte block name
* @param array $args Tempalte Block arguments
@@ -91,11 +88,11 @@ class publicEnhancePostContent
{
$filters = libEPC::getFilters();
- foreach($filters as $id => $filter) {
+ foreach ($filters as $id => $filter) {
if (!libEPC::testContext($tag, $args, $filter)) {
continue;
}
$filter->publicContent($tag, $args);
}
}
-}
\ No newline at end of file
+}
diff --git a/_uninstall.php b/_uninstall.php
index c8f5748..0f534ad 100644
--- a/_uninstall.php
+++ b/_uninstall.php
@@ -1,58 +1,81 @@
addUserAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ 'enhancePostContent',
- /* description */ __('delete all settings')
+ /* type */
+ 'settings',
+ /* action */
+ 'delete_all',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ __('delete all settings')
);
$this->addUserAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ 'enhancePostContent',
- /* description */ __('delete plugin files')
+ /* type */
+ 'plugins',
+ /* action */
+ 'delete',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ __('delete plugin files')
);
$this->addUserAction(
- /* type */ 'versions',
- /* action */ 'delete',
- /* ns */ 'enhancePostContent',
- /* description */ __('delete the version number')
+ /* type */
+ 'versions',
+ /* action */
+ 'delete',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ __('delete the version number')
);
$this->addDirectAction(
- /* type */ 'settings',
- /* action */ 'delete_all',
- /* ns */ 'enhancePostContent',
- /* description */ sprintf(__('delete all %s settings'), 'enhancePostContent')
+ /* type */
+ 'settings',
+ /* action */
+ 'delete_all',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ sprintf(__('delete all %s settings'), 'enhancePostContent')
);
$this->addDirectAction(
- /* type */ 'plugins',
- /* action */ 'delete',
- /* ns */ 'enhancePostContent',
- /* description */ sprintf(__('delete %s plugin files'), 'enhancePostContent')
+ /* type */
+ 'plugins',
+ /* action */
+ 'delete',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ sprintf(__('delete %s plugin files'), 'enhancePostContent')
);
$this->addDirectAction(
- /* type */ 'versions',
- /* action */ 'delete',
- /* ns */ 'enhancePostContent',
- /* description */ sprintf(__('delete %s version number'), 'enhancePostContent')
-);
\ No newline at end of file
+ /* type */
+ 'versions',
+ /* action */
+ 'delete',
+ /* ns */
+ 'enhancePostContent',
+ /* description */
+ sprintf(__('delete %s version number'), 'enhancePostContent')
+);
diff --git a/_widgets.php b/_widgets.php
index 371d11c..d2327b7 100644
--- a/_widgets.php
+++ b/_widgets.php
@@ -1,16 +1,15 @@
$filter) {
+ $types = [];
+ foreach ($filters as $id => $filter) {
$types[$filter->name] = $id;
}
$w->epclist->setting(
@@ -67,7 +66,7 @@ class enhancePostContentWidget
);
# Content
$contents = libEPC::defaultAllowedWidgetValues();
- foreach($contents as $k => $v) {
+ foreach ($contents as $k => $v) {
$w->epclist->setting(
'content' . $v['id'],
sprintf(__('Enable filter on %s'), __($k)),
@@ -105,7 +104,7 @@ class enhancePostContentWidget
/**
* Public part for widget that show extracted content
- *
+ *
* @param dcWidget $w dcWidget instance
*/
public static function publicContentList($w)
@@ -127,7 +126,7 @@ class enhancePostContentWidget
# Content
$content = '';
- foreach(libEPC::defaultAllowedWidgetValues() as $k => $v) {
+ foreach (libEPC::defaultAllowedWidgetValues() as $k => $v) {
$ns = 'content' . $v['id'];
if ($w->$ns && is_callable($v['cb'])) {
$content .= call_user_func_array(
@@ -142,7 +141,7 @@ class enhancePostContentWidget
}
# Filter
- $list = [];
+ $list = [];
$filters = libEPC::getFilters();
if (isset($filters[$w->type])) {
@@ -157,14 +156,13 @@ class enhancePostContentWidget
# Parse result
$res = '';
- foreach($list as $line) {
+ foreach ($list as $line) {
if (empty($line['matches'][0]['match'])) {
continue;
}
- $res .=
- '
' . $line['matches'][0]['match'] .
- ($w->show_total ? ' (' . $line['total'] .')' : '') .
+ $res .= '' . $line['matches'][0]['match'] .
+ ($w->show_total ? ' (' . $line['total'] . ')' : '') .
'';
}
@@ -173,12 +171,12 @@ class enhancePostContentWidget
}
return $w->renderDiv(
- $w->content_only,
- $w->class,
- 'id="epc_' . $w->type .'"',
+ $w->content_only,
+ $w->class,
+ 'id="epc_' . $w->type . '"',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
($w->text ? '
' . html::escapeHTML($w->text) . '
' : '') .
'
'
);
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.filter.php b/inc/lib.epc.filter.php
index 413fce5..e72464f 100644
--- a/inc/lib.epc.filter.php
+++ b/inc/lib.epc.filter.php
@@ -1,21 +1,20 @@
core = $core;
- $this->id = $this->init();
+ $this->id = $this->init();
$this->blogSettings();
}
@@ -84,11 +83,12 @@ abstract class epcFilter
final protected function setProperties($property, $value = null): bool
{
$properties = is_array($property) ? $property : [$property => $value];
- foreach($properties as $k => $v) {
+ foreach ($properties as $k => $v) {
if (isset($this->properties[$k])) {
$this->properties[$k] = $v;
}
}
+
return true;
}
@@ -100,17 +100,18 @@ abstract class epcFilter
final protected function setSettings($setting, $value = null): bool
{
$settings = is_array($setting) ? $setting : [$setting => $value];
- foreach($settings as $k => $v) {
+ foreach ($settings as $k => $v) {
if (isset($this->settings[$k])) {
$this->settings[$k] = $v;
}
}
+
return true;
}
private function blogSettings()
{
- $ns = 'enhancePostContent_' . $this->id;
+ $ns = 'enhancePostContent_' . $this->id;
$opt = @unserialize($this->core->blog->settings->enhancePostContent->$ns);
if (!is_array($opt)) {
@@ -142,7 +143,7 @@ abstract class epcFilter
final public function records()
{
if ($this->records === null && $this->has_list) {
- $records = new epcRecords($this->core);
+ $records = new epcRecords($this->core);
$this->records = $records->getRecords(['epc_filter' => $this->id()]);
}
@@ -160,4 +161,4 @@ abstract class epcFilter
{
return null;
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.filters.php b/inc/lib.epc.filters.php
index 82f358f..2c52786 100644
--- a/inc/lib.epc.filters.php
+++ b/inc/lib.epc.filters.php
@@ -1,16 +1,15 @@
core->meta->getMetadata(['meta_type' => 'tag']);
- while($metas->fetch()) {
+ while ($metas->fetch()) {
$args[0] = libEPC::replaceString(
$metas->meta_id,
sprintf($this->replace, $this->core->blog->url . $this->core->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
@@ -63,7 +62,7 @@ class epcFilterTag extends epcFilter
$metas = $this->core->meta->getMetadata(['meta_type' => 'tag']);
- while($metas->fetch()) {
+ while ($metas->fetch()) {
$list[] = libEPC::matchString(
$metas->meta_id,
sprintf($this->widget, $this->core->blog->url . $this->core->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
@@ -109,7 +108,7 @@ class epcFilterSearch extends epcFilter
$searchs = explode(' ', $GLOBALS['_search']);
- foreach($searchs as $k => $v) {
+ foreach ($searchs as $k => $v) {
$args[0] = libEPC::replaceString(
$v,
sprintf($this->replace, '\\1'),
@@ -149,7 +148,7 @@ class epcFilterAcronym extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
@@ -163,8 +162,8 @@ class epcFilterAcronym extends epcFilter
public function widgetList($content, $w, &$list)
{
- while($this->records()->fetch()) {
- $list[] = libEPC::matchString(
+ while ($this->records()->fetch()) {
+ $list[] = libEPC::matchString(
$this->records()->epc_key,
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
$content,
@@ -188,7 +187,7 @@ class epcFilterAbbreviation extends epcFilter
'htmltag' => 'a',
'class' => ['abbr.epc-abbr'],
'replace' => '
%s',
- 'widget' => '
%s'
+ 'widget' => '
%s'
]);
$this->setSettings([
@@ -203,7 +202,7 @@ class epcFilterAbbreviation extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
@@ -217,7 +216,7 @@ class epcFilterAbbreviation extends epcFilter
public function widgetList($content, $w, &$list)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$list[] = libEPC::matchString(
$this->records()->epc_key,
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
@@ -242,7 +241,7 @@ class epcFilterDefinition extends epcFilter
'htmltag' => 'dfn',
'class' => ['dfn.epc-dfn'],
'replace' => '
%s',
- 'widget' => '
%s'
+ 'widget' => '
%s'
]);
$this->setSettings([
@@ -257,7 +256,7 @@ class epcFilterDefinition extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
@@ -271,7 +270,7 @@ class epcFilterDefinition extends epcFilter
public function widgetList($content, $w, &$list)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$list[] = libEPC::matchString(
$this->records()->epc_key,
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
@@ -312,7 +311,7 @@ class epcFilterCitation extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
@@ -326,7 +325,7 @@ class epcFilterCitation extends epcFilter
public function widgetList($content, $w, &$list)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$list[] = libEPC::matchString(
$this->records()->epc_key,
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
@@ -366,7 +365,7 @@ class epcFilterLink extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, '\\1', $this->records()->epc_value, '\\1'),
@@ -380,7 +379,7 @@ class epcFilterLink extends epcFilter
public function widgetList($content, $w, &$list)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$list[] = libEPC::matchString(
$this->records()->epc_key,
sprintf($this->widget, $this->records()->epc_value, $this->records()->epc_value, '\\1'),
@@ -421,7 +420,7 @@ class epcFilterReplace extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, $this->records()->epc_value, '\\2'),
@@ -462,7 +461,7 @@ class epcFilterUpdate extends epcFilter
public function publicContent($tag, $args)
{
- while($this->records()->fetch()) {
+ while ($this->records()->fetch()) {
$args[0] = libEPC::replaceString(
$this->records()->epc_key,
sprintf($this->replace, '\\1', $this->records()->epc_value),
@@ -511,4 +510,4 @@ class epcFilterTwitter extends epcFilter
return null;
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.pager.php b/inc/lib.epc.pager.php
index d15eb3e..0a959e1 100644
--- a/inc/lib.epc.pager.php
+++ b/inc/lib.epc.pager.php
@@ -1,16 +1,15 @@
rs->isEmpty()) {
if ($filter->show()) {
@@ -31,7 +30,7 @@ class adminEpcList extends adminGenericList
echo '
' . __('No record') . '
';
}
} else {
- $pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
+ $pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
$pager->base_url = $pager_url;
$epc_id = [];
@@ -47,12 +46,12 @@ class adminEpcList extends adminGenericList
'date' => '
' . __('Date') . ' | '
];
- $html_block =
- '
' .
- ($filter->show() ?
+ $html_block = '' .
+ (
+ $filter->show() ?
sprintf(__('List of %s records matching the filter.'), $this->rs_count) :
sprintf(__('List of %s records.'), $this->rs_count)
- ). '' .
+ ) . '' .
'' . implode($cols) . '
%s
%s
';
if ($enclose_block) {
@@ -73,15 +72,15 @@ class adminEpcList extends adminGenericList
private function line($checked)
{
$cols = [
- 'check' => '' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . ' | ',
+ 'check' => '' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . ' | ',
'key' => '' . html::escapeHTML($this->rs->epc_key) . ' | ',
'value' => '' . html::escapeHTML($this->rs->epc_value) . ' | ',
'date' => '' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . ' | '
];
- return
+ return
'' .
- implode($cols) .
+ implode($cols) .
'
';
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.php b/inc/lib.epc.php
index 3cec725..01a81ea 100644
--- a/inc/lib.epc.php
+++ b/inc/lib.epc.php
@@ -1,16 +1,15 @@
callBehavior('enhancePostContentFilters', $filters, $core);
- foreach($filters as $filter) {
- if ($filter instanceOf epcFilter && !isset($final[$filter->id()])) {
- $sort[$filter->id()] = $filter->priority;
+ foreach ($filters as $filter) {
+ if ($filter instanceof epcFilter && !isset($final[$filter->id()])) {
+ $sort[$filter->id()] = $filter->priority;
$final[$filter->id()] = $filter;
}
}
@@ -127,10 +126,10 @@ class libEPC
public static function testContext($tag, $args, $filter)
{
- return is_array($filter->pubPages)
- && in_array($GLOBALS['_ctx']->current_tpl,$filter->pubPages)
- && is_array($filter->tplValues)
- && in_array($tag, $filter->tplValues)
+ return is_array($filter->pubPages)
+ && in_array($GLOBALS['_ctx']->current_tpl, $filter->pubPages)
+ && is_array($filter->tplValues)
+ && in_array($tag, $filter->tplValues)
&& $args[0] != '' //content
&& empty($args[2]) // remove html
;
@@ -158,7 +157,7 @@ class libEPC
return $s;
}
# Remove words that are into unwanted html tags
- $tags = '';
+ $tags = '';
$ignore_tags = array_merge(self::decodeTags($filter->htmltag), self::decodeTags($filter->notag));
if (is_array($ignore_tags) && !empty($ignore_tags)) {
$tags = implode('|', $ignore_tags);
@@ -190,14 +189,15 @@ class libEPC
}
# Build array
- $m = [];
+ $m = [];
$loop = 0;
- foreach($matches[1] as $match) {
- $m[$loop]['key'] = $match;
+ foreach ($matches[1] as $match) {
+ $m[$loop]['key'] = $match;
$m[$loop]['match'] = preg_replace('#(' . $p . '(s|))#s' . $i, $r, $match, -1, $count);
- $m[$loop]['num'] = $count;
+ $m[$loop]['num'] = $count;
$loop++;
}
+
return ['total' => $t, 'matches' => $m];
}
@@ -226,9 +226,10 @@ class libEPC
}
$r = '';
- foreach($a as $k => $v) {
+ foreach ($a as $k => $v) {
$r .= $k . ':' . $v . ';';
}
+
return $r;
}
@@ -247,7 +248,7 @@ class libEPC
return [];
}
- foreach($s as $cpl) {
+ foreach ($s as $cpl) {
$cur = explode(':', $cpl);
if (!is_array($cur) || !isset($cur[1])) {
@@ -263,6 +264,7 @@ class libEPC
$r[$key] = $val;
}
+
return $r;
}
@@ -310,7 +312,7 @@ class libEPC
return null;
}
- $res = '';
+ $res = '';
$post_ids = [];
while ($_ctx->posts->fetch()) {
$comments = $core->blog->getComments(['post_id' => $_ctx->posts->post_id]);
@@ -321,4 +323,4 @@ class libEPC
return $res;
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.records.php b/inc/lib.epc.records.php
index fb5c4bd..456887f 100644
--- a/inc/lib.epc.records.php
+++ b/inc/lib.epc.records.php
@@ -1,16 +1,15 @@
core = $core;
- $this->con = $core->con;
+ $this->core = $core;
+ $this->con = $core->con;
$this->table = $core->prefix . 'epc';
- $this->blog = $core->con->escape($core->blog->id);
+ $this->blog = $core->con->escape($core->blog->id);
}
public function getRecords($params, $count_only = false)
@@ -35,14 +34,12 @@ class epcRecords
if (!empty($params['columns']) && is_array($params['columns'])) {
$content_req .= implode(', ', $params['columns']) . ', ';
}
- $strReq =
- 'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, ' .
+ $strReq = 'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, ' .
$content_req .
'E.epc_filter, E.epc_key, E.epc_value ';
}
- $strReq .=
- 'FROM ' . $this->table . ' E ';
+ $strReq .= 'FROM ' . $this->table . ' E ';
if (!empty($params['from'])) {
$strReq .= $params['from'] . ' ';
@@ -70,7 +67,7 @@ class epcRecords
if (!empty($params['epc_id'])) {
if (is_array($params['epc_id'])) {
- array_walk($params['epc_id'], function(&$v, $k) { if ($v !==null) { $v = (integer) $v; }});
+ array_walk($params['epc_id'], function (&$v, $k) { if ($v !== null) { $v = (integer) $v; }});
} else {
$params['epc_id'] = [(integer) $params['epc_id']];
}
@@ -111,8 +108,8 @@ class epcRecords
$this->con->writeLock($this->table);
try {
- $cur->epc_id = $this->getNextId();
- $cur->blog_id = $this->blog;
+ $cur->epc_id = $this->getNextId();
+ $cur->blog_id = $this->blog;
$cur->epc_upddt = date('Y-m-d H:i:s');
$this->getCursor($cur);
@@ -121,6 +118,7 @@ class epcRecords
$this->con->unlock();
} catch (Exception $e) {
$this->con->unlock();
+
throw $e;
}
$this->trigger();
@@ -141,7 +139,7 @@ class epcRecords
$cur->epc_upddt = date('Y-m-d H:i:s');
- $cur->update("WHERE epc_id = " . $id . " AND blog_id = '" . $this->blog . "' ");
+ $cur->update('WHERE epc_id = ' . $id . " AND blog_id = '" . $this->blog . "' ");
$this->trigger();
# --BEHAVIOR-- enhancePostContentAfterUpdRecord
@@ -151,10 +149,10 @@ class epcRecords
public function isRecord($filter, $key, $not_id = null)
{
return 0 < $this->getRecords([
- 'epc_filter' => $filter,
- 'epc_key' => $key,
- 'not_id' => $not_id
- ], true)->f(0);
+ 'epc_filter' => $filter,
+ 'epc_key' => $key,
+ 'not_id' => $not_id
+ ], true)->f(0);
}
public function delRecord($id)
@@ -170,7 +168,7 @@ class epcRecords
$this->con->execute(
'DELETE FROM ' . $this->table . ' ' .
- 'WHERE epc_id = ' . $id .' ' .
+ 'WHERE epc_id = ' . $id . ' ' .
"AND blog_id = '" . $this->blog . "' "
);
@@ -207,4 +205,4 @@ class epcRecords
{
$this->core->blog->triggerBlog();
}
-}
\ No newline at end of file
+}
diff --git a/inc/lib.epc.update.php b/inc/lib.epc.update.php
index 6c69439..9a2c600 100644
--- a/inc/lib.epc.update.php
+++ b/inc/lib.epc.update.php
@@ -1,51 +1,50 @@
=')) {
- $f = $core->con->select("SELECT * FROM " . $core->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
+ $f = $core->con->select('SELECT * FROM ' . $core->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
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);
if (is_array($curlist)) {
- foreach($curlist as $k => $v) {
+ foreach ($curlist as $k => $v) {
$cur = $core->con->openCursor($core->prefix . 'epc');
$core->con->writeLock($core->prefix . 'epc');
- $cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM ' . $core->prefix . 'epc' . ' ')->f(0) + 1;
- $cur->blog_id = $f->blog_id;
+ $cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM ' . $core->prefix . 'epc' . ' ')->f(0) + 1;
+ $cur->blog_id = $f->blog_id;
$cur->epc_filter = strtolower($m[1]);
- $cur->epc_key = $k;
- $cur->epc_value = $v;
+ $cur->epc_key = $k;
+ $cur->epc_value = $v;
$cur->insert();
$core->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 . "' ");
+ $core->con->execute('DELETE FROM ' . $core->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, '>=')) {
$rs = $core->con->select('SELECT epc_id, epc_filter FROM ' . $core->prefix . 'epc');
- while($rs->fetch()) {
+ while ($rs->fetch()) {
$cur = $core->con->openCursor($core->prefix . 'epc');
$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();
}
-}
\ No newline at end of file
+}
diff --git a/index.php b/index.php
index c604f0a..618f0a2 100644
--- a/index.php
+++ b/index.php
@@ -1,16 +1,15 @@
$filter) {
- $filters_id[$id] = $filter->name;
+foreach ($_filters as $id => $filter) {
+ $filters_id[$id] = $filter->name;
$filters_combo[$filter->name] = $id;
}
-$action = $_POST['action'] ?? '';
+$action = $_POST['action'] ?? '';
$part = $_REQUEST['part'] ?? key($filters_id);
if (!isset($filters_id[$part])) {
@@ -69,7 +68,7 @@ try {
);
$core->adminurl->redirect(
- 'admin.plugin.enhancePostContent',
+ 'admin.plugin.enhancePostContent',
['part' => $part],
'#settings'
);
@@ -80,7 +79,7 @@ try {
&& !empty($_POST['new_key'])
&& !empty($_POST['new_value'])
) {
- $cur = $records->openCursor();
+ $cur = $records->openCursor();
$cur->epc_filter = $filter->id();
$cur->epc_key = html::escapeHTML($_POST['new_key']);
$cur->epc_value = html::escapeHTML($_POST['new_value']);
@@ -97,17 +96,17 @@ try {
);
}
$core->adminurl->redirect(
- 'admin.plugin.enhancePostContent',
+ 'admin.plugin.enhancePostContent',
['part' => $part],
'#record'
);
}
# Update filter records
- if ($action == 'deleterecords' && $filter->has_list
+ if ($action == 'deleterecords' && $filter->has_list
&& !empty($_POST['epc_id']) && is_array($_POST['epc_id'])
) {
- foreach($_POST['epc_id'] as $id) {
+ foreach ($_POST['epc_id'] as $id) {
$records->delRecord($id);
}
@@ -121,13 +120,13 @@ try {
http::redirect($_REQUEST['redir']);
} else {
$core->adminurl->redirect(
- 'admin.plugin.enhancePostContent',
+ 'admin.plugin.enhancePostContent',
['part' => $part],
'#record'
);
}
}
-} catch(Exception $e) {
+} catch (Exception $e) {
$core->error->add($e->getMessage());
}
@@ -138,19 +137,18 @@ if ($filter->has_list) {
$sorts->add(dcAdminFilters::getPageFilter());
$sorts->add('part', $part);
- $params = $sorts->params();
+ $params = $sorts->params();
$params['epc_filter'] = $filter->id();
try {
$list = $records->getRecords($params);
$counter = $records->getRecords($params, true);
$pager = new adminEpcList($core, $list, $counter->f(0));
-
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
- $header = $sorts->js($core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&').'#record');
+ $header = $sorts->js($core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&') . '#record');
}
# -- Display page --
@@ -196,7 +194,7 @@ echo '
' . __('Pages to be filtered') . '
';
-foreach(libEPC::blogAllowedPubPages() as $k => $v) {
+foreach (libEPC::blogAllowedPubPages() as $k => $v) {
echo '
' . __('Contents to be filtered') . '
';
-foreach(libEPC::blogAllowedTplValues() as $k => $v) {
+foreach (libEPC::blogAllowedTplValues() as $k => $v) {
echo '
' . __('Style') . '
';
-foreach($filter->class as $k => $v) {
+foreach ($filter->class as $k => $v) {
echo '
' .
form::field(
- ['filter_style[]', 'filter_style'.$k],
+ ['filter_style[]', 'filter_style' . $k],
60,
255,
html::escapeHTML($filter->style[$k])
@@ -279,24 +277,26 @@ form::hidden(['part'], $part) . '
# Filter records list
if ($filter->has_list) {
- $pager_url = $core->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])).'&page=%s#record';
+ $pager_url = $core->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])) . '&page=%s#record';
echo '
';
$sorts->display(['admin.plugin.enhancePostContent', '#record'], form::hidden('p', 'enhancePostContent') . form::hidden('part', $part));
- $pager->display($sorts, $pager_url,
+ $pager->display(
+ $sorts,
+ $pager_url,
'