diff options
Diffstat (limited to 'inc/plugincontroller.class.php')
-rw-r--r-- | inc/plugincontroller.class.php | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index d80cd4c9e..8d20f885d 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -66,14 +66,14 @@ class Doku_Plugin_Controller { * @param $name string name of the plugin to load * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance * @param $disabled bool true to load even disabled plugins - * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|null the plugin object or null on failure + * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|DokuWiki_Auth_Plugin|DokuWiki_Admin_Plugin|DokuWiki_Action_Plugin|DokuWiki_Remote_Plugin|null the plugin object or null on failure */ public function load($type,$name,$new=false,$disabled=false){ //we keep all loaded plugins available in global scope for reuse global $DOKU_PLUGINS; - list($plugin,$component) = $this->_splitName($name); + list($plugin, /* $component */) = $this->_splitName($name); // check if disabled if(!$disabled && $this->isdisabled($plugin)){ @@ -114,7 +114,7 @@ class Doku_Plugin_Controller { * Whether plugin is disabled * * @param string $plugin name of plugin - * @return bool; true disabled, false enabled + * @return bool true disabled, false enabled */ public function isdisabled($plugin) { return empty($this->tmp_plugins[$plugin]); @@ -124,7 +124,7 @@ class Doku_Plugin_Controller { * Disable the plugin * * @param string $plugin name of plugin - * @return bool; true saving succeed, false saving failed + * @return bool true saving succeed, false saving failed */ public function disable($plugin) { if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; @@ -136,7 +136,7 @@ class Doku_Plugin_Controller { * Enable the plugin * * @param string $plugin name of plugin - * @return bool; true saving succeed, false saving failed + * @return bool true saving succeed, false saving failed */ public function enable($plugin) { if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; @@ -177,9 +177,11 @@ class Doku_Plugin_Controller { // disabling mechanism was changed back very soon again // to keep everything simple we just skip the plugin completely continue; - } elseif (@file_exists(DOKU_PLUGIN.$plugin.'/disabled')) { - // treat this as a default disabled plugin(over-rideable by the plugin manager) - // deprecated 2011-09-10 (usage of disabled files) + } elseif (file_exists(DOKU_PLUGIN.$plugin.'/disabled')) { + /** + * treat this as a default disabled plugin(over-rideable by the plugin manager) + * @deprecated 2011-09-10 (usage of disabled files) + */ if (empty($this->plugin_cascade['local'][$plugin])) { $all_plugins[$plugin] = 0; } else { @@ -227,7 +229,7 @@ class Doku_Plugin_Controller { * @param bool $forceSave; * false to save only when config changed * true to always save - * @return bool; true saving succeed, false saving failed + * @return bool true saving succeed, false saving failed */ protected function saveList($forceSave = false) { global $conf; @@ -245,9 +247,9 @@ class Doku_Plugin_Controller { $out .= "\$plugins['$plugin'] = $value;\n"; } // backup current file (remove any existing backup) - if (@file_exists($file)) { + if (file_exists($file)) { $backup = $file.'.bak'; - if (@file_exists($backup)) @unlink($backup); + if (file_exists($backup)) @unlink($backup); if (!@copy($file,$backup)) return false; if (!empty($conf['fperm'])) chmod($backup, $conf['fperm']); } @@ -280,7 +282,7 @@ class Doku_Plugin_Controller { /** * Build the list of plugins and cascade - * + * */ protected function loadConfig() { global $config_cascade; @@ -300,35 +302,37 @@ class Doku_Plugin_Controller { /** * Returns a list of available plugin components of given type * - * @param string $type, plugin_type name; - * the type of plugin to return, - * @param bool $enabled; - * true to return enabled plugins, - * false to return disabled plugins - * + * @param string $type plugin_type name; the type of plugin to return, + * @param bool $enabled true to return enabled plugins, + * false to return disabled plugins * @return array of plugin components of requested type */ protected function _getListByType($type, $enabled) { $master_list = $enabled ? array_keys(array_filter($this->tmp_plugins)) : array_keys(array_filter($this->tmp_plugins,array($this,'negate'))); - $plugins = array(); + foreach ($master_list as $plugin) { - $dir = $this->get_directory($plugin); - if (@file_exists(DOKU_PLUGIN."$dir/$type.php")){ + $basedir = $this->get_directory($plugin); + if (file_exists(DOKU_PLUGIN."$basedir/$type.php")){ $plugins[] = $plugin; - } else { - if ($dp = @opendir(DOKU_PLUGIN."$dir/$type/")) { + continue; + } + + $typedir = DOKU_PLUGIN."$basedir/$type/"; + if (is_dir($typedir)) { + if ($dp = opendir($typedir)) { while (false !== ($component = readdir($dp))) { if (substr($component,0,1) == '.' || strtolower(substr($component, -4)) != ".php") continue; - if (is_file(DOKU_PLUGIN."$dir/$type/$component")) { + if (is_file($typedir.$component)) { $plugins[] = $plugin.'_'.substr($component, 0, -4); } } closedir($dp); } } - } + + }//foreach return $plugins; } |