update to PSR12
parent
2a3323b79d
commit
7c0d3f45e5
|
@ -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...)
|
||||||
|
|
11
_admin.php
11
_admin.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -22,8 +21,8 @@ $_menu['Plugins']->addItem(
|
||||||
$core->adminurl->get('admin.plugin.dcAdvancedCleaner'),
|
$core->adminurl->get('admin.plugin.dcAdvancedCleaner'),
|
||||||
dcPage::getPF('dcAdvancedCleaner/icon.png'),
|
dcPage::getPF('dcAdvancedCleaner/icon.png'),
|
||||||
preg_match(
|
preg_match(
|
||||||
'/' . preg_quote($core->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/',
|
'/' . preg_quote($core->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
$core->auth->isSuperAdmin()
|
$core->auth->isSuperAdmin()
|
||||||
);
|
);
|
||||||
|
|
38
_config.php
38
_config.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +24,8 @@ if (!empty($_POST['save'])) {
|
||||||
'dcAdvancedCleaner_behavior_active'
|
'dcAdvancedCleaner_behavior_active'
|
||||||
);
|
);
|
||||||
$core->blog->settings->dcAdvancedCleaner->put(
|
$core->blog->settings->dcAdvancedCleaner->put(
|
||||||
'dcAdvancedCleaner_behavior_active',
|
'dcAdvancedCleaner_behavior_active',
|
||||||
!empty($_POST['behavior_active']),
|
!empty($_POST['behavior_active']),
|
||||||
'boolean',
|
'boolean',
|
||||||
null,
|
null,
|
||||||
true,
|
true,
|
||||||
|
@ -36,8 +35,8 @@ if (!empty($_POST['save'])) {
|
||||||
'dcAdvancedCleaner_dcproperty_hide'
|
'dcAdvancedCleaner_dcproperty_hide'
|
||||||
);
|
);
|
||||||
$core->blog->settings->dcAdvancedCleaner->put(
|
$core->blog->settings->dcAdvancedCleaner->put(
|
||||||
'dcAdvancedCleaner_dcproperty_hide',
|
'dcAdvancedCleaner_dcproperty_hide',
|
||||||
!empty($_POST['dcproperty_hide']),
|
!empty($_POST['dcproperty_hide']),
|
||||||
'boolean',
|
'boolean',
|
||||||
null,
|
null,
|
||||||
true,
|
true,
|
||||||
|
@ -47,31 +46,30 @@ if (!empty($_POST['save'])) {
|
||||||
__('Configuration successfully updated.')
|
__('Configuration successfully updated.')
|
||||||
);
|
);
|
||||||
$core->adminurl->redirect(
|
$core->adminurl->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
[
|
[
|
||||||
'module' => 'dcAdvancedCleaner',
|
'module' => 'dcAdvancedCleaner',
|
||||||
'conf' => 1,
|
'conf' => 1,
|
||||||
'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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
<p><label class="classic" for="behavior_active">' .
|
<p><label class="classic" for="behavior_active">' .
|
||||||
form::checkbox(
|
form::checkbox(
|
||||||
'behavior_active',
|
'behavior_active',
|
||||||
1,
|
1,
|
||||||
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active
|
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active
|
||||||
) . ' ' . __('Activate behaviors') . '</label></p>
|
) . ' ' . __('Activate behaviors') . '</label></p>
|
||||||
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
|
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
|
||||||
<p><label class="classic" for="dcproperty_hide">' .
|
<p><label class="classic" for="dcproperty_hide">' .
|
||||||
form::checkbox(
|
form::checkbox(
|
||||||
'dcproperty_hide',
|
'dcproperty_hide',
|
||||||
1,
|
1,
|
||||||
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide
|
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide
|
||||||
) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p>
|
) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p>
|
||||||
<p class="form-note">' .
|
<p class="form-note">' .
|
||||||
__('Prevent from deleting Dotclear important properties.') . '</p>';
|
__('Prevent from deleting Dotclear important properties.') . '</p>';
|
||||||
|
|
19
_define.php
19
_define.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -21,11 +20,11 @@ $this->registerModule(
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'0.8.1',
|
'0.8.1',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.19']],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/dcAdvancedCleaner',
|
'support' => 'https://github.com/JcDenis/dcAdvancedCleaner',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
10
_install.php
10
_install.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -53,4 +52,4 @@ $core->addBehavior('themeBeforeDelete', ['behaviorsDcAdvancedCleaner', 'themeBef
|
||||||
|
|
||||||
if (defined('ACTIVITY_REPORT')) {
|
if (defined('ACTIVITY_REPORT')) {
|
||||||
dcAdvancedCleanerActivityReportBehaviors::add($core);
|
dcAdvancedCleanerActivityReportBehaviors::add($core);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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)
|
||||||
|
@ -54,11 +52,12 @@ abstract class advancedCleaner
|
||||||
final protected function setProperties($property, $value = null): bool
|
final protected function setProperties($property, $value = null): bool
|
||||||
{
|
{
|
||||||
$properties = is_array($property) ? $property : [$property => $value];
|
$properties = is_array($property) ? $property : [$property => $value];
|
||||||
foreach($properties as $k => $v) {
|
foreach ($properties as $k => $v) {
|
||||||
if (isset($this->properties[$k])) {
|
if (isset($this->properties[$k])) {
|
||||||
$this->properties[$k] = (string) $v;
|
$this->properties[$k] = (string) $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ abstract class advancedCleaner
|
||||||
final protected function setActions($action, $name = null): bool
|
final protected function setActions($action, $name = null): bool
|
||||||
{
|
{
|
||||||
$actions = is_array($action) ? $action : [$action => $name];
|
$actions = is_array($action) ? $action : [$action => $name];
|
||||||
foreach($actions as $k => $v) {
|
foreach ($actions as $k => $v) {
|
||||||
$this->actions[$k] = (string) $v;
|
$this->actions[$k] = (string) $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,33 +94,36 @@ abstract class advancedCleaner
|
||||||
$roots = [$roots];
|
$roots = [$roots];
|
||||||
}
|
}
|
||||||
$rs = [];
|
$rs = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($roots as $root) {
|
foreach ($roots as $root) {
|
||||||
$dirs = files::scanDir($root);
|
$dirs = files::scanDir($root);
|
||||||
foreach($dirs as $k) {
|
foreach ($dirs as $k) {
|
||||||
if ('.' == $k || '..' == $k || !is_dir($root .'/' . $k)) {
|
if ('.' == $k || '..' == $k || !is_dir($root . '/' . $k)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$rs[$i]['key'] = $k;
|
$rs[$i]['key'] = $k;
|
||||||
$rs[$i]['value'] = count(self::scanDir($root . '/' . $k));
|
$rs[$i]['value'] = count(self::scanDir($root . '/' . $k));
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function delDir($roots, $folder, $delfolder = true)
|
protected static function delDir($roots, $folder, $delfolder = true)
|
||||||
{
|
{
|
||||||
if (strpos($folder,'/')) {
|
if (strpos($folder, '/')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!is_array($roots)) {
|
if (!is_array($roots)) {
|
||||||
$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,17 +137,18 @@ 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;
|
||||||
}
|
}
|
||||||
if (is_dir($path . '/' . $file)) {
|
if (is_dir($path . '/' . $file)) {
|
||||||
$res[] = $file;
|
$res[] = $file;
|
||||||
$res = self::scanDir($path . '/' . $file, $dir . '/' . $file, $res);
|
$res = self::scanDir($path . '/' . $file, $dir . '/' . $file, $res);
|
||||||
} else {
|
} else {
|
||||||
$res[] = empty($dir) ? $file : $dir . '/' . $file;
|
$res[] = empty($dir) ? $file : $dir . '/' . $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +157,7 @@ abstract class advancedCleaner
|
||||||
if (!is_dir($dir) || !is_readable($dir)) {
|
if (!is_dir($dir) || !is_readable($dir)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (substr($dir,-1) != '/') {
|
if (substr($dir, -1) != '/') {
|
||||||
$dir .= '/';
|
$dir .= '/';
|
||||||
}
|
}
|
||||||
if (($d = @dir($dir)) === false) {
|
if (($d = @dir($dir)) === false) {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -23,13 +22,13 @@ class dcAdvancedCleaner
|
||||||
public function __construct($core)
|
public function __construct($core)
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
$this->core = $core;
|
||||||
$cleaners = new arrayObject();
|
$cleaners = new arrayObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$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,9 +68,10 @@ 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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -35,18 +34,18 @@ __('delete %s cache files');
|
||||||
* @brief Modules uninstall features handler
|
* @brief Modules uninstall features handler
|
||||||
*
|
*
|
||||||
* Provides an object to handle modules uninstall features
|
* Provides an object to handle modules uninstall features
|
||||||
* (themes or plugins).
|
* (themes or plugins).
|
||||||
* This class used dcAdvancedCleaner.
|
* This class used dcAdvancedCleaner.
|
||||||
*/
|
*/
|
||||||
class dcUninstaller
|
class dcUninstaller
|
||||||
{
|
{
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
protected $modules = [];
|
protected $modules = [];
|
||||||
protected $actions = ['user' => [], 'callback' => []];
|
protected $actions = ['user' => [], 'callback' => []];
|
||||||
protected $callbacks = ['user' => [], 'callback' => []];
|
protected $callbacks = ['user' => [], 'callback' => []];
|
||||||
|
|
||||||
protected $id = null;
|
protected $id = null;
|
||||||
protected $mroot = null;
|
protected $mroot = null;
|
||||||
|
|
||||||
public $core;
|
public $core;
|
||||||
|
@ -55,16 +54,16 @@ class dcUninstaller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object constructor.
|
* Object constructor.
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
* @param dcCore $core dcCore instance
|
||||||
*/
|
*/
|
||||||
public function __construct(dcCore $core)
|
public function __construct(dcCore $core)
|
||||||
{
|
{
|
||||||
$this->core =& $core;
|
$this->core = & $core;
|
||||||
$this->ac = new dcAdvancedCleaner($core);
|
$this->ac = new dcAdvancedCleaner($core);
|
||||||
|
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach($this->ac->get() as $cleaner) {
|
foreach ($this->ac->get() as $cleaner) {
|
||||||
$res[$cleaner->id] = $cleaner->getActions();
|
$res[$cleaner->id] = $cleaner->getActions();
|
||||||
}
|
}
|
||||||
$this->allowed_actions = $res;
|
$this->allowed_actions = $res;
|
||||||
|
@ -77,16 +76,16 @@ class dcUninstaller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads modules.
|
* Loads modules.
|
||||||
*
|
*
|
||||||
* Files _defines.php and _uninstall.php must be present on module
|
* Files _defines.php and _uninstall.php must be present on module
|
||||||
* to be recognized.
|
* to be recognized.
|
||||||
* (path separator depends on your OS).
|
* (path separator depends on your OS).
|
||||||
*
|
*
|
||||||
* @param string $path Separated list of paths
|
* @param string $path Separated list of paths
|
||||||
*/
|
*/
|
||||||
public function loadModules($path)
|
public function loadModules($path)
|
||||||
{
|
{
|
||||||
$this->path = explode(PATH_SEPARATOR,$path);
|
$this->path = explode(PATH_SEPARATOR, $path);
|
||||||
|
|
||||||
foreach ($this->path as $root) {
|
foreach ($this->path as $root) {
|
||||||
if (!is_dir($root) || !is_readable($root)) {
|
if (!is_dir($root) || !is_readable($root)) {
|
||||||
|
@ -114,31 +113,30 @@ class dcUninstaller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load one module.
|
* Load one module.
|
||||||
*
|
*
|
||||||
* Files _defines.php and _uninstall.php must be present on module
|
* Files _defines.php and _uninstall.php must be present on module
|
||||||
* to be recognized.
|
* to be recognized.
|
||||||
*
|
*
|
||||||
* @param string $root path of module
|
* @param string $root path of module
|
||||||
*/
|
*/
|
||||||
public function loadModule($root)
|
public function loadModule($root)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
require $root . '/_define.php';
|
require $root . '/_define.php';
|
||||||
require $root . '/_uninstall.php';
|
require $root . '/_uninstall.php';
|
||||||
|
|
||||||
$this->id = null;
|
$this->id = null;
|
||||||
$this->mroot = null;
|
$this->mroot = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method registers a module in modules list.
|
* This method registers a module in modules list.
|
||||||
*
|
*
|
||||||
* @param string $name Module name
|
* @param string $name Module name
|
||||||
* @param string $desc Module description
|
* @param string $desc Module description
|
||||||
* @param string $author Module author name
|
* @param string $author Module author name
|
||||||
|
@ -148,11 +146,11 @@ class dcUninstaller
|
||||||
{
|
{
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
$this->modules[$this->id] = [
|
$this->modules[$this->id] = [
|
||||||
'root' => $this->mroot,
|
'root' => $this->mroot,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'desc' => $desc,
|
'desc' => $desc,
|
||||||
'author' => $author,
|
'author' => $author,
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'root_writable' => is_writable($this->mroot)
|
'root_writable' => is_writable($this->mroot)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -161,9 +159,9 @@ class dcUninstaller
|
||||||
/**
|
/**
|
||||||
* Returns all modules associative array or only one module if <var>$id</var>
|
* Returns all modules associative array or only one module if <var>$id</var>
|
||||||
* is present.
|
* is present.
|
||||||
*
|
*
|
||||||
* @param string $id Optionnal module ID
|
* @param string $id Optionnal module ID
|
||||||
*
|
*
|
||||||
* @return array Modules
|
* @return array Modules
|
||||||
*/
|
*/
|
||||||
public function getModules($id = null)
|
public function getModules($id = null)
|
||||||
|
@ -171,14 +169,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the module with ID <var>$id</var> exists.
|
* Returns true if the module with ID <var>$id</var> exists.
|
||||||
*
|
*
|
||||||
* @param string $idModule ID
|
* @param string $idModule ID
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function moduleExists($id)
|
public function moduleExists($id)
|
||||||
|
@ -188,9 +187,9 @@ class dcUninstaller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a predefined action to unsintall features.
|
* Add a predefined action to unsintall features.
|
||||||
*
|
*
|
||||||
* This action is set in _uninstall.php.
|
* This action is set in _uninstall.php.
|
||||||
*
|
*
|
||||||
* @param string $type Type of action (from $allowed_actions)
|
* @param string $type Type of action (from $allowed_actions)
|
||||||
* @param string $action Action (from $allowed_actions)
|
* @param string $action Action (from $allowed_actions)
|
||||||
* @param string $ns Name of setting related to module.
|
* @param string $ns Name of setting related to module.
|
||||||
|
@ -231,7 +230,7 @@ class dcUninstaller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns modules <var>$id</var> predefined actions associative array
|
* Returns modules <var>$id</var> predefined actions associative array
|
||||||
*
|
*
|
||||||
* @param string $id Optionnal module ID
|
* @param string $id Optionnal module ID
|
||||||
* @return array Modules id
|
* @return array Modules id
|
||||||
*/
|
*/
|
||||||
|
@ -253,24 +252,25 @@ class dcUninstaller
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach($this->allowed_actions as $k => $v) {
|
foreach ($this->allowed_actions as $k => $v) {
|
||||||
if (!isset($this->actions[$group][$id][$k])) {
|
if (!isset($this->actions[$group][$id][$k])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$res[$k] = $this->actions[$group][$id][$k];
|
$res[$k] = $this->actions[$group][$id][$k];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a callable function for unsintall features.
|
* Add a callable function for unsintall features.
|
||||||
*
|
*
|
||||||
* This action is set in _uninstall.php.
|
* This action is set in _uninstall.php.
|
||||||
*
|
*
|
||||||
* @param string $func Callable function
|
* @param string $func Callable function
|
||||||
* @param string $desc Description of action
|
* @param string $desc Description of action
|
||||||
*/
|
*/
|
||||||
protected function addUserCallback($func, $desc= '')
|
protected function addUserCallback($func, $desc = '')
|
||||||
{
|
{
|
||||||
$this->addCallback('user', $func, $desc);
|
$this->addCallback('user', $func, $desc);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ class dcUninstaller
|
||||||
* Returns modules <var>$id</var> callback actions associative array
|
* Returns modules <var>$id</var> callback actions associative array
|
||||||
|
|
||||||
* @param string $id Optionnal module ID
|
* @param string $id Optionnal module ID
|
||||||
*
|
*
|
||||||
* @return array Modules id
|
* @return array Modules id
|
||||||
*/
|
*/
|
||||||
public function getUserCallbacks($id)
|
public function getUserCallbacks($id)
|
||||||
|
@ -323,14 +323,15 @@ 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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a predifined action.
|
* Execute a predifined action.
|
||||||
*
|
*
|
||||||
* This function call dcAdvancedCleaner to do actions.
|
* This function call dcAdvancedCleaner to do actions.
|
||||||
*
|
*
|
||||||
* @param string $type Type of action (from $allowed_actions)
|
* @param string $type Type of action (from $allowed_actions)
|
||||||
* @param string $action Action (from $allowed_actions)
|
* @param string $action Action (from $allowed_actions)
|
||||||
* @param string $ns Name of setting related to module.
|
* @param string $ns Name of setting related to module.
|
||||||
|
@ -356,4 +357,4 @@ class dcUninstaller
|
||||||
{
|
{
|
||||||
return in_array($group, ['user','direct']) ? $group : null;
|
return in_array($group, ['user','direct']) ? $group : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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
|
||||||
|
@ -53,7 +52,7 @@ class advancedCleanerSettings extends advancedCleaner
|
||||||
'breadcrumb',
|
'breadcrumb',
|
||||||
'dcckeditor',
|
'dcckeditor',
|
||||||
'dclegacyeditor',
|
'dclegacyeditor',
|
||||||
'maintenance',
|
'maintenance',
|
||||||
'pages',
|
'pages',
|
||||||
'pings',
|
'pings',
|
||||||
'system',
|
'system',
|
||||||
|
@ -68,19 +67,19 @@ 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'
|
||||||
);
|
);
|
||||||
|
|
||||||
$rs = [];
|
$rs = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($res->fetch()) {
|
while ($res->fetch()) {
|
||||||
$rs[$i]['key'] = $res->setting_ns;
|
$rs[$i]['key'] = $res->setting_ns;
|
||||||
$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++;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +91,7 @@ class advancedCleanerSettings extends advancedCleaner
|
||||||
{
|
{
|
||||||
if ($action == 'delete_global') {
|
if ($action == 'delete_global') {
|
||||||
$this->core->con->execute(
|
$this->core->con->execute(
|
||||||
'DELETE FROM ' .$this->core->prefix . 'setting ' .
|
'DELETE FROM ' . $this->core->prefix . 'setting ' .
|
||||||
'WHERE blog_id IS NULL ' .
|
'WHERE blog_id IS NULL ' .
|
||||||
"AND setting_ns = '" . $this->core->con->escape($ns) . "' "
|
"AND setting_ns = '" . $this->core->con->escape($ns) . "' "
|
||||||
);
|
);
|
||||||
|
@ -110,7 +109,7 @@ class advancedCleanerSettings extends advancedCleaner
|
||||||
}
|
}
|
||||||
if ($action == 'delete_all') {
|
if ($action == 'delete_all') {
|
||||||
$this->core->con->execute(
|
$this->core->con->execute(
|
||||||
'DELETE FROM ' .$this->core->prefix . 'setting ' .
|
'DELETE FROM ' . $this->core->prefix . 'setting ' .
|
||||||
"WHERE setting_ns = '" . $this->core->con->escape($ns) . "' " .
|
"WHERE setting_ns = '" . $this->core->con->escape($ns) . "' " .
|
||||||
"AND (blog_id IS NULL OR blog_id != '') "
|
"AND (blog_id IS NULL OR blog_id != '') "
|
||||||
);
|
);
|
||||||
|
@ -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 '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,18 +177,18 @@ class advancedCleanerTables extends advancedCleaner
|
||||||
public function get(): array
|
public function get(): array
|
||||||
{
|
{
|
||||||
$object = dbSchema::init($this->core->con);
|
$object = dbSchema::init($this->core->con);
|
||||||
$res = $object->getTables();
|
$res = $object->getTables();
|
||||||
|
|
||||||
$rs = [];
|
$rs = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($res as $k => $v) {
|
foreach ($res as $k => $v) {
|
||||||
if ('' != $this->core->prefix) {
|
if ('' != $this->core->prefix) {
|
||||||
if (!preg_match('/^' . preg_quote($this->core->prefix) . '(.*?)$/', $v, $m)) {
|
if (!preg_match('/^' . preg_quote($this->core->prefix) . '(.*?)$/', $v, $m)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$v = $m[1];
|
$v = $m[1];
|
||||||
}
|
}
|
||||||
$rs[$i]['key'] = $v;
|
$rs[$i]['key'] = $v;
|
||||||
$rs[$i]['value'] = $this->core->con->select('SELECT count(*) FROM ' . $res[$k])->f(0);
|
$rs[$i]['value'] = $this->core->con->select('SELECT count(*) FROM ' . $res[$k])->f(0);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -266,9 +266,9 @@ class advancedCleanerVersions extends advancedCleaner
|
||||||
$res = $this->core->con->select('SELECT * FROM ' . $this->core->prefix . 'version');
|
$res = $this->core->con->select('SELECT * FROM ' . $this->core->prefix . 'version');
|
||||||
|
|
||||||
$rs = [];
|
$rs = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($res->fetch()) {
|
while ($res->fetch()) {
|
||||||
$rs[$i]['key'] = $res->module;
|
$rs[$i]['key'] = $res->module;
|
||||||
$rs[$i]['value'] = $res->version;
|
$rs[$i]['value'] = $res->version;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ class advancedCleanerVersions extends advancedCleaner
|
||||||
{
|
{
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
$this->core->con->execute(
|
$this->core->con->execute(
|
||||||
'DELETE FROM '. $this->core->prefix . 'version ' .
|
'DELETE FROM ' . $this->core->prefix . 'version ' .
|
||||||
"WHERE module = '" . $this->core->con->escape($ns) . "' "
|
"WHERE module = '" . $this->core->con->escape($ns) . "' "
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -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 '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,4 +516,4 @@ class advancedCleanerVars extends advancedCleaner
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +18,7 @@ class dcAdvancedCleanerActivityReportBehaviors
|
||||||
{
|
{
|
||||||
public static function maintenance($type, $action, $ns)
|
public static function maintenance($type, $action, $ns)
|
||||||
{
|
{
|
||||||
$GLOBALS['core']->activityReport->addLog('dcadvancedcleaner', 'maintenance', [$type ,$action, $ns]);
|
$GLOBALS['core']->activityReport->addLog('dcadvancedcleaner', 'maintenance', [$type,$action, $ns]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add($core)
|
public static function add($core)
|
||||||
|
@ -27,10 +26,10 @@ class dcAdvancedCleanerActivityReportBehaviors
|
||||||
// This file is used with plugin activityReport
|
// This file is used with plugin activityReport
|
||||||
$core->activityReport->addGroup(
|
$core->activityReport->addGroup(
|
||||||
'dcadvancedcleaner',
|
'dcadvancedcleaner',
|
||||||
__('Plugin dcAdvancedCleaner')
|
__('Plugin dcAdvancedCleaner')
|
||||||
);
|
);
|
||||||
|
|
||||||
// from BEHAVIOR dcAdvancedCleanerBeforeAction
|
// from BEHAVIOR dcAdvancedCleanerBeforeAction
|
||||||
// in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php
|
// in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php
|
||||||
$core->activityReport->addAction(
|
$core->activityReport->addAction(
|
||||||
'dcadvancedcleaner',
|
'dcadvancedcleaner',
|
||||||
|
@ -41,4 +40,4 @@ class dcAdvancedCleanerActivityReportBehaviors
|
||||||
['dcAdvancedCleanerActivityReportBehaviors', 'maintenance']
|
['dcAdvancedCleanerActivityReportBehaviors', 'maintenance']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -51,17 +50,17 @@ class behaviorsDcAdvancedCleaner
|
||||||
$uninstaller->loadModule($module['root']);
|
$uninstaller->loadModule($module['root']);
|
||||||
|
|
||||||
$m_callbacks = $uninstaller->getDirectCallbacks($module['id']);
|
$m_callbacks = $uninstaller->getDirectCallbacks($module['id']);
|
||||||
$m_actions = $uninstaller->getDirectActions($module['id']);
|
$m_actions = $uninstaller->getDirectActions($module['id']);
|
||||||
|
|
||||||
foreach($m_callbacks as $k => $callback) {
|
foreach ($m_callbacks as $k => $callback) {
|
||||||
if (!isset($callback['func']) || !is_callable($callback['func'])) {
|
if (!isset($callback['func']) || !is_callable($callback['func'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
call_user_func($callback['func'], $module);
|
call_user_func($callback['func'], $module);
|
||||||
$done = true;
|
$done = true;
|
||||||
}
|
}
|
||||||
foreach($m_actions as $type => $actions) {
|
foreach ($m_actions as $type => $actions) {
|
||||||
foreach($actions as $v) {
|
foreach ($actions as $v) {
|
||||||
$uninstaller->execute($type, $v['action'], $v['ns']);
|
$uninstaller->execute($type, $v['action'], $v['ns']);
|
||||||
$done = true;
|
$done = true;
|
||||||
}
|
}
|
||||||
|
@ -86,12 +85,13 @@ class behaviorsDcAdvancedCleaner
|
||||||
$uninstaller = new dcUninstaller($core);
|
$uninstaller = new dcUninstaller($core);
|
||||||
$uninstaller->loadModules($path);
|
$uninstaller->loadModules($path);
|
||||||
$modules = $uninstaller->getModules();
|
$modules = $uninstaller->getModules();
|
||||||
$props = $uninstaller->getAllowedActions();
|
$props = $uninstaller->getAllowedActions();
|
||||||
|
|
||||||
echo '<div class="multi-part" id="uninstaller" title="' . __($title) . '"><h3>' . __($title) . '</h3>';
|
echo '<div class="multi-part" id="uninstaller" title="' . __($title) . '"><h3>' . __($title) . '</h3>';
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,14 +101,14 @@ class behaviorsDcAdvancedCleaner
|
||||||
'<table class="clear"><tr>' .
|
'<table class="clear"><tr>' .
|
||||||
'<th colspan="2">' . __('module') . '</th>';
|
'<th colspan="2">' . __('module') . '</th>';
|
||||||
|
|
||||||
foreach($props as $pro_id => $prop) {
|
foreach ($props as $pro_id => $prop) {
|
||||||
echo '<th>' . __($pro_id) . '</th>';
|
echo '<th>' . __($pro_id) . '</th>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<th>' . __('other') . '</th>' . '</tr>';
|
echo '<th>' . __('other') . '</th>' . '</tr>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($modules as $module_id => $module) {
|
foreach ($modules as $module_id => $module) {
|
||||||
echo
|
echo
|
||||||
'<tr class="line">' .
|
'<tr class="line">' .
|
||||||
'<td class="nowrap">' . $module_id . '</td>' .
|
'<td class="nowrap">' . $module_id . '</td>' .
|
||||||
|
@ -116,27 +116,27 @@ class behaviorsDcAdvancedCleaner
|
||||||
|
|
||||||
$actions = $uninstaller->getUserActions($module_id);
|
$actions = $uninstaller->getUserActions($module_id);
|
||||||
|
|
||||||
foreach($props as $prop_id => $prop) {
|
foreach ($props as $prop_id => $prop) {
|
||||||
echo '<td class="nowrap">';
|
echo '<td class="nowrap">';
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
$ret = base64_encode(serialize([
|
$ret = base64_encode(serialize([
|
||||||
'type' => $prop_id,
|
'type' => $prop_id,
|
||||||
'action'=> $action['action'],
|
'action' => $action['action'],
|
||||||
'ns'=> $action['ns']
|
'ns' => $action['ns']
|
||||||
]));
|
]));
|
||||||
|
|
||||||
echo '<label class="classic">'.
|
echo '<label class="classic">' .
|
||||||
form::checkbox(['actions[' . $module_id . '][' . $j . ']'], $ret) .
|
form::checkbox(['actions[' . $module_id . '][' . $j . ']'], $ret) .
|
||||||
' ' . $action['desc'] . '</label><br />';
|
' ' . $action['desc'] . '</label><br />';
|
||||||
|
|
||||||
|
@ -154,18 +154,17 @@ 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">' .
|
||||||
form::checkbox(['extras[' . $module_id . '][' . $k . ']'], $ret) .
|
form::checkbox(['extras[' . $module_id . '][' . $k . ']'], $ret) .
|
||||||
' ' . $callback['desc'] . '</label><br />';
|
' ' . $callback['desc'] . '</label><br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
'</table>' .
|
'</table>' .
|
||||||
'<p>' .
|
'<p>' .
|
||||||
$core->formNonce() .
|
$core->formNonce() .
|
||||||
|
@ -199,8 +198,8 @@ class behaviorsDcAdvancedCleaner
|
||||||
try {
|
try {
|
||||||
// Extras
|
// Extras
|
||||||
if (!empty($_POST['extras'])) {
|
if (!empty($_POST['extras'])) {
|
||||||
foreach($_POST['extras'] as $module_id => $extras) {
|
foreach ($_POST['extras'] as $module_id => $extras) {
|
||||||
foreach($extras as $k => $sentence) {
|
foreach ($extras as $k => $sentence) {
|
||||||
$extra = @unserialize(@base64_decode($sentence));
|
$extra = @unserialize(@base64_decode($sentence));
|
||||||
|
|
||||||
if (!$extra || !is_callable($extra)) {
|
if (!$extra || !is_callable($extra)) {
|
||||||
|
@ -212,13 +211,13 @@ class behaviorsDcAdvancedCleaner
|
||||||
}
|
}
|
||||||
// Actions
|
// Actions
|
||||||
if (!empty($_POST['actions'])) {
|
if (!empty($_POST['actions'])) {
|
||||||
foreach($_POST['actions'] as $module_id => $actions) {
|
foreach ($_POST['actions'] as $module_id => $actions) {
|
||||||
foreach($actions as $k => $sentence) {
|
foreach ($actions as $k => $sentence) {
|
||||||
$action = @unserialize(@base64_decode($sentence));
|
$action = @unserialize(@base64_decode($sentence));
|
||||||
|
|
||||||
if (!$action
|
if (!$action
|
||||||
|| !isset($action['type'])
|
|| !isset($action['type'])
|
||||||
|| !isset($action['action'])
|
|| !isset($action['action'])
|
||||||
|| !isset($action['ns'])
|
|| !isset($action['ns'])
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -229,8 +228,8 @@ class behaviorsDcAdvancedCleaner
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
||||||
http::redirect($_POST['redir']);
|
http::redirect($_POST['redir']);
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
$list->core->error->add($e->getMessage());
|
$list->core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
index.php
38
index.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis and Contributors
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
@ -19,9 +18,9 @@ dcPage::checkSuper();
|
||||||
|
|
||||||
$ac = new dcAdvancedCleaner($core);
|
$ac = new dcAdvancedCleaner($core);
|
||||||
|
|
||||||
$cleaner = false;
|
$cleaner = false;
|
||||||
$select_menu = [];
|
$select_menu = [];
|
||||||
foreach($ac->get() as $k) {
|
foreach ($ac->get() as $k) {
|
||||||
$select_menu[$k->name] = $k->id;
|
$select_menu[$k->name] = $k->id;
|
||||||
if ($k->id == $_REQUEST['part']) {
|
if ($k->id == $_REQUEST['part']) {
|
||||||
$cleaner = $k;
|
$cleaner = $k;
|
||||||
|
@ -36,16 +35,15 @@ if (!$cleaner) {
|
||||||
# Actions
|
# Actions
|
||||||
if (!empty($_POST['entries']) && !empty($_POST['action'])) {
|
if (!empty($_POST['entries']) && !empty($_POST['action'])) {
|
||||||
try {
|
try {
|
||||||
foreach($_POST['entries'] as $ns) {
|
foreach ($_POST['entries'] as $ns) {
|
||||||
$ac->set($cleaner->id, $_POST['action'], $ns);
|
$ac->set($cleaner->id, $_POST['action'], $ns);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
||||||
$core->adminurl->redirect(
|
$core->adminurl->redirect(
|
||||||
'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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,9 +58,9 @@ $core->callBehavior('dcAdvancedCleanerAdminHeader', $core);
|
||||||
|
|
||||||
echo '</head><body>' .
|
echo '</head><body>' .
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Advanced cleaner') => ''
|
__('Advanced cleaner') => ''
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
'<form method="get" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' .
|
'<form method="get" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' .
|
||||||
|
@ -86,17 +84,17 @@ if (empty($rs)) {
|
||||||
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
||||||
'</tr></thead><tbody>';
|
'</tr></thead><tbody>';
|
||||||
|
|
||||||
foreach($rs as $k => $v) {
|
foreach ($rs as $k => $v) {
|
||||||
$offline = in_array($v['key'], $cleaner->official());
|
$offline = in_array($v['key'], $cleaner->official());
|
||||||
|
|
||||||
if ($offline && $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
if ($offline && $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
'<tr class="line' . ($offline ? ' offline' : '') . '">' .
|
'<tr class="line' . ($offline ? ' offline' : '') . '">' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
form::checkbox(
|
form::checkbox(
|
||||||
['entries[' . $k . ']', 'entries_' . $k],
|
['entries[' . $k . ']', 'entries_' . $k],
|
||||||
html::escapeHTML($v['key'])
|
html::escapeHTML($v['key'])
|
||||||
) . '</td> ' .
|
) . '</td> ' .
|
||||||
'<td class="nowrap"><label for="entries_' . $k . '" class="classic">' . $v['key'] . '</label></td>' .
|
'<td class="nowrap"><label for="entries_' . $k . '" class="classic">' . $v['key'] . '</label></td>' .
|
||||||
|
@ -111,18 +109,18 @@ if (empty($rs)) {
|
||||||
form::hidden(['p'], 'dcAdvancedCleaner') .
|
form::hidden(['p'], 'dcAdvancedCleaner') .
|
||||||
form::hidden(['part'], $cleaner->id) .
|
form::hidden(['part'], $cleaner->id) .
|
||||||
$core->formNonce() . '</p>' .
|
$core->formNonce() . '</p>' .
|
||||||
'<p class="info">' .
|
'<p class="info">' .
|
||||||
__('Beware: All actions done here are irreversible and are directly applied') .
|
__('Beware: All actions done here are irreversible and are directly applied') .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
||||||
echo '<p class="info">' .
|
echo '<p class="info">' .
|
||||||
__('Default values of Dotclear are hidden. You can change this in settings') .
|
__('Default values of Dotclear are hidden. You can change this in settings') .
|
||||||
'</p>';
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::helpBlock('dcAdvancedCleaner');
|
dcPage::helpBlock('dcAdvancedCleaner');
|
||||||
|
|
||||||
echo '</body></html>';
|
echo '</body></html>';
|
||||||
|
|
|
@ -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;
|
||||||
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__).'/help/dcAdvancedCleaner.html';
|
}
|
||||||
}
|
if (!isset($__resources['help']['dcAdvancedCleaner'])) {
|
||||||
|
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html';
|
||||||
|
}
|
||||||
|
|
|
@ -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;
|
||||||
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__).'/help/dcAdvancedCleaner.html';
|
}
|
||||||
}
|
if (!isset($__resources['help']['dcAdvancedCleaner'])) {
|
||||||
|
$__resources['help']['dcAdvancedCleaner'] = dirname(__FILE__) . '/help/dcAdvancedCleaner.html';
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue