From 98aafb569ee3413b93cd9c25844b6494d6490693 Mon Sep 17 00:00:00 2001 From: Hakan Sandell <sandell.hakan@gmail.com> Date: Sat, 10 Sep 2011 10:59:10 +0200 Subject: [PATCH] Code cleanup documentation before merge Function get_plugin_components() moved to extantion manager --- conf/plugins.protected.php | 5 +++++ inc/lang/en/lang.php | 2 +- inc/plugincontroller.class.php | 14 ++++++++------ inc/pluginutils.php | 27 --------------------------- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/conf/plugins.protected.php b/conf/plugins.protected.php index bdfe821c5..26eb8888b 100644 --- a/conf/plugins.protected.php +++ b/conf/plugins.protected.php @@ -1,4 +1,9 @@ <?php +/** + * This file configures the enabled/disabled status of plugins, which are also protected + * from changes by the extention manager. These settings will override any local settings. + * It is not recommended to change this file, as it is overwritten on DokuWiki upgrades. + */ $plugins['acl'] = 1; $plugins['plugin'] = 1; $plugins['config'] = 1; diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 02dff5cb7..de8385dd9 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -318,5 +318,5 @@ $lang['seconds'] = '%d seconds ago'; $lang['wordblock'] = 'Your change was not saved because it contains blocked text (spam).'; -$lang['plugin_insterr'] = "Plugin installed incorrectly. Rename plugin directory '%s' to '%s'."; +$lang['plugin_install_err'] = "Plugin installed incorrectly. Rename plugin directory '%s' to '%s'."; //Setup VIM: ex: et ts=2 : diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 6dcdcdfff..a6685ca2f 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -14,7 +14,7 @@ class Doku_Plugin_Controller { var $list_bytype = array(); var $tmp_plugins = array(); var $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>array()); - var $last_local = ''; + var $last_local_config_file = ''; //backup of tmp_plugins needed for write check var $tmp_bak =array(); @@ -71,7 +71,8 @@ class Doku_Plugin_Controller { function load($type,$name,$new=false,$disabled=false){ //we keep all loaded plugins available in global scope for reuse - global $DOKU_PLUGINS,$lang; + global $DOKU_PLUGINS; + global $lang; list($plugin,$component) = $this->_splitName($name); @@ -98,7 +99,7 @@ class Doku_Plugin_Controller { $dir = $this->get_directory($plugin); $inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt"); if($inf['base'] && $inf['base'] != $plugin){ - msg(sprintf($lang['plugin_insterr'],hsc($plugin),hsc($inf['base'])),-1); + msg(sprintf($lang['plugin_install_err'],hsc($plugin),hsc($inf['base'])),-1); } return null; } @@ -129,6 +130,7 @@ class Doku_Plugin_Controller { protected function _populateMasterList() { if ($dh = @opendir(DOKU_PLUGIN)) { + $all_plugins = array(); while (false !== ($plugin = readdir($dh))) { if ($plugin[0] == '.') continue; // skip hidden entries if (is_file(DOKU_PLUGIN.$plugin)) continue; // skip files, we're only interested in directories @@ -188,7 +190,7 @@ class Doku_Plugin_Controller { $local_plugins = $this->rebuildLocal(); //only write if the list has changed if($local_plugins != $this->plugin_cascade['local']) { - $file = $this->last_local; + $file = $this->last_local_config_file; $out = "<?php\n"; foreach ($local_plugins as $plugin => $value) { $out .= "\$plugins['$plugin'] = $value;\n"; @@ -243,8 +245,8 @@ class Doku_Plugin_Controller { $this->plugin_cascade[$type] = $this->checkRequire($config_cascade['plugins'][$type]); } $local = $config_cascade['plugins']['local']; - $this->last_local = array_pop($local); - $this->plugin_cascade['local'] = $this->checkRequire(array($this->last_local)); + $this->last_local_config_file = array_pop($local); + $this->plugin_cascade['local'] = $this->checkRequire(array($this->last_local_config_file)); if(is_array($local)) { $this->plugin_cascade['default'] = array_merge($this->plugin_cascade['default'],$this->checkRequire($local)); } diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 897020a6c..53cfedf82 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -40,30 +40,3 @@ function plugin_getcascade() { global $plugin_controller; return $plugin_controller->getCascade(); } -/** - * return a list (name & type) of all the component plugins that make up this plugin - * - */ -function get_plugin_components($plugin) { - global $plugin_types; - static $plugins; - if(empty($plugins[$plugin])) { - $components = array(); - $path = DOKU_PLUGIN.plugin_directory($plugin).'/'; - - foreach ($plugin_types as $type) { - if (@file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; } - - if ($dh = @opendir($path.$type.'/')) { - while (false !== ($cp = readdir($dh))) { - if ($cp == '.' || $cp == '..' || strtolower(substr($cp,-4)) != '.php') continue; - - $components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type); - } - closedir($dh); - } - } - $plugins[$plugin] = $components; - } - return $plugins[$plugin]; -} -- GitLab