diff --git a/CHANGELOG.md b/CHANGELOG.md index ae92756..908031b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ - [ ] fix php7.3+ and php8.0 - [ ] fix PSR(1)2 coding style - [ ] fix translation -- [ ] update license +- [x] add dcstore (pre release) +- [x] update license - [x] update readme 0.7.3 - 2018.03.12 - Pierre Van Glabeke diff --git a/README.md b/README.md index 9fcb53c..0e88440 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Once it's done you can manage your reports from menu * Source & contribution : [GitHub Page](https://github.com/JcDenis/dcAdvancedCleaner) * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner) * Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40381) - + ## CONTRIBUTORS * Jean-Christian Denis diff --git a/_admin.php b/_admin.php index 126ada5..9eb19ba 100644 --- a/_admin.php +++ b/_admin.php @@ -1,34 +1,35 @@ addItem( - __('Advanced cleaner'), - 'plugin.php?p=dcAdvancedCleaner', - 'index.php?pf=dcAdvancedCleaner/icon.png', - preg_match('/plugin.php\?p=dcAdvancedCleaner(&.*)?$/',$_SERVER['REQUEST_URI']), - $core->auth->isSuperAdmin() + __('Advanced cleaner'), + 'plugin.php?p=dcAdvancedCleaner', + 'index.php?pf=dcAdvancedCleaner/icon.png', + preg_match('/plugin.php\?p=dcAdvancedCleaner(&.*)?$/',$_SERVER['REQUEST_URI']), + $core->auth->isSuperAdmin() ); $core->addBehavior('adminDashboardFavorites','dcAdvancedCleanerDashboardFavorites'); function dcAdvancedCleanerDashboardFavorites($core,$favs) { - $favs->register('dcAdvancedCleaner', array( - 'title' => __('Advanced cleaner'), - 'url' => 'plugin.php?p=dcAdvancedCleaner', - 'small-icon' => 'index.php?pf=dcAdvancedCleaner/icon.png', - 'large-icon' => 'index.php?pf=dcAdvancedCleaner/icon-big.png', - 'permissions' => 'usage,contentadmin' - )); + $favs->register('dcAdvancedCleaner', array( + 'title' => __('Advanced cleaner'), + 'url' => 'plugin.php?p=dcAdvancedCleaner', + 'small-icon' => 'index.php?pf=dcAdvancedCleaner/icon.png', + 'large-icon' => 'index.php?pf=dcAdvancedCleaner/icon-big.png', + 'permissions' => 'usage,contentadmin' + )); } \ No newline at end of file diff --git a/_define.php b/_define.php index b2dd373..af04bd3 100644 --- a/_define.php +++ b/_define.php @@ -1,29 +1,31 @@ registerModule( - /* Name */ "Advanced cleaner", - /* Description*/ "Make a huge cleaning of dotclear", - /* Author */ "JC Denis", - /* Version */ '0.7.3', - /* Properties */ - array( - 'permissions' => null, - 'type' => 'plugin', - 'dc_min' => '2.9', - 'support' => 'https://forum.dotclear.org/viewtopic.php?id=40381', - 'details' => 'http://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner' - ) -); - /* date */ #20180213 \ No newline at end of file + 'Advanced cleaner', + 'Make a huge cleaning of dotclear', + 'Jean-Christian Denis and Contributors', + '0.7.3.1', + [ + 'requires' => [['core', '2.19']], + 'permissions' => null, + 'type' => 'plugin', + 'support' => 'https://github.com/JcDenis/dcAdvancedCleaner', + 'details' => 'https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner', + 'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml' + ] +); \ No newline at end of file diff --git a/_install.php b/_install.php index 4d6dccb..799b9c1 100644 --- a/_install.php +++ b/_install.php @@ -1,14 +1,15 @@ =')) {return;} # Install or update try { - # Check DC version - if (version_compare(str_replace("-r","-p",DC_VERSION),'2.2-alpha','<')) - { - throw new Exception('dcAdvancedCleaner requires Dotclear 2.2'); - } - - # Settings - $core->blog->settings->addNamespace('dcAdvancedCleaner'); - $core->blog->settings->dcAdvancedCleaner->put('dcAdvancedCleaner_behavior_active',true,'boolean','',false,true); - $core->blog->settings->dcAdvancedCleaner->put('dcAdvancedCleaner_dcproperty_hide',true,'boolean','',false,true); - - # Version - $core->setVersion('dcAdvancedCleaner',$new_version); - - return true; + # Check DC version + if (version_compare(str_replace("-r","-p",DC_VERSION),'2.2-alpha','<')) + { + throw new Exception('dcAdvancedCleaner requires Dotclear 2.2'); + } + + # Settings + $core->blog->settings->addNamespace('dcAdvancedCleaner'); + $core->blog->settings->dcAdvancedCleaner->put('dcAdvancedCleaner_behavior_active',true,'boolean','',false,true); + $core->blog->settings->dcAdvancedCleaner->put('dcAdvancedCleaner_dcproperty_hide',true,'boolean','',false,true); + + # Version + $core->setVersion('dcAdvancedCleaner',$new_version); + + return true; } catch (Exception $e) { - $core->error->add($e->getMessage()); - return false; + $core->error->add($e->getMessage()); + return false; } \ No newline at end of file diff --git a/_prepend.php b/_prepend.php index 91d7d4e..cda1549 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,14 +1,15 @@ blog->settings->addNamespace('dcAdvancedCleaner'); # Main class $__autoload['dcAdvancedCleaner'] = - dirname(__FILE__).'/inc/class.dc.advanced.cleaner.php'; + dirname(__FILE__).'/inc/class.dc.advanced.cleaner.php'; # Behaviors class $__autoload['behaviorsDcAdvancedCleaner'] = - dirname(__FILE__).'/inc/lib.dc.advanced.cleaner.behaviors.php'; + dirname(__FILE__).'/inc/lib.dc.advanced.cleaner.behaviors.php'; # Unsintaller class $__autoload['dcUninstaller'] = - dirname(__FILE__).'/inc/class.dc.uninstaller.php'; + dirname(__FILE__).'/inc/class.dc.uninstaller.php'; # Add tab on plugin admin page $core->addBehavior('pluginsToolsTabs', - array('behaviorsDcAdvancedCleaner','pluginsToolsTabs')); + array('behaviorsDcAdvancedCleaner','pluginsToolsTabs')); # Action on plugin deletion $core->addBehavior('pluginsBeforeDelete', - array('behaviorsDcAdvancedCleaner','pluginsBeforeDelete')); + array('behaviorsDcAdvancedCleaner','pluginsBeforeDelete')); # Action on theme deletion $core->addBehavior('themeBeforeDelete', - array('behaviorsDcAdvancedCleaner','themeBeforeDelete')); + array('behaviorsDcAdvancedCleaner','themeBeforeDelete')); # Tabs of dcAvdancedCleaner admin page $core->addBehavior('dcAdvancedCleanerAdminTabs', - array('behaviorsDcAdvancedCleaner','dcAdvancedCleanerAdminTabs')); + array('behaviorsDcAdvancedCleaner','dcAdvancedCleanerAdminTabs')); # Add dcac events on plugin activityReport if (defined('ACTIVITY_REPORT')) { - require_once dirname(__FILE__).'/inc/lib.dc.advanced.cleaner.activityreport.php'; + require_once dirname(__FILE__).'/inc/lib.dc.advanced.cleaner.activityreport.php'; } \ No newline at end of file diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..312901d --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,12 @@ + + +Nettoyeur avancé +0.7.3.1 +Jean-Christian Denis and Contributors +Make a huge cleaning of dotclear +https://github.com/JcDenis/dcAdvancedCleaner/releases/download/v0.7.3.1/plugin-dcAdvancedCleaner.zip +2.19 +https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner +https://github.com/JcDenis/dcAdvancedCleaner + + \ No newline at end of file diff --git a/inc/class.dc.advanced.cleaner.php b/inc/class.dc.advanced.cleaner.php index 49abb21..44660cd 100644 --- a/inc/class.dc.advanced.cleaner.php +++ b/inc/class.dc.advanced.cleaner.php @@ -1,395 +1,396 @@ array( - 'delete_global' => 'Failed to delete global settings', - 'delete_local' => 'Failed to delete local settings', - 'delete_all' => 'Failed to delete all settings' - ), - 'tables' => array( - 'empty' => 'Failed to empty table', - 'delete' => 'Failed to delete table' - ), - 'plugins' => array( - 'empty' => 'Failed to empty plugin folder', - 'delete' => 'Failed to delete plugin folder' - ), - 'themes' => array( - 'empty' => 'Failed to empty themes folder', - 'delete' => 'Failed to delete themes folder' - ), - 'caches' => array( - 'empty' => 'Failed to empty cache folder', - 'delete' => 'Failed to delete cache folder' - ), - 'versions' => array( - 'delete' => 'Failed to delete version' - ) - ); + protected static $errors = array( + 'settings' => array( + 'delete_global' => 'Failed to delete global settings', + 'delete_local' => 'Failed to delete local settings', + 'delete_all' => 'Failed to delete all settings' + ), + 'tables' => array( + 'empty' => 'Failed to empty table', + 'delete' => 'Failed to delete table' + ), + 'plugins' => array( + 'empty' => 'Failed to empty plugin folder', + 'delete' => 'Failed to delete plugin folder' + ), + 'themes' => array( + 'empty' => 'Failed to empty themes folder', + 'delete' => 'Failed to delete themes folder' + ), + 'caches' => array( + 'empty' => 'Failed to empty cache folder', + 'delete' => 'Failed to delete cache folder' + ), + 'versions' => array( + 'delete' => 'Failed to delete version' + ) + ); - public static $dotclear = array( - 'settings' => array( - 'akismet','antispam','breadcrumb','dcckeditor','dclegacyeditor','maintenance', + public static $dotclear = array( + 'settings' => array( + 'akismet','antispam','breadcrumb','dcckeditor','dclegacyeditor','maintenance', 'pages','pings','system','themes','widgets' - ), - 'tables' => array( - 'blog','category','comment','link','log','media', - 'meta','permissions','ping','post','post_media','pref','session', - 'setting','spamrule','user','version' - ), - 'plugins' => array( - 'aboutConfig','akismet','antispam','attachments','blogroll','blowupConfig', - 'breadcrumb','dcCKEditor','dclegacy','dcLegacyEditor','fairTrackbacks','importExport','maintenance', - 'pages','pings','simpleMenu','tags','themeEditor','userPref','widgets' - ), - 'themes' => array( - 'default','customCSS','blueSilence','berlin','ductile' - ), - 'caches' => array( - 'cbfeed','dcrepo','versions' - ), - 'versions' => array( - 'antispam','blogroll','blowupConfig','core','dcCKEditor','dcLegacyEditor','pages','pings','simpleMenu','tags','widgets' - ) - ); + ), + 'tables' => array( + 'blog','category','comment','link','log','media', + 'meta','permissions','ping','post','post_media','pref','session', + 'setting','spamrule','user','version' + ), + 'plugins' => array( + 'aboutConfig','akismet','antispam','attachments','blogroll','blowupConfig', + 'breadcrumb','dcCKEditor','dclegacy','dcLegacyEditor','fairTrackbacks','importExport','maintenance', + 'pages','pings','simpleMenu','tags','themeEditor','userPref','widgets' + ), + 'themes' => array( + 'default','customCSS','blueSilence','berlin','ductile' + ), + 'caches' => array( + 'cbfeed','dcrepo','versions' + ), + 'versions' => array( + 'antispam','blogroll','blowupConfig','core','dcCKEditor','dcLegacyEditor','pages','pings','simpleMenu','tags','widgets' + ) + ); - public static $exclude = array( - '.','..','__MACOSX','.svn','CVS','.DS_Store','Thumbs.db' - ); + public static $exclude = array( + '.','..','__MACOSX','.svn','CVS','.DS_Store','Thumbs.db' + ); - public static function getSettings($core) - { - $res = $core->con->select( - 'SELECT setting_ns '. - 'FROM '.$core->prefix.'setting '. - 'WHERE blog_id IS NULL '. - "OR blog_id IS NOT NULL ". - 'GROUP BY setting_ns'); + public static function getSettings($core) + { + $res = $core->con->select( + 'SELECT setting_ns '. + 'FROM '.$core->prefix.'setting '. + 'WHERE blog_id IS NULL '. + "OR blog_id IS NOT NULL ". + 'GROUP BY setting_ns'); - $rs = array(); - $i = 0; - while($res->fetch()) { + $rs = array(); + $i = 0; + while($res->fetch()) { - $rs[$i]['key'] = $res->setting_ns; - $rs[$i]['value'] = $core->con->select( - 'SELECT count(*) FROM '.$core->prefix.'setting '. - "WHERE setting_ns = '".$res->setting_ns."' ". - "AND (blog_id IS NULL OR blog_id IS NOT NULL) ". - "GROUP BY setting_ns ")->f(0); - $i++; - } - return $rs; - } + $rs[$i]['key'] = $res->setting_ns; + $rs[$i]['value'] = $core->con->select( + 'SELECT count(*) FROM '.$core->prefix.'setting '. + "WHERE setting_ns = '".$res->setting_ns."' ". + "AND (blog_id IS NULL OR blog_id IS NOT NULL) ". + "GROUP BY setting_ns ")->f(0); + $i++; + } + return $rs; + } - protected static function deleteGlobalSettings($core,$entry) - { - $core->con->execute( - 'DELETE FROM '.$core->prefix.'setting '. - 'WHERE blog_id IS NULL '. - "AND setting_ns = '".$core->con->escape($entry)."' " - ); - } + protected static function deleteGlobalSettings($core,$entry) + { + $core->con->execute( + 'DELETE FROM '.$core->prefix.'setting '. + 'WHERE blog_id IS NULL '. + "AND setting_ns = '".$core->con->escape($entry)."' " + ); + } - protected static function deleteLocalSettings($core,$entry) - { - $core->con->execute( - 'DELETE FROM '.$core->prefix.'setting '. - "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ". - "AND setting_ns = '".$core->con->escape($entry)."' " - ); - } + protected static function deleteLocalSettings($core,$entry) + { + $core->con->execute( + 'DELETE FROM '.$core->prefix.'setting '. + "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ". + "AND setting_ns = '".$core->con->escape($entry)."' " + ); + } - protected static function deleteAllSettings($core,$entry) - { - $core->con->execute( - 'DELETE FROM '.$core->prefix.'setting '. - "WHERE setting_ns = '".$core->con->escape($entry)."' ". - "AND (blog_id IS NULL OR blog_id != '') " - ); - } + protected static function deleteAllSettings($core,$entry) + { + $core->con->execute( + 'DELETE FROM '.$core->prefix.'setting '. + "WHERE setting_ns = '".$core->con->escape($entry)."' ". + "AND (blog_id IS NULL OR blog_id != '') " + ); + } - public static function getTables($core) - { - $object = dbSchema::init($core->con); - $res = $object->getTables(); + public static function getTables($core) + { + $object = dbSchema::init($core->con); + $res = $object->getTables(); - $rs = array(); - $i = 0; - foreach($res as $k => $v) - { - if ('' != $core->prefix) - { - if (!preg_match('/^'.preg_quote($core->prefix).'(.*?)$/',$v,$m)) continue; - $v = $m[1]; - } - $rs[$i]['key'] = $v; - $rs[$i]['value'] = $core->con->select('SELECT count(*) FROM '.$res[$k])->f(0); - $i++; - } - return $rs; - } + $rs = array(); + $i = 0; + foreach($res as $k => $v) + { + if ('' != $core->prefix) + { + if (!preg_match('/^'.preg_quote($core->prefix).'(.*?)$/',$v,$m)) continue; + $v = $m[1]; + } + $rs[$i]['key'] = $v; + $rs[$i]['value'] = $core->con->select('SELECT count(*) FROM '.$res[$k])->f(0); + $i++; + } + return $rs; + } - protected static function emptyTable($core,$entry) - { - $core->con->execute( - 'DELETE FROM '.$core->con->escapeSystem($core->prefix.$entry) - ); - } + protected static function emptyTable($core,$entry) + { + $core->con->execute( + 'DELETE FROM '.$core->con->escapeSystem($core->prefix.$entry) + ); + } - protected static function deleteTable($core,$entry) - { - self::emptyTable($core,$entry); + protected static function deleteTable($core,$entry) + { + self::emptyTable($core,$entry); - $core->con->execute( - 'DROP TABLE '.$core->con->escapeSystem($core->prefix.$entry) - ); - } + $core->con->execute( + 'DROP TABLE '.$core->con->escapeSystem($core->prefix.$entry) + ); + } - public static function getVersions($core) - { - $res = $core->con->select('SELECT * FROM '.$core->prefix.'version'); + public static function getVersions($core) + { + $res = $core->con->select('SELECT * FROM '.$core->prefix.'version'); - $rs = array(); - $i = 0; - while ($res->fetch()) { + $rs = array(); + $i = 0; + while ($res->fetch()) { - $rs[$i]['key'] = $res->module; - $rs[$i]['value'] = $res->version; - $i++; - } - return $rs; - } + $rs[$i]['key'] = $res->module; + $rs[$i]['value'] = $res->version; + $i++; + } + return $rs; + } - protected static function deleteVersion($core,$entry) - { - $core->con->execute( - 'DELETE FROM '.$core->prefix.'version '. - "WHERE module = '".$core->con->escape($entry)."' " - ); - } + protected static function deleteVersion($core,$entry) + { + $core->con->execute( + 'DELETE FROM '.$core->prefix.'version '. + "WHERE module = '".$core->con->escape($entry)."' " + ); + } - public static function getPlugins($core) - { - $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); - return self::getDirs($res); - } + public static function getPlugins($core) + { + $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); + return self::getDirs($res); + } - protected static function emptyPlugin($core,$entry) - { - $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); - self::delDir($res,$entry,false); - } + protected static function emptyPlugin($core,$entry) + { + $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); + self::delDir($res,$entry,false); + } - protected static function deletePlugin($core,$entry) - { - $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); - self::delDir($res,$entry,true); - } + protected static function deletePlugin($core,$entry) + { + $res = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT); + self::delDir($res,$entry,true); + } - public static function getThemes($core) - { - return self::getDirs($core->blog->themes_path); - } + public static function getThemes($core) + { + return self::getDirs($core->blog->themes_path); + } - protected static function emptyTheme($core,$entry) - { - self::delDir($core->blog->themes_path,$entry,false); - } + protected static function emptyTheme($core,$entry) + { + self::delDir($core->blog->themes_path,$entry,false); + } - protected static function deleteTheme($core,$entry) - { - self::delDir($core->blog->themes_path,$entry,true); - } + protected static function deleteTheme($core,$entry) + { + self::delDir($core->blog->themes_path,$entry,true); + } - public static function getCaches($core) - { - return self::getDirs(DC_TPL_CACHE); - } + public static function getCaches($core) + { + return self::getDirs(DC_TPL_CACHE); + } - protected static function emptyCache($core,$entry) - { - self::delDir(DC_TPL_CACHE,$entry,false); - } + protected static function emptyCache($core,$entry) + { + self::delDir(DC_TPL_CACHE,$entry,false); + } - protected static function deleteCache($core,$entry) - { - self::delDir(DC_TPL_CACHE,$entry,true); - } + protected static function deleteCache($core,$entry) + { + self::delDir(DC_TPL_CACHE,$entry,true); + } - public static function execute($core,$type,$action,$ns) - { - if (strtolower($ns) == 'dcadvancedcleaner') - throw new exception("dcAdvancedCleaner can't remove itself"); + public static function execute($core,$type,$action,$ns) + { + if (strtolower($ns) == 'dcadvancedcleaner') + throw new exception("dcAdvancedCleaner can't remove itself"); - # BEHAVIOR dcAdvancedCleanerBeforeAction - $core->callBehavior('dcAdvancedCleanerBeforeAction',$type,$action,$ns); + # BEHAVIOR dcAdvancedCleanerBeforeAction + $core->callBehavior('dcAdvancedCleanerBeforeAction',$type,$action,$ns); - try { - # Delete global settings - if ($type == 'settings' && $action == 'delete_global') - self::deleteGlobalSettings($core,$ns); + try { + # Delete global settings + if ($type == 'settings' && $action == 'delete_global') + self::deleteGlobalSettings($core,$ns); - # Delete local settings - if ($type == 'settings' && $action == 'delete_local') - self::deleteLocalSettings($core,$ns); + # Delete local settings + if ($type == 'settings' && $action == 'delete_local') + self::deleteLocalSettings($core,$ns); - # Delete all settings - if ($type == 'settings' && $action == 'delete_all') - self::deleteAllSettings($core,$ns); + # Delete all settings + if ($type == 'settings' && $action == 'delete_all') + self::deleteAllSettings($core,$ns); - # Empty tables - if ($type == 'tables' && $action == 'empty') - self::emptyTable($core,$ns); + # Empty tables + if ($type == 'tables' && $action == 'empty') + self::emptyTable($core,$ns); - # Delete tables - if ($type == 'tables' && $action == 'delete') - self::deleteTable($core,$ns); + # Delete tables + if ($type == 'tables' && $action == 'delete') + self::deleteTable($core,$ns); - # Delete versions - if ($type == 'versions' && $action == 'delete') - self::deleteVersion($core,$ns); + # Delete versions + if ($type == 'versions' && $action == 'delete') + self::deleteVersion($core,$ns); - # Empty plugins - if ($type == 'plugins' && $action == 'empty') - self::emptyPlugin($core,$ns); + # Empty plugins + if ($type == 'plugins' && $action == 'empty') + self::emptyPlugin($core,$ns); - # Delete plugins - if ($type == 'plugins' && $action == 'delete') - self::deletePlugin($core,$ns); + # Delete plugins + if ($type == 'plugins' && $action == 'delete') + self::deletePlugin($core,$ns); - # Empty themes - if ($type == 'themes' && $action == 'empty') - self::emptyTheme($core,$ns); + # Empty themes + if ($type == 'themes' && $action == 'empty') + self::emptyTheme($core,$ns); - # Delete themes - if ($type == 'themes' && $action == 'delete') - self::deleteTheme($core,$ns); + # Delete themes + if ($type == 'themes' && $action == 'delete') + self::deleteTheme($core,$ns); - # Empty caches - if ($type == 'caches' && $action == 'empty') - self::emptyCache($core,$ns); + # Empty caches + if ($type == 'caches' && $action == 'empty') + self::emptyCache($core,$ns); - # Delete caches - if ($type == 'caches' && $action == 'delete') - self::deleteCache($core,$ns); + # Delete caches + if ($type == 'caches' && $action == 'delete') + self::deleteCache($core,$ns); - return true; - } - catch(Exception $e) { - $errors = self::$errors; - if (isset($errors[$type][$action])) { - throw new Exception(__($errors[$type][$action])); - } - else { - throw new Exception(sprintf(__('Cannot execute "%s" of type "%s"'),$action,$type)); - } - return false; - } - } + return true; + } + catch(Exception $e) { + $errors = self::$errors; + if (isset($errors[$type][$action])) { + throw new Exception(__($errors[$type][$action])); + } + else { + throw new Exception(sprintf(__('Cannot execute "%s" of type "%s"'),$action,$type)); + } + return false; + } + } - protected static function getDirs($roots) - { - if (!is_array($roots)) - $roots = array($roots); + protected static function getDirs($roots) + { + if (!is_array($roots)) + $roots = array($roots); - $rs = array(); - $i = 0; - foreach ($roots as $root) { + $rs = array(); + $i = 0; + foreach ($roots as $root) { - $dirs = files::scanDir($root); - foreach($dirs as $k) { + $dirs = files::scanDir($root); + foreach($dirs as $k) { - if ('.' == $k || '..' == $k || !is_dir($root.'/'.$k)) continue; + if ('.' == $k || '..' == $k || !is_dir($root.'/'.$k)) continue; - $rs[$i]['key'] = $k; - $rs[$i]['value'] = count(self::scanDir($root.'/'.$k)); - $i++; - } - } - return $rs; - } + $rs[$i]['key'] = $k; + $rs[$i]['value'] = count(self::scanDir($root.'/'.$k)); + $i++; + } + } + return $rs; + } - protected static function delDir($roots,$folder,$delfolder=true) - { - if (strpos($folder,'/')) - return false; + protected static function delDir($roots,$folder,$delfolder=true) + { + if (strpos($folder,'/')) + return false; - if (!is_array($roots)) - $roots = array($roots); + if (!is_array($roots)) + $roots = array($roots); - foreach ($roots as $root) - { - if (file_exists($root.'/'.$folder)) - return self::delTree($root.'/'.$folder,$delfolder); - } - return false; - } + foreach ($roots as $root) + { + if (file_exists($root.'/'.$folder)) + return self::delTree($root.'/'.$folder,$delfolder); + } + return false; + } - protected static function scanDir($path,$dir='',$res=array()) - { - $exclude = self::$exclude; + protected static function scanDir($path,$dir='',$res=array()) + { + $exclude = self::$exclude; - $path = path::real($path); - if (!is_dir($path) || !is_readable($path)) return array(); + $path = path::real($path); + if (!is_dir($path) || !is_readable($path)) return array(); - $files = files::scandir($path); + $files = files::scandir($path); - foreach($files AS $file) { - if (in_array($file,$exclude)) continue; + foreach($files AS $file) { + if (in_array($file,$exclude)) continue; - if (is_dir($path.'/'.$file)) { + if (is_dir($path.'/'.$file)) { - $res[] = $file; - $res = self::scanDir($path.'/'.$file,$dir.'/'.$file,$res); - } else { + $res[] = $file; + $res = self::scanDir($path.'/'.$file,$dir.'/'.$file,$res); + } else { - $res[] = empty($dir) ? $file : $dir.'/'.$file; - } - } - return $res; - } + $res[] = empty($dir) ? $file : $dir.'/'.$file; + } + } + return $res; + } - protected static function delTree($dir,$delroot=true) - { - if (!is_dir($dir) || !is_readable($dir)) return false; + protected static function delTree($dir,$delroot=true) + { + if (!is_dir($dir) || !is_readable($dir)) return false; - if (substr($dir,-1) != '/') $dir .= '/'; + if (substr($dir,-1) != '/') $dir .= '/'; - if (($d = @dir($dir)) === false) return false; + if (($d = @dir($dir)) === false) return false; - while (($entryname = $d->read()) !== false) - { - if ($entryname != '.' && $entryname != '..') - { - if (is_dir($dir.'/'.$entryname)) - { - if (!self::delTree($dir.'/'.$entryname)) return false; - } - else - { - if (!@unlink($dir.'/'.$entryname)) return false; - } - } - } - $d->close(); + while (($entryname = $d->read()) !== false) + { + if ($entryname != '.' && $entryname != '..') + { + if (is_dir($dir.'/'.$entryname)) + { + if (!self::delTree($dir.'/'.$entryname)) return false; + } + else + { + if (!@unlink($dir.'/'.$entryname)) return false; + } + } + } + $d->close(); - if ($delroot) - return @rmdir($dir); - else - return true; - } + if ($delroot) + return @rmdir($dir); + else + return true; + } } \ No newline at end of file diff --git a/inc/class.dc.uninstaller.php b/inc/class.dc.uninstaller.php index e32cbc8..45c1b40 100644 --- a/inc/class.dc.uninstaller.php +++ b/inc/class.dc.uninstaller.php @@ -1,14 +1,15 @@ array Modules informations array - protected $actions = array('user'=>array(),'callback'=>array()); - protected $callbacks = array('user'=>array(),'callback'=>array()); + protected $modules = array(); ///< array Modules informations array + protected $actions = array('user'=>array(),'callback'=>array()); + protected $callbacks = array('user'=>array(),'callback'=>array()); - protected $id = null; - protected $mroot = null; + protected $id = null; + protected $mroot = null; - /** - Array of all allowed properties to uninstall parts of modules. - 'settings' : settings set on dcSettings, - 'tables' : if module creates table, - 'plugins' : if module has files on plugin path, - 'themes' : if module has files on theme path, (on current blog) - 'caches' : if module has files on DC caches path, - 'versions' : if module set a versions on DC table 'version' - */ - protected static $allowed_properties = array( - 'versions' => array( - 'delete' => 'delete version in dc' - ), - 'settings' => array( - 'delete_global' => 'delete global settings', - 'delete_local' => 'delete local settings', - 'delete_all' => 'delete all settings' - ), - 'tables' => array( - 'empty' => 'empty table', - 'delete' => 'delete table' - ), - 'plugins' => array( - 'empty' => 'empty plugin folder', - 'delete' => 'delete plugin folder' - ), - 'themes' => array( - 'empty' => 'empty theme folder', - 'delete' => 'delete theme folder' - ), - 'caches' => array( - 'empty' => 'empty cache folder', - 'delete' => 'delete cache folder' - ) - ); + /** + Array of all allowed properties to uninstall parts of modules. + 'settings' : settings set on dcSettings, + 'tables' : if module creates table, + 'plugins' : if module has files on plugin path, + 'themes' : if module has files on theme path, (on current blog) + 'caches' : if module has files on DC caches path, + 'versions' : if module set a versions on DC table 'version' + */ + protected static $allowed_properties = array( + 'versions' => array( + 'delete' => 'delete version in dc' + ), + 'settings' => array( + 'delete_global' => 'delete global settings', + 'delete_local' => 'delete local settings', + 'delete_all' => 'delete all settings' + ), + 'tables' => array( + 'empty' => 'empty table', + 'delete' => 'delete table' + ), + 'plugins' => array( + 'empty' => 'empty plugin folder', + 'delete' => 'delete plugin folder' + ), + 'themes' => array( + 'empty' => 'empty theme folder', + 'delete' => 'delete theme folder' + ), + 'caches' => array( + 'empty' => 'empty cache folder', + 'delete' => 'delete cache folder' + ) + ); - protected static $priority_properties = array( - 'versions','settings','tables','themes','plugins','caches' - ); + protected static $priority_properties = array( + 'versions','settings','tables','themes','plugins','caches' + ); - public $core; ///< dcCore dcCore instance - - /** - Object constructor. - - @param core dcCore dcCore instance - */ - public function __construct($core) - { - $this->core =& $core; - } + public $core; ///< dcCore dcCore instance - public static function getAllowedProperties() - { - return self::$allowed_properties; - } - - /** - Loads modules. - Files _defines.php and _uninstall.php must be present on module - to be recognized. - (path separator depends on your OS). - - @param path string Separated list of paths - */ - public function loadModules($path) - { - $this->path = explode(PATH_SEPARATOR,$path); + /** + Object constructor. - foreach ($this->path as $root) - { - if (!is_dir($root) || !is_readable($root)) continue; + @param core dcCore dcCore instance + */ + public function __construct($core) + { + $this->core =& $core; + } - if (substr($root,-1) != '/') $root .= '/'; + public static function getAllowedProperties() + { + return self::$allowed_properties; + } - if (($d = @dir($root)) === false) continue; + /** + Loads modules. + Files _defines.php and _uninstall.php must be present on module + to be recognized. + (path separator depends on your OS). - while (($entry = $d->read()) !== false) - { - $full_entry = $root.'/'.$entry; + @param path string Separated list of paths + */ + public function loadModules($path) + { + $this->path = explode(PATH_SEPARATOR,$path); - if ($entry != '.' && $entry != '..' && is_dir($full_entry)) - { - $this->loadModule($full_entry); - } - } - $d->close(); - } + foreach ($this->path as $root) + { + if (!is_dir($root) || !is_readable($root)) continue; - # Sort modules by name - uasort($this->modules,array($this,'sortModules')); - } - - /** - Load one module. - Files _defines.php and _uninstall.php must be present on module - to be recognized. - - @param root string path of module - */ - public function loadModule($root) - { - if (file_exists($root.'/_define.php') - && file_exists($root.'/_uninstall.php')) { + if (substr($root,-1) != '/') $root .= '/'; - $this->id = basename($root); - $this->mroot = $root; + if (($d = @dir($root)) === false) continue; - require $root.'/_define.php'; - require $root.'/_uninstall.php'; + while (($entry = $d->read()) !== false) + { + $full_entry = $root.'/'.$entry; - $this->id = null; - $this->mroot = null; - } - } - - /** - This method registers a module in modules list. You should use - this to register a new module. - - @param name string Module name - @param desc string Module description - @param author string Module author name - @param version string Module version - */ - public function registerModule($name,$desc,$author,$version) - { - if ($this->id) { - $this->modules[$this->id] = array( - 'root' => $this->mroot, - 'name' => $name, - 'desc' => $desc, - 'author' => $author, - 'version' => $version, - 'root_writable' => is_writable($this->mroot) - ); - } - } - - /** - Returns all modules associative array or only one module if $id - is present. - - @param id string Optionnal module ID - @return array - */ - public function getModules($id=null) - { - if ($id && isset($this->modules[$id])) { - return $this->modules[$id]; - } - return $this->modules; - } - - /** - Returns true if the module with ID $id exists. - - @param id string Module ID - @return boolean - */ - public function moduleExists($id) - { - return isset($this->modules[$id]); - } + if ($entry != '.' && $entry != '..' && is_dir($full_entry)) + { + $this->loadModule($full_entry); + } + } + $d->close(); + } - /** - Add a predefined action to unsintall features. - This action is set in _uninstall.php. - - @param type string Type of action (from $allowed_properties) - @param action string Action (from $allowed_properties) - @param ns string Name of setting related to module. - @param desc string Description of action - */ - protected function addUserAction($type,$action,$ns,$desc='') - { - $this->addAction('user',$type,$action,$ns,$desc); - } + # Sort modules by name + uasort($this->modules,array($this,'sortModules')); + } - protected function addDirectAction($type,$action,$ns,$desc='') - { - $this->addAction('direct',$type,$action,$ns,$desc); - } + /** + Load one module. + Files _defines.php and _uninstall.php must be present on module + to be recognized. - private function addAction($group,$type,$action,$ns,$desc) - { - $group = self::group($group); + @param root string path of module + */ + public function loadModule($root) + { + if (file_exists($root.'/_define.php') + && file_exists($root.'/_uninstall.php')) { - if (null === $this->id) return; + $this->id = basename($root); + $this->mroot = $root; - if (empty($type) || empty($ns)) return; + require $root.'/_define.php'; + require $root.'/_uninstall.php'; - if (!isset(self::$allowed_properties[$type][$action])) return; + $this->id = null; + $this->mroot = null; + } + } - if (empty($desc)) $desc = __($action); + /** + This method registers a module in modules list. You should use + this to register a new module. - $this->actions[$group][$this->id][$type][] = array( - 'ns' => $ns, - 'action' => $action, - 'desc' => $desc - ); - } + @param name string Module name + @param desc string Module description + @param author string Module author name + @param version string Module version + */ + public function registerModule($name,$desc,$author,$version) + { + if ($this->id) { + $this->modules[$this->id] = array( + 'root' => $this->mroot, + 'name' => $name, + 'desc' => $desc, + 'author' => $author, + 'version' => $version, + 'root_writable' => is_writable($this->mroot) + ); + } + } - /** - Returns modules $id predefined actions associative array - ordered by priority - - @param id string Optionnal module ID - @return array - */ - public function getUserActions($id) - { - return $this->getActions('user',$id); - } + /** + Returns all modules associative array or only one module if $id + is present. - public function getDirectActions($id) - { - return $this->getActions('direct',$id); - } + @param id string Optionnal module ID + @return array + */ + public function getModules($id=null) + { + if ($id && isset($this->modules[$id])) { + return $this->modules[$id]; + } + return $this->modules; + } - protected function getActions($group,$id) - { - $group = self::group($group); + /** + Returns true if the module with ID $id exists. - if (!isset($this->actions[$group][$id])) return array(); + @param id string Module ID + @return boolean + */ + public function moduleExists($id) + { + return isset($this->modules[$id]); + } - $res = array(); - foreach(self::$priority_properties as $k => $v) - { - if (!isset($this->actions[$group][$id][$v])) continue; - $res[$v] = $this->actions[$group][$id][$v]; - } + /** + Add a predefined action to unsintall features. + This action is set in _uninstall.php. - return $res; - } + @param type string Type of action (from $allowed_properties) + @param action string Action (from $allowed_properties) + @param ns string Name of setting related to module. + @param desc string Description of action + */ + protected function addUserAction($type,$action,$ns,$desc='') + { + $this->addAction('user',$type,$action,$ns,$desc); + } - /** - Add a callable function for unsintall features. - This action is set in _uninstall.php. - - @param func string Callable function - @param desc string Description of action - */ - protected function addUserCallback($func,$desc='') - { - $this->addCallback('user',$func,$desc); - } + protected function addDirectAction($type,$action,$ns,$desc='') + { + $this->addAction('direct',$type,$action,$ns,$desc); + } - protected function addDirectCallback($func,$desc='') - { - $this->addCallback('direct',$func,$desc); - } + private function addAction($group,$type,$action,$ns,$desc) + { + $group = self::group($group); - private function addCallback($group,$func,$desc) - { - $group = self::group($group); + if (null === $this->id) return; - if (null === $this->id) return; + if (empty($type) || empty($ns)) return; - if (empty($desc)) $desc = __('extra action'); + if (!isset(self::$allowed_properties[$type][$action])) return; - if (!is_callable($func)) return; + if (empty($desc)) $desc = __($action); - $this->callbacks[$group][$this->id][] = array( - 'func' => $func, - 'desc' => $desc - ); - } - - /** - Returns modules $id callback actions associative array - - @param id string Optionnal module ID - @return array - */ - public function getUserCallbacks($id) - { - return $this->getCallbacks('user',$id); - } + $this->actions[$group][$this->id][$type][] = array( + 'ns' => $ns, + 'action' => $action, + 'desc' => $desc + ); + } - public function getDirectCallbacks($id) - { - return $this->getCallbacks('direct',$id); - } + /** + Returns modules $id predefined actions associative array + ordered by priority - protected function getCallbacks($group,$id) - { - $group = self::group($group); + @param id string Optionnal module ID + @return array + */ + public function getUserActions($id) + { + return $this->getActions('user',$id); + } - if (!isset($this->callbacks[$group][$id])) return array(); + public function getDirectActions($id) + { + return $this->getActions('direct',$id); + } - return $this->callbacks[$group][$id]; - } - - /** - Execute a predifined action. This function call dcAdvancedCleaner - to do actions. - - @param type string Type of action (from $allowed_properties) - @param action string Action (from $allowed_properties) - @param ns string Name of setting related to module. - @return array - */ - public function execute($type,$action,$ns) - { - $prop = $this->getAllowedProperties(); + protected function getActions($group,$id) + { + $group = self::group($group); - if (!isset($prop[$type][$action]) || empty($ns)) return; + if (!isset($this->actions[$group][$id])) return array(); - dcAdvancedCleaner::execute($this->core,$type,$action,$ns); - } + $res = array(); + foreach(self::$priority_properties as $k => $v) + { + if (!isset($this->actions[$group][$id][$v])) continue; + $res[$v] = $this->actions[$group][$id][$v]; + } - private function sortModules($a,$b) - { - return strcasecmp($a['name'],$b['name']); - } + return $res; + } - private function group($group) - { - return in_array($group,array('user','direct')) ? $group : null; - } + /** + Add a callable function for unsintall features. + This action is set in _uninstall.php. + + @param func string Callable function + @param desc string Description of action + */ + protected function addUserCallback($func,$desc='') + { + $this->addCallback('user',$func,$desc); + } + + protected function addDirectCallback($func,$desc='') + { + $this->addCallback('direct',$func,$desc); + } + + private function addCallback($group,$func,$desc) + { + $group = self::group($group); + + if (null === $this->id) return; + + if (empty($desc)) $desc = __('extra action'); + + if (!is_callable($func)) return; + + $this->callbacks[$group][$this->id][] = array( + 'func' => $func, + 'desc' => $desc + ); + } + + /** + Returns modules $id callback actions associative array + + @param id string Optionnal module ID + @return array + */ + public function getUserCallbacks($id) + { + return $this->getCallbacks('user',$id); + } + + public function getDirectCallbacks($id) + { + return $this->getCallbacks('direct',$id); + } + + protected function getCallbacks($group,$id) + { + $group = self::group($group); + + if (!isset($this->callbacks[$group][$id])) return array(); + + return $this->callbacks[$group][$id]; + } + + /** + Execute a predifined action. This function call dcAdvancedCleaner + to do actions. + + @param type string Type of action (from $allowed_properties) + @param action string Action (from $allowed_properties) + @param ns string Name of setting related to module. + @return array + */ + public function execute($type,$action,$ns) + { + $prop = $this->getAllowedProperties(); + + if (!isset($prop[$type][$action]) || empty($ns)) return; + + dcAdvancedCleaner::execute($this->core,$type,$action,$ns); + } + + private function sortModules($a,$b) + { + return strcasecmp($a['name'],$b['name']); + } + + private function group($group) + { + return in_array($group,array('user','direct')) ? $group : null; + } } \ No newline at end of file diff --git a/inc/lib.dc.advanced.cleaner.activityreport.php b/inc/lib.dc.advanced.cleaner.activityreport.php index 52ffe36..c88fc7d 100644 --- a/inc/lib.dc.advanced.cleaner.activityreport.php +++ b/inc/lib.dc.advanced.cleaner.activityreport.php @@ -1,14 +1,15 @@ activityReport->addGroup('dcadvancedcleaner',__('Plugin dcAdvancedCleaner # from BEHAVIOR dcAdvancedCleanerBeforeAction # in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php $core->activityReport->addAction( - 'dcadvancedcleaner', - 'maintenance', - __('Maintenance'), - __('New action from dcAdvancedCleaner has been made with type="%s", action="%s", ns="%s".'), - 'dcAdvancedCleanerBeforeAction', - array('dcAdvancedCleanerActivityReportBehaviors','maintenance') + 'dcadvancedcleaner', + 'maintenance', + __('Maintenance'), + __('New action from dcAdvancedCleaner has been made with type="%s", action="%s", ns="%s".'), + 'dcAdvancedCleanerBeforeAction', + array('dcAdvancedCleanerActivityReportBehaviors','maintenance') ); class dcAdvancedCleanerActivityReportBehaviors { - public static function maintenance($type,$action,$ns) - { - $logs = array($type,$action,$ns); + public static function maintenance($type,$action,$ns) + { + $logs = array($type,$action,$ns); - $GLOBALS['core']->activityReport->addLog('dcadvancedcleaner','maintenance',$logs); - } + $GLOBALS['core']->activityReport->addLog('dcadvancedcleaner','maintenance',$logs); + } } \ No newline at end of file diff --git a/inc/lib.dc.advanced.cleaner.behaviors.php b/inc/lib.dc.advanced.cleaner.behaviors.php index e276ae6..d09baab 100644 --- a/inc/lib.dc.advanced.cleaner.behaviors.php +++ b/inc/lib.dc.advanced.cleaner.behaviors.php @@ -1,224 +1,225 @@ blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) return; + if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) return; - $uninstaller = new dcUninstaller($core); - $uninstaller->loadModule($module['root']); + $uninstaller = new dcUninstaller($core); + $uninstaller->loadModule($module['root']); - $m_callbacks = $uninstaller->getDirectCallbacks($module['id']); - $m_actions = $uninstaller->getDirectActions($module['id']); + $m_callbacks = $uninstaller->getDirectCallbacks($module['id']); + $m_actions = $uninstaller->getDirectActions($module['id']); - foreach($m_callbacks as $k => $callback) - { - if (!isset($callback['func']) || !is_callable($callback['func'])) continue; + foreach($m_callbacks as $k => $callback) + { + if (!isset($callback['func']) || !is_callable($callback['func'])) continue; - call_user_func($callback['func'],$module); - $done = true; - } + call_user_func($callback['func'],$module); + $done = true; + } - foreach($m_actions as $type => $actions) - { - foreach($actions as $v) - { - $uninstaller->execute($type,$v['action'],$v['ns']); - $done = true; - } - } + foreach($m_actions as $type => $actions) + { + foreach($actions as $v) + { + $uninstaller->execute($type,$v['action'],$v['ns']); + $done = true; + } + } - if ($done) { - http::redirect($redir); - } - } + if ($done) { + http::redirect($redir); + } + } - public static function dcAdvancedCleanerAdminTabs($core,$p_url) - { - self::modulesTabs($core,DC_PLUGINS_ROOT,$p_url.'&tab=uninstaller'); - } + public static function dcAdvancedCleanerAdminTabs($core,$p_url) + { + self::modulesTabs($core,DC_PLUGINS_ROOT,$p_url.'&tab=uninstaller'); + } - public static function pluginsToolsTabs($core) - { - self::modulesTabs($core,DC_PLUGINS_ROOT,'plugins.php?tab=uninstaller'); - } + public static function pluginsToolsTabs($core) + { + self::modulesTabs($core,DC_PLUGINS_ROOT,'plugins.php?tab=uninstaller'); + } - # Generic module tabs - public static function modulesTabs($core,$path,$redir,$title='') - { - if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) return; + # Generic module tabs + public static function modulesTabs($core,$path,$redir,$title='') + { + if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) return; - $err = ''; - $title = empty($title) ? __('Advanced uninstall') : $title; + $err = ''; + $title = empty($title) ? __('Advanced uninstall') : $title; - $uninstaller = new dcUninstaller($core); - $uninstaller->loadModules($path); - $modules = $uninstaller->getModules(); - $props = $uninstaller->getAllowedProperties(); + $uninstaller = new dcUninstaller($core); + $uninstaller->loadModules($path); + $modules = $uninstaller->getModules(); + $props = $uninstaller->getAllowedProperties(); - # Execute - if (isset($_POST['action']) && $_POST['action'] == 'uninstall' - && (!empty($_POST['extras']) || !empty($_POST['actions']))) { + # Execute + if (isset($_POST['action']) && $_POST['action'] == 'uninstall' + && (!empty($_POST['extras']) || !empty($_POST['actions']))) { - try { - # Extras - if (!empty($_POST['extras'])) { - foreach($_POST['extras'] as $module_id => $extras) - { - foreach($extras as $k => $sentence) - { - $extra = @unserialize(@base64_decode($sentence)); + try { + # Extras + if (!empty($_POST['extras'])) { + foreach($_POST['extras'] as $module_id => $extras) + { + foreach($extras as $k => $sentence) + { + $extra = @unserialize(@base64_decode($sentence)); - if (!$extra || !is_callable($extra)) continue; + if (!$extra || !is_callable($extra)) continue; - call_user_func($extra,$modul_id); - } - } - } - # Actions - if (!empty($_POST['actions'])) { - foreach($_POST['actions'] as $module_id => $actions) - { - foreach($actions as $k => $sentence) - { - $action = @unserialize(@base64_decode($sentence)); + call_user_func($extra,$modul_id); + } + } + } + # Actions + if (!empty($_POST['actions'])) { + foreach($_POST['actions'] as $module_id => $actions) + { + foreach($actions as $k => $sentence) + { + $action = @unserialize(@base64_decode($sentence)); - if (!$action - || !isset($action['type']) - || !isset($action['action']) - || !isset($action['ns'])) continue; + if (!$action + || !isset($action['type']) + || !isset($action['action']) + || !isset($action['ns'])) continue; - $uninstaller->execute($action['type'],$action['action'],$action['ns']); - } - } - } - http::redirect($redir.'&msg=1'); - } - catch(Exception $e) { - $err = $e->getMessage(); - } - } + $uninstaller->execute($action['type'],$action['action'],$action['ns']); + } + } + } + http::redirect($redir.'&msg=1'); + } + catch(Exception $e) { + $err = $e->getMessage(); + } + } - echo - '
'; + echo + '
'; - if($err) - echo '

'.$err.'

'; + if($err) + echo '

'.$err.'

'; - if(!count($modules)) { - echo '

'.__('There is no module with uninstall features').'

'; - return; - } + if(!count($modules)) { + echo '

'.__('There is no module with uninstall features').'

'; + return; + } - echo - '

'.__('List of modules with advanced uninstall features').'

'. - '
'. - ''. - ''. - ''; - - foreach($props as $pro_id => $prop) { - echo ''; - } + echo + '

'.__('List of modules with advanced uninstall features').'

'. + ''. + '
'.__('id').''.__('n°').''.__($pro_id).'
'. + ''. + ''; - echo - ''. - ''; + foreach($props as $pro_id => $prop) { + echo ''; + } - $i = 0; - foreach($modules as $module_id => $module) { + echo + ''. + ''; - echo - ''. - ''. - ''; + $i = 0; + foreach($modules as $module_id => $module) { - $actions = $uninstaller->getUserActions($module_id); + echo + ''. + ''. + ''; - foreach($props as $prop_id => $prop) { - echo ''; - continue; - } + foreach($props as $prop_id => $prop) { + echo ''; + continue; + } - if (!isset($props[$prop_id][$action['action']])) continue; + $j = 0; + foreach($actions[$prop_id] as $action_id => $action) { - $ret = base64_encode(serialize(array( - 'type' => $prop_id, - 'action'=>$action['action'], - 'ns'=>$action['ns'] - ))); + if (!isset($props[$prop_id][$action['action']])) continue; - echo '
'; + $ret = base64_encode(serialize(array( + 'type' => $prop_id, + 'action'=>$action['action'], + 'ns'=>$action['ns'] + ))); - $j++; - } - echo ''; - } + echo '
'; - echo ''; + } - $callbacks = $uninstaller->getUserCallbacks($module_id); + echo ''; - } - echo - '
'.__('id').''.__('n°').''.__('extra').'
'.__($pro_id).''.__('extra').'
'.$module_id.''.$module['version'].'
'.$module_id.''.$module['version'].''; + $actions = $uninstaller->getUserActions($module_id); - if (!isset($actions[$prop_id])) { - echo '--'; - $j = 0; - foreach($actions[$prop_id] as $action_id => $action) { + if (!isset($actions[$prop_id])) { + echo '--'; + $j++; + } + echo ''; - if (empty($callbacks)) { - echo '--'; - } + $callbacks = $uninstaller->getUserCallbacks($module_id); - $k = 0; - foreach($callbacks as $callback_id => $callback) { + if (empty($callbacks)) { + echo '--'; + } - $ret = base64_encode(serialize($callback['func'])); + $k = 0; + foreach($callbacks as $callback_id => $callback) { - echo '
'; - } + $ret = base64_encode(serialize($callback['func'])); - echo '
'. - '

'. - $core->formNonce(). - form::hidden(array('redir'),$redir). - form::hidden(array('action'),'uninstall'). - ' '. - '

'. - '
'. - ''; - } + echo '
'; + } + + echo ''; + } + echo + ''. + '

'. + $core->formNonce(). + form::hidden(array('redir'),$redir). + form::hidden(array('action'),'uninstall'). + ' '. + '

'. + ''. + ''; + } } \ No newline at end of file diff --git a/index.php b/index.php index c5cd569..c072416 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,15 @@ array('dcAdvancedCleaner','getSettings'), - 'tables' => array('dcAdvancedCleaner','getTables'), - 'plugins' => array('dcAdvancedCleaner','getPlugins'), - 'themes' => array('dcAdvancedCleaner','getThemes'), - 'caches' => array('dcAdvancedCleaner','getCaches'), - 'versions' => array('dcAdvancedCleaner','getVersions') - ); - $combo_actions = array( - 'settings' => array( - __('delete global settings') => 'delete_global', - __('delete blog settings') => 'delete_local', - __('delete all settings') =>'delete_all' - ), - 'tables' => array( - __('delete') => 'delete', - __('empty') => 'empty' - ), - 'plugins' => array( - __('delete') => 'delete', - __('empty') => 'empty' - ), - 'themes' => array( - __('delete') => 'delete', - __('empty') => 'empty' - ), - 'caches' => array( - __('delete') => 'delete', - __('empty') => 'empty' - ), - 'versions' => array( - __('delete') => 'delete' - ) - ); - $combo_help = array( - 'settings' => __('Namespaces registered in dcSettings'), - 'tables' => __('All database tables of Dotclear'), - 'plugins' => __('Folders from plugins directories'), - 'themes' => __('Folders from blog themes directory'), - 'caches' => __('Folders from cache directory'), - 'versions' => __('Versions registered in table "version" of Dotclear') - ); + $combo_funcs = array( + 'settings' => array('dcAdvancedCleaner','getSettings'), + 'tables' => array('dcAdvancedCleaner','getTables'), + 'plugins' => array('dcAdvancedCleaner','getPlugins'), + 'themes' => array('dcAdvancedCleaner','getThemes'), + 'caches' => array('dcAdvancedCleaner','getCaches'), + 'versions' => array('dcAdvancedCleaner','getVersions') + ); + $combo_actions = array( + 'settings' => array( + __('delete global settings') => 'delete_global', + __('delete blog settings') => 'delete_local', + __('delete all settings') =>'delete_all' + ), + 'tables' => array( + __('delete') => 'delete', + __('empty') => 'empty' + ), + 'plugins' => array( + __('delete') => 'delete', + __('empty') => 'empty' + ), + 'themes' => array( + __('delete') => 'delete', + __('empty') => 'empty' + ), + 'caches' => array( + __('delete') => 'delete', + __('empty') => 'empty' + ), + 'versions' => array( + __('delete') => 'delete' + ) + ); + $combo_help = array( + 'settings' => __('Namespaces registered in dcSettings'), + 'tables' => __('All database tables of Dotclear'), + 'plugins' => __('Folders from plugins directories'), + 'themes' => __('Folders from blog themes directory'), + 'caches' => __('Folders from cache directory'), + 'versions' => __('Versions registered in table "version" of Dotclear') + ); - if (!isset($combo_funcs[$type])) return ''; + if (!isset($combo_funcs[$type])) return ''; - $rs = call_user_func($combo_funcs[$type],$core); + $rs = call_user_func($combo_funcs[$type],$core); - echo - '
'. - '

'.$combo_help[$type].'

'; - - if (empty($rs)) { - echo - '

'.sprintf(__('There is no %s'),__(substr($type,0,-1))).'

'; - } else { + echo + '
'. + '

'.$combo_help[$type].'

'; - echo - '

'.sprintf(__('There are %s %s'),count($rs),__($type)).'

'. - '
'. - ''. - ''. - ''; + if (empty($rs)) { + echo + '

'.sprintf(__('There is no %s'),__(substr($type,0,-1))).'

'; + } else { - foreach($rs as $k => $v) - { - $offline = in_array($v['key'],dcAdvancedCleaner::$dotclear[$type]); + echo + '

'.sprintf(__('There are %s %s'),count($rs),__($type)).'

'. + ''. + '
'.__('Name').''.__('Objects').'
'. + ''. + ''; - if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide && $offline) continue; + foreach($rs as $k => $v) + { + $offline = in_array($v['key'],dcAdvancedCleaner::$dotclear[$type]); - echo - ''. - ''. - ''. - ''; - } + if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide && $offline) continue; - echo - '
'.__('Name').''.__('Objects').'
'.$v['value'].'
'. - '

'.__('Action on selected rows:').'
'. - form::combo(array('action'),$combo_actions[$type]). - ''. - form::hidden(array('p'),'dcAdvancedCleaner'). - form::hidden(array('tab'),'lists'). - form::hidden(array('part'),$type). - form::hidden(array('type'),$type). - $core->formNonce().'

'. - '
'; - } - echo - '
'; + echo + ''. + ''. + ''.$v['value'].''. + ''; + } + + echo + ''. + '

'.__('Action on selected rows:').'
'. + form::combo(array('action'),$combo_actions[$type]). + ''. + form::hidden(array('p'),'dcAdvancedCleaner'). + form::hidden(array('tab'),'lists'). + form::hidden(array('part'),$type). + form::hidden(array('type'),$type). + $core->formNonce().'

'. + ''; + } + echo + '
'; } # Localized l10n @@ -147,35 +148,35 @@ $s = $core->blog->settings->dcAdvancedCleaner; # Combos $combo_title = array( - 'settings' => __('Settings'), - 'tables' => __('Tables'), - 'plugins' => __('Extensions'), - 'themes' => __('Themes'), - 'caches' => __('Cache'), - 'versions' => __('Versions') + 'settings' => __('Settings'), + 'tables' => __('Tables'), + 'plugins' => __('Extensions'), + 'themes' => __('Themes'), + 'caches' => __('Cache'), + 'versions' => __('Versions') ); - + $combo_type = array( - 'settings' => array('delete_global','delete_local','delete_all'), - 'tables' => array('empty','delete'), - 'plugins' => array('empty','delete'), - 'themes' => array('empty','delete'), - 'caches' => array('empty','delete'), - 'versions' => array('delete') + 'settings' => array('delete_global','delete_local','delete_all'), + 'tables' => array('empty','delete'), + 'plugins' => array('empty','delete'), + 'themes' => array('empty','delete'), + 'caches' => array('empty','delete'), + 'versions' => array('delete') ); # This plugin settings if ($tab == 'dcac' && $action == 'dcadvancedcleaner_settings') { - try { - $s->put('dcAdvancedCleaner_behavior_active',isset($_POST['dcadvancedcleaner_behavior_active']),'boolean'); - $s->put('dcAdvancedCleaner_dcproperty_hide',isset($_POST['dcadvancedcleaner_dcproperty_hide']),'boolean'); + try { + $s->put('dcAdvancedCleaner_behavior_active',isset($_POST['dcadvancedcleaner_behavior_active']),'boolean'); + $s->put('dcAdvancedCleaner_dcproperty_hide',isset($_POST['dcadvancedcleaner_dcproperty_hide']),'boolean'); - http::redirect($p_url.'&tab=dcac&part=dcac&part=&msg=done'); - } - catch(Exception $e) { - $core->error->add($e->getMessage()); - } + http::redirect($p_url.'&tab=dcac&part=dcac&part=&msg=done'); + } + catch(Exception $e) { + $core->error->add($e->getMessage()); + } } # Actions @@ -183,16 +184,16 @@ if ($tab == 'lists' && !empty($entries) && isset($combo_type[$type]) && in_array($action,$combo_type[$type])) { - try { - foreach($entries as $v) { - dcAdvancedCleaner::execute($core,$type,$action,$v); - } + try { + foreach($entries as $v) { + dcAdvancedCleaner::execute($core,$type,$action,$v); + } - http::redirect($p_url.'&tab=lists&part='.$part.'&msg=done'); - } - catch(Exception $e) { - $core->error->add($e->getMessage()); - } + http::redirect($p_url.'&tab=lists&part='.$part.'&msg=done'); + } + catch(Exception $e) { + $core->error->add($e->getMessage()); + } } echo ' @@ -208,7 +209,7 @@ $core->callBehavior('dcAdvancedCleanerAdminHeader',$core,$p_url,$tab); echo ' '. - dcPage::breadcrumb( + dcPage::breadcrumb( array( html::escapeHTML($core->blog->name) => '', ''.$page_title.'' => '' @@ -225,20 +226,20 @@ echo '
' '

'; foreach($combo_title as $k => $v) { - echo ''.$v.' '; + echo ''.$v.' '; } echo '

'; - + # Load "part" page if (isset($combo_title[$part])) { - echo '
'.$combo_title[$part].''; - drawDcAdvancedCleanerLists($core,$part); - echo '
'; + echo '
'.$combo_title[$part].''; + drawDcAdvancedCleanerLists($core,$part); + echo '
'; } if ($s->dcAdvancedCleaner_dcproperty_hide) { - echo '

'.__('Default values of Dotclear are hidden. You can change this in settings tab').'

'; + echo '

'.__('Default values of Dotclear are hidden. You can change this in settings tab').'

'; } echo '
'; @@ -278,5 +279,4 @@ echo ' dcAdvancedCleaner - '.$core->plugins->moduleInfo('dcAdvancedCleaner','version').'  dcMiniUrl

-'; -?> \ No newline at end of file +'; \ No newline at end of file diff --git a/locales/en/resources.php b/locales/en/resources.php index 21a5735..540484c 100644 --- a/locales/en/resources.php +++ b/locales/en/resources.php @@ -12,5 +12,5 @@ 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'; } \ No newline at end of file diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php index 2997420..fe57041 100644 --- a/locales/fr/main.lang.php +++ b/locales/fr/main.lang.php @@ -187,6 +187,4 @@ $GLOBALS['__l10n']['Hide Dotclear default properties in actions tabs'] = 'Cacher #index.php:262 $GLOBALS['__l10n']['Prevent from deleting Dotclear important properties.'] = 'Évite de supprimer des propriétés importantes de Dotclear.'; -$GLOBALS['__l10n']['Make a huge cleaning of dotclear'] = 'Faites un énorme nettoyage de dotclear'; - -?> \ No newline at end of file +$GLOBALS['__l10n']['Make a huge cleaning of dotclear'] = 'Faites un énorme nettoyage de dotclear'; \ No newline at end of file diff --git a/locales/fr/resources.php b/locales/fr/resources.php index 21a5735..540484c 100644 --- a/locales/fr/resources.php +++ b/locales/fr/resources.php @@ -12,5 +12,5 @@ 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'; } \ No newline at end of file