diff options
author | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-08-13 14:59:29 +0200 |
---|---|---|
committer | Chris Smith <chris.eureka@jalakai.co.uk> | 2008-08-13 14:59:29 +0200 |
commit | 94806c6f093ed94d70c5720d2ea1f1747440087f (patch) | |
tree | 5b73d1c050fe59274b13975f52b03d3d2b8e95df /inc/pluginutils.php | |
parent | 13ecfb181fddc89a007270d1d325db1f7e4f5fcc (diff) | |
download | rpg-94806c6f093ed94d70c5720d2ea1f1747440087f.tar.gz rpg-94806c6f093ed94d70c5720d2ea1f1747440087f.tar.bz2 |
add third parameter to plugin_load(), $new, to allow return of a new plugin object instance
darcs-hash:20080813125929-f07c6-4f20e147334ebc5be006ec9f260331950ac2e4cb.gz
Diffstat (limited to 'inc/pluginutils.php')
-rw-r--r-- | inc/pluginutils.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 55c03f4a5..100f781f2 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -60,16 +60,21 @@ function plugin_list($type='',$all=false){ * * @param $type string type of plugin to load * @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 * @return objectreference the plugin object or null on failure */ -function &plugin_load($type,$name){ +function &plugin_load($type,$name,$new=false){ //we keep all loaded plugins available in global scope for reuse global $DOKU_PLUGINS; - //plugin already loaded? if(!empty($DOKU_PLUGINS[$type][$name])){ - return $DOKU_PLUGINS[$type][$name]; + if ($new) { + $class = $type.'_plugin_'.$name; + return class_exists($class) ? new $class : null; + } else { + return $DOKU_PLUGINS[$type][$name]; + } } //try to load the wanted plugin file |