Skip to content
Snippets Groups Projects
Commit 98aafb56 authored by Hakan Sandell's avatar Hakan Sandell
Browse files

Code cleanup documentation before merge

Function get_plugin_components() moved to extantion manager
parent b838050e
No related branches found
No related tags found
No related merge requests found
<?php <?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['acl'] = 1;
$plugins['plugin'] = 1; $plugins['plugin'] = 1;
$plugins['config'] = 1; $plugins['config'] = 1;
......
...@@ -318,5 +318,5 @@ $lang['seconds'] = '%d seconds ago'; ...@@ -318,5 +318,5 @@ $lang['seconds'] = '%d seconds ago';
$lang['wordblock'] = 'Your change was not saved because it contains blocked text (spam).'; $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 : //Setup VIM: ex: et ts=2 :
...@@ -14,7 +14,7 @@ class Doku_Plugin_Controller { ...@@ -14,7 +14,7 @@ class Doku_Plugin_Controller {
var $list_bytype = array(); var $list_bytype = array();
var $tmp_plugins = array(); var $tmp_plugins = array();
var $plugin_cascade = array('default'=>array(),'local'=>array(),'protected'=>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 //backup of tmp_plugins needed for write check
var $tmp_bak =array(); var $tmp_bak =array();
...@@ -71,7 +71,8 @@ class Doku_Plugin_Controller { ...@@ -71,7 +71,8 @@ class Doku_Plugin_Controller {
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 //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); list($plugin,$component) = $this->_splitName($name);
...@@ -98,7 +99,7 @@ class Doku_Plugin_Controller { ...@@ -98,7 +99,7 @@ class Doku_Plugin_Controller {
$dir = $this->get_directory($plugin); $dir = $this->get_directory($plugin);
$inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt"); $inf = confToHash(DOKU_PLUGIN."$dir/plugin.info.txt");
if($inf['base'] && $inf['base'] != $plugin){ 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; return null;
} }
...@@ -129,6 +130,7 @@ class Doku_Plugin_Controller { ...@@ -129,6 +130,7 @@ class Doku_Plugin_Controller {
protected function _populateMasterList() { protected function _populateMasterList() {
if ($dh = @opendir(DOKU_PLUGIN)) { if ($dh = @opendir(DOKU_PLUGIN)) {
$all_plugins = array();
while (false !== ($plugin = readdir($dh))) { while (false !== ($plugin = readdir($dh))) {
if ($plugin[0] == '.') continue; // skip hidden entries if ($plugin[0] == '.') continue; // skip hidden entries
if (is_file(DOKU_PLUGIN.$plugin)) continue; // skip files, we're only interested in directories if (is_file(DOKU_PLUGIN.$plugin)) continue; // skip files, we're only interested in directories
...@@ -188,7 +190,7 @@ class Doku_Plugin_Controller { ...@@ -188,7 +190,7 @@ class Doku_Plugin_Controller {
$local_plugins = $this->rebuildLocal(); $local_plugins = $this->rebuildLocal();
//only write if the list has changed //only write if the list has changed
if($local_plugins != $this->plugin_cascade['local']) { if($local_plugins != $this->plugin_cascade['local']) {
$file = $this->last_local; $file = $this->last_local_config_file;
$out = "<?php\n"; $out = "<?php\n";
foreach ($local_plugins as $plugin => $value) { foreach ($local_plugins as $plugin => $value) {
$out .= "\$plugins['$plugin'] = $value;\n"; $out .= "\$plugins['$plugin'] = $value;\n";
...@@ -243,8 +245,8 @@ class Doku_Plugin_Controller { ...@@ -243,8 +245,8 @@ class Doku_Plugin_Controller {
$this->plugin_cascade[$type] = $this->checkRequire($config_cascade['plugins'][$type]); $this->plugin_cascade[$type] = $this->checkRequire($config_cascade['plugins'][$type]);
} }
$local = $config_cascade['plugins']['local']; $local = $config_cascade['plugins']['local'];
$this->last_local = array_pop($local); $this->last_local_config_file = array_pop($local);
$this->plugin_cascade['local'] = $this->checkRequire(array($this->last_local)); $this->plugin_cascade['local'] = $this->checkRequire(array($this->last_local_config_file));
if(is_array($local)) { if(is_array($local)) {
$this->plugin_cascade['default'] = array_merge($this->plugin_cascade['default'],$this->checkRequire($local)); $this->plugin_cascade['default'] = array_merge($this->plugin_cascade['default'],$this->checkRequire($local));
} }
......
...@@ -40,30 +40,3 @@ function plugin_getcascade() { ...@@ -40,30 +40,3 @@ function plugin_getcascade() {
global $plugin_controller; global $plugin_controller;
return $plugin_controller->getCascade(); 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];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment