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 GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -29,7 +28,9 @@ try {
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
));
}
@ -82,7 +83,8 @@ try {
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, '>=')) {

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -20,7 +19,6 @@ require dirname(__FILE__) . '/_widgets.php';
$core->blog->settings->addNamespace('enhancePostContent');
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
$core->addBehavior(
'publicHeadContent',
['publicEnhancePostContent', 'publicHeadContent']
@ -63,13 +61,12 @@ class publicEnhancePostContent
$styles = $filter->style;
$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";
}
}

View File

@ -10,49 +10,72 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return;
}
$this->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')
/* type */
'versions',
/* action */
'delete',
/* ns */
'enhancePostContent',
/* description */
sprintf(__('delete %s version number'), 'enhancePostContent')
);

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -162,8 +161,7 @@ class enhancePostContentWidget
continue;
}
$res .=
'<li>' . $line['matches'][0]['match'] .
$res .= '<li>' . $line['matches'][0]['match'] .
($w->show_total ? ' (' . $line['total'] . ')' : '') .
'</li>';
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
abstract class epcFilter
{
public $core;
@ -89,6 +88,7 @@ abstract class epcFilter
$this->properties[$k] = $v;
}
}
return true;
}
@ -105,6 +105,7 @@ abstract class epcFilter
$this->settings[$k] = $v;
}
}
return true;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class epcFilterTag extends epcFilter
{
protected function init(): string

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -47,9 +46,9 @@ class adminEpcList extends adminGenericList
'date' => '<th scope="col">' . __('Date') . '</th>'
];
$html_block =
'<div class="table-outer"><table><caption>' .
($filter->show() ?
$html_block = '<div class="table-outer"><table><caption>' .
(
$filter->show() ?
sprintf(__('List of %s records matching the filter.'), $this->rs_count) :
sprintf(__('List of %s records.'), $this->rs_count)
) . '</caption>' .

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
# l10n
__('entry excerpt');__('entry content');__('comment content');
__('home page');__('post page');__('category page');__('search results page');
@ -110,7 +109,7 @@ class libEPC
$core->callBehavior('enhancePostContentFilters', $filters, $core);
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;
$final[$filter->id()] = $filter;
}
@ -198,6 +197,7 @@ class libEPC
$m[$loop]['num'] = $count;
$loop++;
}
return ['total' => $t, 'matches' => $m];
}
@ -229,6 +229,7 @@ class libEPC
foreach ($a as $k => $v) {
$r .= $k . ':' . $v . ';';
}
return $r;
}
@ -263,6 +264,7 @@ class libEPC
$r[$key] = $val;
}
return $r;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class epcRecords
{
public $core;
@ -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'] . ' ';
@ -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

View File

@ -10,10 +10,9 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
# Move old filters lists from settings to database
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()) {
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->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->update("WHERE epc_id = " . $rs->epc_id . " ");
$cur->update('WHERE epc_id = ' . $rs->epc_id . ' ');
$core->blog->triggerBlog();
}
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -145,7 +144,6 @@ if ($filter->has_list) {
$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());
}
@ -286,7 +284,9 @@ if ($filter->has_list) {
$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">' .
'%s' .