From b838050e5828b5cbf32b9e82ce11c9cc54592809 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Sat, 20 Aug 2011 19:11:52 +0530 Subject: added new plugins config cascade and added plugin.info.txt --- inc/config_cascade.php | 5 ++ inc/infoutils.php | 4 +- inc/lang/en/lang.php | 2 +- inc/plugincontroller.class.php | 167 ++++++++++++++++++++++++++++++++++------- inc/pluginutils.php | 33 +++++++- 5 files changed, 179 insertions(+), 32 deletions(-) (limited to 'inc') diff --git a/inc/config_cascade.php b/inc/config_cascade.php index 48ed5a000..c01778e99 100644 --- a/inc/config_cascade.php +++ b/inc/config_cascade.php @@ -64,6 +64,11 @@ $config_cascade = array_merge( 'plainauth.users' => array( 'default' => DOKU_CONF.'users.auth.php', ), + + 'plugins' => array( + 'local' => array(DOKU_CONF.'plugins.local.php'), + 'protected' => array(DOKU_CONF.'plugins.protected.php'), + ), ), $config_cascade ); diff --git a/inc/infoutils.php b/inc/infoutils.php index 786661d01..f1deec66b 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -66,8 +66,8 @@ function getVersionData(){ $chunk = fread($fh,2000); fclose($fh); $chunk = trim($chunk); - $chunk = array_pop(explode("\n",$chunk)); //last log line - $chunk = array_shift(explode("\t",$chunk)); //strip commit msg + $chunk = @array_pop(explode("\n",$chunk)); //last log line + $chunk = @array_shift(explode("\t",$chunk)); //strip commit msg $chunk = explode(" ",$chunk); array_pop($chunk); //strip timezone $date = date('Y-m-d',array_pop($chunk)); diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 95356f7b4..02dff5cb7 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'."; //Setup VIM: ex: et ts=2 : diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index ea5725d47..6dcdcdfff 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -11,11 +11,18 @@ if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); class Doku_Plugin_Controller { - var $list_enabled = array(); - var $list_disabled = array(); var $list_bytype = array(); + var $tmp_plugins = array(); + var $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>array()); + var $last_local = ''; + //backup of tmp_plugins needed for write check + var $tmp_bak =array(); - function Doku_Plugin_Controller() { + /** + * Populates the master list of plugins + */ + function __construct() { + $this->loadConfig(); $this->_populateMasterList(); } @@ -37,7 +44,7 @@ class Doku_Plugin_Controller { // request the complete list if (!$type) { - return $all ? array_merge($this->list_enabled,$this->list_disabled) : $this->list_enabled; + return $all ? array_keys($this->tmp_plugins) : array_keys(array_filter($this->tmp_plugins)); } if (!isset($this->list_bytype[$type]['enabled'])) { @@ -61,9 +68,10 @@ class Doku_Plugin_Controller { * @param $disabled bool true to load even disabled plugins * @return objectreference the plugin object or null on failure */ - function &load($type,$name,$new=false,$disabled=false){ + function load($type,$name,$new=false,$disabled=false){ + //we keep all loaded plugins available in global scope for reuse - global $DOKU_PLUGINS; + global $DOKU_PLUGINS,$lang; list($plugin,$component) = $this->_splitName($name); @@ -85,12 +93,12 @@ class Doku_Plugin_Controller { //construct class and instantiate if (!class_exists($class, true)) { + # the plugin might be in the wrong directory $dir = $this->get_directory($plugin); $inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt"); if($inf['base'] && $inf['base'] != $plugin){ - msg("Plugin installed incorrectly. Rename plugin directory '". - hsc($plugin)."' to '".hsc($inf['base'])."'.",-1); + msg(sprintf($lang['plugin_insterr'],hsc($plugin),hsc($inf['base'])),-1); } return null; } @@ -100,30 +108,27 @@ class Doku_Plugin_Controller { } function isdisabled($plugin) { - return (array_search($plugin, $this->list_enabled) === false); + return empty($this->tmp_plugins[$plugin]); } - function enable($plugin) { - if (array_search($plugin, $this->list_disabled) !== false) { - return @unlink(DOKU_PLUGIN.$plugin.'/disabled'); - } - return false; + function disable($plugin) { + if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; + $this->tmp_plugins[$plugin] = 0; + return $this->saveList(); } - function disable($plugin) { - if (array_search($plugin, $this->list_enabled) !== false) { - return @touch(DOKU_PLUGIN.$plugin.'/disabled'); - } - return false; + function enable($plugin) { + if(array_key_exists($plugin,$this->plugin_cascade['protected'])) return false; + $this->tmp_plugins[$plugin] = 1; + return $this->saveList(); } function get_directory($plugin) { return $plugin; } - function _populateMasterList() { - global $conf; - if ($dh = opendir(DOKU_PLUGIN)) { + protected function _populateMasterList() { + if ($dh = @opendir(DOKU_PLUGIN)) { 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 @@ -132,19 +137,123 @@ class Doku_Plugin_Controller { // the plugin was disabled by rc2009-01-26 // disabling mechanism was changed back very soon again // to keep everything simple we just skip the plugin completely - }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled') || + }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')) { + if(empty($this->plugin_cascade['local'][$plugin])) + $all_plugins[$plugin] = 0; + else + $all_plugins[$plugin] = 1; + //treat this as a default disabled plugin(over-rideable by the plugin manager) + $this->plugin_cascade['default'][$plugin] = 0; + //TODO take this out before final release, + //it is here only for other developers to be able to switch branches easily + //@unlink(DOKU_PLUGIN.$plugin.'/disabled'); + continue; + } + elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 0) || ($plugin === 'plugin' && isset($conf['pluginmanager']) && !$conf['pluginmanager'])){ - $this->list_disabled[] = $plugin; + $all_plugins[$plugin] = 0; + } elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 1)) { + $all_plugins[$plugin] = 1; } else { - $this->list_enabled[] = $plugin; + $all_plugins[$plugin] = 1; } } + $this->tmp_plugins = $all_plugins; + $this->saveList(); } } + protected function checkRequire($files) { + $plugins = array(); + foreach($files as $file) { + if(file_exists($file)) { + @include_once($file); + } + } + return $plugins; + } + + function getCascade() { + return $this->plugin_cascade; + } + /** + * Save the current list of plugins + */ + function saveList() { + if(!empty($this->tmp_plugins)) { + //quick check to ensure rewrite is necessary + if($this->tmp_plugins != $this->tmp_bak) { + //Rebuild local for better check and saving + $local_plugins = $this->rebuildLocal(); + //only write if the list has changed + if($local_plugins != $this->plugin_cascade['local']) { + $file = $this->last_local; + $out = " $value) { + $out .= "\$plugins['$plugin'] = $value;\n"; + } + // backup current file (remove any existing backup) + if (@file_exists($file)) { + if (@file_exists($file.'.bak')) @unlink($file.'.bak'); + if (!io_rename($file, $file.'.bak')) return false; + } + //check if can open for writing, else restore + if (!$fh = @fopen($file, 'wb')) { + io_rename($file.'.bak', $file);// problem opening, restore the backup + return false; + } + @fwrite($fh, $out); + fclose($fh); + return true; + } + } + } + return false; + } + + /** + * Rebuild the set of local plugins + * @return array array of plugins to be saved in end($config_cascade['plugins']['local']) + */ + function rebuildLocal() { + //assign to local variable to avoid overwriting + $backup = $this->tmp_plugins; + //Can't do anything about protected one so rule them out completely + $local_default = array_diff_key($backup,$this->plugin_cascade['protected']); + //Diff between local+default and default + //gives us the ones we need to check and save + $diffed_ones = array_diff_key($local_default,$this->plugin_cascade['default']); + //The ones which we are sure of (list of 0s not in default) + $sure_plugins = array_filter($diffed_ones,array($this,'negate')); + //the ones in need of diff + $conflicts = array_diff_key($local_default,$diffed_ones); + //The final list + return array_merge($sure_plugins,array_diff_assoc($conflicts,$this->plugin_cascade['default'])); + } + + /** + * Build the list of plugins and cascade + * + */ + function loadConfig() { + global $config_cascade; + foreach(array('default','protected') as $type) { + if(array_key_exists($type,$config_cascade['plugins'])) + $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)); + if(is_array($local)) { + $this->plugin_cascade['default'] = array_merge($this->plugin_cascade['default'],$this->checkRequire($local)); + } + $this->tmp_plugins = array_merge($this->plugin_cascade['default'],$this->plugin_cascade['local'],$this->plugin_cascade['protected']); + $this->tmp_bak = $this->tmp_plugins; + } + function _getListByType($type, $enabled) { - $master_list = $enabled ? $this->list_enabled : $this->list_disabled; + $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) { @@ -169,11 +278,13 @@ class Doku_Plugin_Controller { } function _splitName($name) { - if (array_search($name, $this->list_enabled + $this->list_disabled) === false) { + if (array_search($name, array_keys($this->tmp_plugins)) === false) { return explode('_',$name,2); } return array($name,''); } - + function negate($input) { + return !(bool) $input; + } } diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 85bcaee1e..897020a6c 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -16,7 +16,7 @@ function plugin_list($type='',$all=false) { global $plugin_controller; return $plugin_controller->getList($type,$all); } -function &plugin_load($type,$name,$new=false,$disabled=false) { +function plugin_load($type,$name,$new=false,$disabled=false) { global $plugin_controller; return $plugin_controller->load($type,$name,$new,$disabled); } @@ -36,3 +36,34 @@ function plugin_directory($plugin) { global $plugin_controller; return $plugin_controller->get_directory($plugin); } +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]; +} -- cgit v1.2.3 From 98aafb569ee3413b93cd9c25844b6494d6490693 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 10:59:10 +0200 Subject: Code cleanup documentation before merge Function get_plugin_components() moved to extantion manager --- inc/lang/en/lang.php | 2 +- inc/plugincontroller.class.php | 14 ++++++++------ inc/pluginutils.php | 27 --------------------------- 3 files changed, 9 insertions(+), 34 deletions(-) (limited to 'inc') 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 = " $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]; -} -- cgit v1.2.3 From 9036904c40c369c2dffd8d0bc44b1239013e8eb5 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 14:27:48 +0200 Subject: Usage of 'disabled' file to control plugins deprecated Plugins with a disabled file will be treated as having an entry (=0) in conf/plugins.default.php overridable by conf/plugins.local.php --- inc/plugincontroller.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index a6685ca2f..2910e6de0 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -140,21 +140,20 @@ class Doku_Plugin_Controller { // disabling mechanism was changed back very soon again // to keep everything simple we just skip the plugin completely }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 $all_plugins[$plugin] = 1; - //treat this as a default disabled plugin(over-rideable by the plugin manager) $this->plugin_cascade['default'][$plugin] = 0; - //TODO take this out before final release, - //it is here only for other developers to be able to switch branches easily - //@unlink(DOKU_PLUGIN.$plugin.'/disabled'); - continue; + } elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 0) || ($plugin === 'plugin' && isset($conf['pluginmanager']) && !$conf['pluginmanager'])){ $all_plugins[$plugin] = 0; + } elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 1)) { $all_plugins[$plugin] = 1; } else { @@ -162,7 +161,6 @@ class Doku_Plugin_Controller { } } $this->tmp_plugins = $all_plugins; - $this->saveList(); } } -- cgit v1.2.3 From 48e46d886a3fbb772a8a64be7ff642ccd7613701 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 14:32:04 +0200 Subject: Whitespace and brackets cleanup --- inc/plugincontroller.class.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 2910e6de0..632814d3c 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -139,22 +139,21 @@ class Doku_Plugin_Controller { // the plugin was disabled by rc2009-01-26 // disabling mechanism was changed back very soon again // to keep everything simple we just skip the plugin completely - }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')) { + } 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])) + if (empty($this->plugin_cascade['local'][$plugin])) { $all_plugins[$plugin] = 0; - else + } else { $all_plugins[$plugin] = 1; + } $this->plugin_cascade['default'][$plugin] = 0; - } - elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 0) || - ($plugin === 'plugin' && isset($conf['pluginmanager']) && - !$conf['pluginmanager'])){ + } elseif ((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 0) || + ($plugin === 'plugin' && isset($conf['pluginmanager']) && !$conf['pluginmanager'])){ $all_plugins[$plugin] = 0; - } elseif((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 1)) { + } elseif ((array_key_exists($plugin,$this->tmp_plugins) && $this->tmp_plugins[$plugin] == 1)) { $all_plugins[$plugin] = 1; } else { $all_plugins[$plugin] = 1; -- cgit v1.2.3 From 4645e48889676e072a61645e5c6f0664dd5d906c Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 15:03:11 +0200 Subject: Now using io_savefile with locking and added header when saving plugin.local --- inc/plugincontroller.class.php | 48 +++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 632814d3c..3ad0676d7 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -176,37 +176,33 @@ class Doku_Plugin_Controller { function getCascade() { return $this->plugin_cascade; } + /** * Save the current list of plugins */ function saveList() { - if(!empty($this->tmp_plugins)) { - //quick check to ensure rewrite is necessary - if($this->tmp_plugins != $this->tmp_bak) { - //Rebuild local for better check and saving - $local_plugins = $this->rebuildLocal(); - //only write if the list has changed - if($local_plugins != $this->plugin_cascade['local']) { - $file = $this->last_local_config_file; - $out = " $value) { - $out .= "\$plugins['$plugin'] = $value;\n"; - } - // backup current file (remove any existing backup) - if (@file_exists($file)) { - if (@file_exists($file.'.bak')) @unlink($file.'.bak'); - if (!io_rename($file, $file.'.bak')) return false; - } - //check if can open for writing, else restore - if (!$fh = @fopen($file, 'wb')) { - io_rename($file.'.bak', $file);// problem opening, restore the backup - return false; - } - @fwrite($fh, $out); - fclose($fh); - return true; - } + global $conf; + + if (empty($this->tmp_plugins)) return false; + if ($this->tmp_plugins == $this->tmp_bak) return false; + + // Rebuild list of local settings + $local_plugins = $this->rebuildLocal(); + if($local_plugins != $this->plugin_cascade['local']) { + $file = $this->last_local_config_file; + $out = " $value) { + $out .= "\$plugins['$plugin'] = $value;\n"; + } + // backup current file (remove any existing backup) + if (@file_exists($file)) { + $backup = $file.'.bak'; + if (@file_exists($backup)) @unlink($backup); + if (!@copy($file,$backup)) return false; + if ($conf['fperm']) chmod($backup, $conf['fperm']); } + //check if can open for writing, else restore + return io_saveFile($file,$out); } return false; } -- cgit v1.2.3 From 25b1f51433d8d2643fae1754ecaf3b8ec986ffe2 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 18:48:15 +0200 Subject: Removed tmp_bak array, no need for checking before save if anything changed --- inc/plugincontroller.class.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 3ad0676d7..aa5d0af57 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -15,8 +15,6 @@ class Doku_Plugin_Controller { var $tmp_plugins = array(); var $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>array()); var $last_local_config_file = ''; - //backup of tmp_plugins needed for write check - var $tmp_bak =array(); /** * Populates the master list of plugins @@ -184,7 +182,6 @@ class Doku_Plugin_Controller { global $conf; if (empty($this->tmp_plugins)) return false; - if ($this->tmp_plugins == $this->tmp_bak) return false; // Rebuild list of local settings $local_plugins = $this->rebuildLocal(); @@ -244,7 +241,6 @@ class Doku_Plugin_Controller { $this->plugin_cascade['default'] = array_merge($this->plugin_cascade['default'],$this->checkRequire($local)); } $this->tmp_plugins = array_merge($this->plugin_cascade['default'],$this->plugin_cascade['local'],$this->plugin_cascade['protected']); - $this->tmp_bak = $this->tmp_plugins; } function _getListByType($type, $enabled) { -- cgit v1.2.3 From c8f071abd276c4c381eacabead655799db4a7a2f Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 18:54:23 +0200 Subject: Added comment in conf/plugins.local about how disabled files work --- inc/plugincontroller.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index aa5d0af57..cdaee2e8f 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -187,7 +187,8 @@ class Doku_Plugin_Controller { $local_plugins = $this->rebuildLocal(); if($local_plugins != $this->plugin_cascade['local']) { $file = $this->last_local_config_file; - $out = " $value) { $out .= "\$plugins['$plugin'] = $value;\n"; } -- cgit v1.2.3 From a95a7bf3a77d3c38a54af67b2f7584c480381691 Mon Sep 17 00:00:00 2001 From: Hakan Sandell Date: Sat, 10 Sep 2011 19:47:00 +0200 Subject: empty conf/plugins.local is created if not existing --- inc/plugincontroller.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index cdaee2e8f..734331c94 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -158,6 +158,9 @@ class Doku_Plugin_Controller { } } $this->tmp_plugins = $all_plugins; + if (!file_exists($this->last_local_config_file)) { + $this->saveList(true); + } } } @@ -178,17 +181,18 @@ class Doku_Plugin_Controller { /** * Save the current list of plugins */ - function saveList() { + function saveList($forceSave = false) { global $conf; if (empty($this->tmp_plugins)) return false; // Rebuild list of local settings $local_plugins = $this->rebuildLocal(); - if($local_plugins != $this->plugin_cascade['local']) { + if($local_plugins != $this->plugin_cascade['local'] || $forceSave) { $file = $this->last_local_config_file; - $out = " $value) { $out .= "\$plugins['$plugin'] = $value;\n"; } -- cgit v1.2.3