diff options
author | Adrian Lang <lang@cosmocode.de> | 2010-03-29 12:00:30 +0200 |
---|---|---|
committer | Adrian Lang <lang@cosmocode.de> | 2010-03-29 12:37:05 +0200 |
commit | f6ec8df813b28547ca3b04bb39f0ce670a6bb990 (patch) | |
tree | 01cfd7c927495421861eef551b94b8653ca65218 | |
parent | ea6dfbca91f6afe89ff631ac28eae023bcc52853 (diff) | |
download | rpg-f6ec8df813b28547ca3b04bb39f0ce670a6bb990.tar.gz rpg-f6ec8df813b28547ca3b04bb39f0ce670a6bb990.tar.bz2 |
Allow plugins to specify that they have to be instantiated
Plugins may return false in isSingleton to let plugin_load return a new
instance every time it is called.
Renderer plugins are not loaded with $new set to true, but instead specify
themself that they are not singletons. This behaviour allows the odt renderer
to keep working (see #1598).
-rw-r--r-- | inc/parser/renderer.php | 9 | ||||
-rw-r--r-- | inc/parserutils.php | 2 | ||||
-rw-r--r-- | inc/plugin.php | 6 | ||||
-rw-r--r-- | inc/plugincontroller.class.php | 2 | ||||
-rw-r--r-- | lib/plugins/syntax.php | 8 |
5 files changed, 14 insertions, 13 deletions
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 393099003..4dac75d21 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -49,6 +49,15 @@ class Doku_Renderer extends DokuWiki_Plugin { trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING); } + /** + * Allow the plugin to prevent DokuWiki from reusing an instance + * + * @return bool false if the plugin has to be instantiated + */ + function isSingleton() { + return false; + } + //handle plugin rendering function plugin($name,$data){ diff --git a/inc/parserutils.php b/inc/parserutils.php index 4bec3ab1d..35ccdc1d6 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -585,7 +585,7 @@ function & p_get_renderer($mode) { // Maybe a plugin/component is available? list($plugin, $component) = $plugin_controller->_splitName($rname); if (!$plugin_controller->isdisabled($plugin)){ - $Renderer =& $plugin_controller->load('renderer',$rname, true); + $Renderer =& $plugin_controller->load('renderer',$rname); } if(is_null($Renderer)){ diff --git a/inc/plugin.php b/inc/plugin.php index 364534739..aff07c1e5 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -231,12 +231,12 @@ class DokuWiki_Plugin { } /** - * Allow the plugin to prevent DokuWiki creating a second instance of itself + * Allow the plugin to prevent DokuWiki from reusing an instance * - * @return bool true if the plugin can not be instantiated more than once + * @return bool false if the plugin has to be instantiated */ function isSingleton() { - return false; + return true; } // deprecated functions diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 043687270..61f460414 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -66,7 +66,7 @@ class Doku_Plugin_Controller { //plugin already loaded? if(!empty($DOKU_PLUGINS[$type][$name])){ - if ($new && !$DOKU_PLUGINS[$type][$name]->isSingleton()) { + if ($new || !$DOKU_PLUGINS[$type][$name]->isSingleton()) { $class = $type.'_plugin_'.$name; return class_exists($class) ? new $class : null; } else { diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 601b5591e..f7b64d8c0 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -266,13 +266,5 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { return $conf; } - /** - * Allow the plugin to prevent DokuWiki creating a second instance of itself - * - * @return bool true if the plugin can not be instantiated more than once - */ - function isSingleton() { - return false; - } } //Setup VIM: ex: et ts=4 enc=utf-8 : |