update to PSR12

This commit is contained in:
Jean-Christian Paul Denis 2021-11-06 16:19:49 +01:00
parent 2a3323b79d
commit 7c0d3f45e5
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
15 changed files with 240 additions and 232 deletions

View File

@ -1,8 +1,11 @@
0.8.1 - dev 0.8.1 - dev
- [ ] orphan media cleaner - [ ] orphan media cleaner
- fix permissions
- move actions to independent tools - move actions to independent tools
- add var folder - add var folder
- update admin page to a lighter interface - update admin page to a lighter interface
- update translation (and remove .lang.php file)
- update to PSR12
0.8 - 2021.09.07 0.8 - 2021.09.07
- update DC official values (themes,settings,tables...) - update DC official values (themes,settings,tables...)

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_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
@ -54,8 +53,7 @@ if (!empty($_POST['save'])) {
'redir' => empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir'] 'redir' => empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir']
] ]
); );
} } catch (Exception $e) {
catch(Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }

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;
} }
@ -47,5 +46,6 @@ try {
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
return false; return false;
} }

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
*/ */
abstract class advancedCleaner abstract class advancedCleaner
{ {
protected $core; protected $core;
@ -32,7 +31,6 @@ abstract class advancedCleaner
$this->core = $core; $this->core = $core;
$this->init(); $this->init();
} }
public static function create(arrayObject $o, dcCore $core) public static function create(arrayObject $o, dcCore $core)
@ -59,6 +57,7 @@ abstract class advancedCleaner
$this->properties[$k] = (string) $v; $this->properties[$k] = (string) $v;
} }
} }
return true; return true;
} }
@ -107,6 +106,7 @@ abstract class advancedCleaner
$i++; $i++;
} }
} }
return $rs; return $rs;
} }
@ -119,9 +119,11 @@ abstract class advancedCleaner
$roots = [$roots]; $roots = [$roots];
} }
foreach ($roots as $root) { foreach ($roots as $root) {
if (file_exists($root . '/' . $folder)) if (file_exists($root . '/' . $folder)) {
return self::delTree($root . '/' . $folder, $delfolder); return self::delTree($root . '/' . $folder, $delfolder);
} }
}
return false; return false;
} }
@ -135,7 +137,7 @@ abstract class advancedCleaner
} }
$files = files::scandir($path); $files = files::scandir($path);
foreach($files AS $file) { foreach ($files as $file) {
if (in_array($file, $exclude)) { if (in_array($file, $exclude)) {
continue; continue;
} }
@ -146,6 +148,7 @@ abstract class advancedCleaner
$res[] = empty($dir) ? $file : $dir . '/' . $file; $res[] = empty($dir) ? $file : $dir . '/' . $file;
} }
} }
return $res; return $res;
} }
@ -163,7 +166,8 @@ abstract class advancedCleaner
while (($entryname = $d->read()) !== false) { while (($entryname = $d->read()) !== false) {
if ($entryname != '.' && $entryname != '..') { if ($entryname != '.' && $entryname != '..') {
if (is_dir($dir . '/' . $entryname)) { if (is_dir($dir . '/' . $entryname)) {
if (!self::delTree($dir . '/' . $entryname)) {return false; if (!self::delTree($dir . '/' . $entryname)) {
return false;
} }
} else { } else {
if (!@unlink($dir . '/' . $entryname)) { if (!@unlink($dir . '/' . $entryname)) {
@ -176,8 +180,8 @@ abstract class advancedCleaner
if ($delroot) { if ($delroot) {
return @rmdir($dir); return @rmdir($dir);
} else { }
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
*/ */
if (!defined('DC_ADMIN_CONTEXT')) { if (!defined('DC_ADMIN_CONTEXT')) {
return null; return null;
} }
@ -29,7 +28,7 @@ class dcAdvancedCleaner
$this->core->callBehavior('advancedCleanerAdd', $cleaners, $this->core); $this->core->callBehavior('advancedCleanerAdd', $cleaners, $this->core);
foreach ($cleaners as $cleaner) { foreach ($cleaners as $cleaner) {
if ($cleaner instanceOf advancedCleaner && !isset($this->cleaners[$cleaner->id])) { if ($cleaner instanceof advancedCleaner && !isset($this->cleaners[$cleaner->id])) {
$this->cleaners[$cleaner->id] = $cleaner; $this->cleaners[$cleaner->id] = $cleaner;
} }
} }
@ -49,6 +48,7 @@ class dcAdvancedCleaner
if ($silent) { if ($silent) {
return false; return false;
} }
throw new exception(sprintf(__('unknow cleaner type %s'), $type)); throw new exception(sprintf(__('unknow cleaner type %s'), $type));
} }
@ -68,6 +68,7 @@ class dcAdvancedCleaner
if ($ret === false) { if ($ret === false) {
$msg = $this->cleaners[$type]->error($action); $msg = $this->cleaners[$type]->error($action);
throw new Exception($msg ?? __('Unknow error')); throw new Exception($msg ?? __('Unknow error'));
} }

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_ADMIN_CONTEXT')) { if (!defined('DC_ADMIN_CONTEXT')) {
return null; return null;
} }
@ -124,7 +123,6 @@ class dcUninstaller
{ {
if (file_exists($root . '/_define.php') if (file_exists($root . '/_define.php')
&& file_exists($root . '/_uninstall.php')) { && file_exists($root . '/_uninstall.php')) {
$this->id = basename($root); $this->id = basename($root);
$this->mroot = $root; $this->mroot = $root;
@ -171,6 +169,7 @@ class dcUninstaller
if ($id && isset($this->modules[$id])) { if ($id && isset($this->modules[$id])) {
return $this->modules[$id]; return $this->modules[$id];
} }
return $this->modules; return $this->modules;
} }
@ -259,6 +258,7 @@ class dcUninstaller
} }
$res[$k] = $this->actions[$group][$id][$k]; $res[$k] = $this->actions[$group][$id][$k];
} }
return $res; return $res;
} }
@ -323,6 +323,7 @@ class dcUninstaller
if (!isset($this->callbacks[$group][$id])) { if (!isset($this->callbacks[$group][$id])) {
return []; return [];
} }
return $this->callbacks[$group][$id]; return $this->callbacks[$group][$id];
} }

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 advancedCleanerSettings extends advancedCleaner class advancedCleanerSettings extends advancedCleaner
{ {
protected function init(): bool protected function init(): bool
@ -68,7 +67,7 @@ class advancedCleanerSettings extends advancedCleaner
'SELECT setting_ns ' . 'SELECT setting_ns ' .
'FROM ' . $this->core->prefix . 'setting ' . 'FROM ' . $this->core->prefix . 'setting ' .
'WHERE blog_id IS NULL ' . 'WHERE blog_id IS NULL ' .
"OR blog_id IS NOT NULL " . 'OR blog_id IS NOT NULL ' .
'GROUP BY setting_ns' 'GROUP BY setting_ns'
); );
@ -79,8 +78,8 @@ class advancedCleanerSettings extends advancedCleaner
$rs[$i]['value'] = $this->core->con->select( $rs[$i]['value'] = $this->core->con->select(
'SELECT count(*) FROM ' . $this->core->prefix . 'setting ' . 'SELECT count(*) FROM ' . $this->core->prefix . 'setting ' .
"WHERE setting_ns = '" . $res->setting_ns . "' " . "WHERE setting_ns = '" . $res->setting_ns . "' " .
"AND (blog_id IS NULL OR blog_id IS NOT NULL) " . 'AND (blog_id IS NULL OR blog_id IS NOT NULL) ' .
"GROUP BY setting_ns " 'GROUP BY setting_ns '
)->f(0); )->f(0);
$i++; $i++;
} }
@ -148,6 +147,7 @@ class advancedCleanerTables extends advancedCleaner
if ($action == 'delete') { if ($action == 'delete') {
return __('Failed to delete table'); return __('Failed to delete table');
} }
return ''; return '';
} }
@ -317,6 +317,7 @@ class advancedCleanerPlugins extends advancedCleaner
if ($action == 'delete') { if ($action == 'delete') {
return __('Failed to delete plugin folder'); return __('Failed to delete plugin folder');
} }
return ''; return '';
} }
@ -378,6 +379,7 @@ class advancedCleanerThemes extends advancedCleaner
if ($action == 'delete') { if ($action == 'delete') {
return __('Failed to delete themes folder'); return __('Failed to delete themes folder');
} }
return ''; return '';
} }
@ -437,6 +439,7 @@ class advancedCleanerCaches extends advancedCleaner
if ($action == 'delete') { if ($action == 'delete') {
return __('Failed to delete cache folder'); return __('Failed to delete cache folder');
} }
return ''; return '';
} }
@ -489,6 +492,7 @@ class advancedCleanerVars extends advancedCleaner
if ($action == 'delete') { if ($action == 'delete') {
return __('Failed to delete var folder'); return __('Failed to delete var folder');
} }
return ''; return '';
} }

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_ADMIN_CONTEXT')) { if (!defined('DC_ADMIN_CONTEXT')) {
return null; return null;
} }
@ -92,6 +91,7 @@ class behaviorsDcAdvancedCleaner
if (!count($modules)) { if (!count($modules)) {
echo '<p>' . __('There is no module with uninstall features') . '</p></div>'; echo '<p>' . __('There is no module with uninstall features') . '</p></div>';
return null; return null;
} }
@ -121,12 +121,12 @@ class behaviorsDcAdvancedCleaner
if (!isset($actions[$prop_id])) { if (!isset($actions[$prop_id])) {
echo '--</td>'; echo '--</td>';
continue; continue;
} }
$j = 0; $j = 0;
foreach ($actions[$prop_id] as $action_id => $action) { foreach ($actions[$prop_id] as $action_id => $action) {
if (!isset($props[$prop_id][$action['action']])) { if (!isset($props[$prop_id][$action['action']])) {
continue; continue;
} }
@ -155,7 +155,6 @@ class behaviorsDcAdvancedCleaner
$k = 0; $k = 0;
foreach ($callbacks as $callback_id => $callback) { foreach ($callbacks as $callback_id => $callback) {
$ret = base64_encode(serialize($callback['func'])); $ret = base64_encode(serialize($callback['func']));
echo '<label class="classic">' . echo '<label class="classic">' .

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;
} }
@ -44,8 +43,7 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) {
'admin.plugin.dcAdvancedCleaner', 'admin.plugin.dcAdvancedCleaner',
['part' => $cleaner->id] ['part' => $cleaner->id]
); );
} } catch (Exception $e) {
catch(Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }

View File

@ -1,16 +1,18 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of dcAdvancedCleaner, a plugin for Dotclear 2. * @brief dcAdvancedCleaner, a plugin for Dotclear 2
# *
# Copyright (c) 2009 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
if (!defined('DC_RC_PATH')){return;} */
if (!isset($__resources['help']['dcAdvancedCleaner'])) if (!defined('DC_RC_PATH')) {
{ return;
}
if (!isset($__resources['help']['dcAdvancedCleaner'])) {
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html'; $__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html';
} }

View File

@ -1,16 +1,18 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of dcAdvancedCleaner, a plugin for Dotclear 2. * @brief dcAdvancedCleaner, a plugin for Dotclear 2
# *
# Copyright (c) 2009 JC Denis and contributors * @package Dotclear
# jcdenis@gdwd.com * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# -- END LICENSE BLOCK ------------------------------------ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
if (!defined('DC_RC_PATH')){return;} */
if (!isset($__resources['help']['dcAdvancedCleaner'])) if (!defined('DC_RC_PATH')) {
{ return;
}
if (!isset($__resources['help']['dcAdvancedCleaner'])) {
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html'; $__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html';
} }