fix PSR coding style

master
Jean-Christian Paul Denis 2021-11-01 10:33:43 +01:00
parent d416fc3c33
commit a10ab12580
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
16 changed files with 283 additions and 268 deletions

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -29,7 +28,9 @@ try {
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s',
$mod_id,
$dc_min
)); ));
} }
@ -82,7 +83,8 @@ try {
if (isset($filter['list'])) { if (isset($filter['list'])) {
$s->put('enhancePostContent_' . $id . 'List', serialize($filter['list']), 'string', 'List for ' . $id, false, true); $s->put('enhancePostContent_' . $id . 'List', serialize($filter['list']), 'string', 'List for ' . $id, false, true);
} }
*/ } */
}
# Update old versions # Update old versions
if ($old_version && version_compare('2021.10.05', $old_version, '>=')) { if ($old_version && version_compare('2021.10.05', $old_version, '>=')) {

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -20,7 +19,6 @@ require dirname(__FILE__) . '/_widgets.php';
$core->blog->settings->addNamespace('enhancePostContent'); $core->blog->settings->addNamespace('enhancePostContent');
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) { if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
$core->addBehavior( $core->addBehavior(
'publicHeadContent', 'publicHeadContent',
['publicEnhancePostContent', 'publicHeadContent'] ['publicEnhancePostContent', 'publicHeadContent']
@ -63,13 +61,12 @@ class publicEnhancePostContent
$styles = $filter->style; $styles = $filter->style;
$style = html::escapeHTML(trim($styles[$k])); $style = html::escapeHTML(trim($styles[$k]));
if ('' != $style) { if ('' != $style) {
$res .= $class . " {" . $style . "} "; $res .= $class . ' {' . $style . '} ';
} }
} }
if (!empty($res)) { if (!empty($res)) {
$css[] = $css[] = '/* CSS for enhancePostContent ' . $id . " */ \n" . $res . "\n";
"/* CSS for enhancePostContent " . $id . " */ \n" . $res . "\n";
} }
} }

View File

@ -10,49 +10,72 @@
* @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 (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return; return;
} }
$this->addUserAction( $this->addUserAction(
/* type */ 'settings', /* type */
/* action */ 'delete_all', 'settings',
/* ns */ 'enhancePostContent', /* action */
/* description */ __('delete all settings') 'delete_all',
/* ns */
'enhancePostContent',
/* description */
__('delete all settings')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'plugins', /* type */
/* action */ 'delete', 'plugins',
/* ns */ 'enhancePostContent', /* action */
/* description */ __('delete plugin files') 'delete',
/* ns */
'enhancePostContent',
/* description */
__('delete plugin files')
); );
$this->addUserAction( $this->addUserAction(
/* type */ 'versions', /* type */
/* action */ 'delete', 'versions',
/* ns */ 'enhancePostContent', /* action */
/* description */ __('delete the version number') 'delete',
/* ns */
'enhancePostContent',
/* description */
__('delete the version number')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'settings', /* type */
/* action */ 'delete_all', 'settings',
/* ns */ 'enhancePostContent', /* action */
/* description */ sprintf(__('delete all %s settings'), 'enhancePostContent') 'delete_all',
/* ns */
'enhancePostContent',
/* description */
sprintf(__('delete all %s settings'), 'enhancePostContent')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'plugins', /* type */
/* action */ 'delete', 'plugins',
/* ns */ 'enhancePostContent', /* action */
/* description */ sprintf(__('delete %s plugin files'), 'enhancePostContent') 'delete',
/* ns */
'enhancePostContent',
/* description */
sprintf(__('delete %s plugin files'), 'enhancePostContent')
); );
$this->addDirectAction( $this->addDirectAction(
/* type */ 'versions', /* type */
/* action */ 'delete', 'versions',
/* ns */ 'enhancePostContent', /* action */
/* description */ sprintf(__('delete %s version number'), 'enhancePostContent') 'delete',
/* ns */
'enhancePostContent',
/* description */
sprintf(__('delete %s version number'), 'enhancePostContent')
); );

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -162,8 +161,7 @@ class enhancePostContentWidget
continue; continue;
} }
$res .= $res .= '<li>' . $line['matches'][0]['match'] .
'<li>' . $line['matches'][0]['match'] .
($w->show_total ? ' (' . $line['total'] . ')' : '') . ($w->show_total ? ' (' . $line['total'] . ')' : '') .
'</li>'; '</li>';
} }

View File

@ -10,7 +10,6 @@
* @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
*/ */
abstract class epcFilter abstract class epcFilter
{ {
public $core; public $core;
@ -89,6 +88,7 @@ abstract class epcFilter
$this->properties[$k] = $v; $this->properties[$k] = $v;
} }
} }
return true; return true;
} }
@ -105,6 +105,7 @@ abstract class epcFilter
$this->settings[$k] = $v; $this->settings[$k] = $v;
} }
} }
return true; return true;
} }

View File

@ -10,7 +10,6 @@
* @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
*/ */
class epcFilterTag extends epcFilter class epcFilterTag extends epcFilter
{ {
protected function init(): string protected function init(): string

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -47,9 +46,9 @@ class adminEpcList extends adminGenericList
'date' => '<th scope="col">' . __('Date') . '</th>' 'date' => '<th scope="col">' . __('Date') . '</th>'
]; ];
$html_block = $html_block = '<div class="table-outer"><table><caption>' .
'<div class="table-outer"><table><caption>' . (
($filter->show() ? $filter->show() ?
sprintf(__('List of %s records matching the filter.'), $this->rs_count) : sprintf(__('List of %s records matching the filter.'), $this->rs_count) :
sprintf(__('List of %s records.'), $this->rs_count) sprintf(__('List of %s records.'), $this->rs_count)
) . '</caption>' . ) . '</caption>' .

View File

@ -10,7 +10,6 @@
* @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
*/ */
# l10n # l10n
__('entry excerpt');__('entry content');__('comment content'); __('entry excerpt');__('entry content');__('comment content');
__('home page');__('post page');__('category page');__('search results page'); __('home page');__('post page');__('category page');__('search results page');
@ -110,7 +109,7 @@ class libEPC
$core->callBehavior('enhancePostContentFilters', $filters, $core); $core->callBehavior('enhancePostContentFilters', $filters, $core);
foreach ($filters as $filter) { foreach ($filters as $filter) {
if ($filter instanceOf epcFilter && !isset($final[$filter->id()])) { if ($filter instanceof epcFilter && !isset($final[$filter->id()])) {
$sort[$filter->id()] = $filter->priority; $sort[$filter->id()] = $filter->priority;
$final[$filter->id()] = $filter; $final[$filter->id()] = $filter;
} }
@ -198,6 +197,7 @@ class libEPC
$m[$loop]['num'] = $count; $m[$loop]['num'] = $count;
$loop++; $loop++;
} }
return ['total' => $t, 'matches' => $m]; return ['total' => $t, 'matches' => $m];
} }
@ -229,6 +229,7 @@ class libEPC
foreach ($a as $k => $v) { foreach ($a as $k => $v) {
$r .= $k . ':' . $v . ';'; $r .= $k . ':' . $v . ';';
} }
return $r; return $r;
} }
@ -263,6 +264,7 @@ class libEPC
$r[$key] = $val; $r[$key] = $val;
} }
return $r; return $r;
} }

View File

@ -10,7 +10,6 @@
* @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
*/ */
class epcRecords class epcRecords
{ {
public $core; public $core;
@ -35,14 +34,12 @@ class epcRecords
if (!empty($params['columns']) && is_array($params['columns'])) { if (!empty($params['columns']) && is_array($params['columns'])) {
$content_req .= implode(', ', $params['columns']) . ', '; $content_req .= implode(', ', $params['columns']) . ', ';
} }
$strReq = $strReq = 'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, ' .
'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, ' .
$content_req . $content_req .
'E.epc_filter, E.epc_key, E.epc_value '; 'E.epc_filter, E.epc_key, E.epc_value ';
} }
$strReq .= $strReq .= 'FROM ' . $this->table . ' E ';
'FROM ' . $this->table . ' E ';
if (!empty($params['from'])) { if (!empty($params['from'])) {
$strReq .= $params['from'] . ' '; $strReq .= $params['from'] . ' ';
@ -121,6 +118,7 @@ class epcRecords
$this->con->unlock(); $this->con->unlock();
} catch (Exception $e) { } catch (Exception $e) {
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
$this->trigger(); $this->trigger();
@ -141,7 +139,7 @@ class epcRecords
$cur->epc_upddt = date('Y-m-d H:i:s'); $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(); $this->trigger();
# --BEHAVIOR-- enhancePostContentAfterUpdRecord # --BEHAVIOR-- enhancePostContentAfterUpdRecord

View File

@ -10,10 +10,9 @@
* @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
*/ */
# 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 = $core->con->select('SELECT * FROM ' . $core->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)) {
@ -33,7 +32,7 @@ if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
$core->con->unlock(); $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 . "' ");
} }
} }
@ -45,7 +44,7 @@ if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
$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(); $core->blog->triggerBlog();
} }
} }

View File

@ -10,7 +10,6 @@
* @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 (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -145,7 +144,6 @@ if ($filter->has_list) {
$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($core, $list, $counter->f(0));
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
@ -286,7 +284,9 @@ if ($filter->has_list) {
$sorts->display(['admin.plugin.enhancePostContent', '#record'], form::hidden('p', 'enhancePostContent') . form::hidden('part', $part)); $sorts->display(['admin.plugin.enhancePostContent', '#record'], form::hidden('p', 'enhancePostContent') . form::hidden('part', $part));
$pager->display($sorts, $pager_url, $pager->display(
$sorts,
$pager_url,
'<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' . '<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' .
'%s' . '%s' .