summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/parser/handler.php4
-rw-r--r--inc/parser/xhtml.php4
-rw-r--r--inc/parserutils.php3
-rw-r--r--inc/pluginutils.php13
4 files changed, 11 insertions, 13 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index ded291356..55cbcf342 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -66,8 +66,8 @@ class Doku_Handler {
*/
function plugin($match, $state, $pos, $pluginname){
$data = array($match);
- $plugin = null;
- if(plugin_load('syntax',$pluginname,$plugin)){
+ $plugin =& plugin_load('syntax',$pluginname);
+ if($plugin != null){
$data = $plugin->handle($match, $state, $pos, $this);
}
$this->_addCall('plugin',array($pluginname,$data,$pos),$pos);
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 2fd5844d0..7dd1b8034 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -86,8 +86,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
//handles plugin rendering
function plugin($name,$data){
- $plugin = null;
- if(plugin_load('syntax',$name,$plugin)){
+ $plugin =& plugin_load('syntax',$name);
+ if($plugin != null){
$plugin->render('xhtml',$this,$data);
}
}
diff --git a/inc/parserutils.php b/inc/parserutils.php
index 1bf36c5fd..e3bd04524 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -199,7 +199,7 @@ function p_get_parsermodes(){
global $PARSER_MODES;
$obj = null;
foreach($pluginlist as $p){
- plugin_load('syntax',$p,$obj); //load plugin into $obj
+ $obj =& plugin_load('syntax',$p); //load plugin into $obj
$PARSER_MODES[$obj->getType()][] = "plugin_$p"; //register mode type
//add to modes
$modes[] = array(
@@ -207,6 +207,7 @@ function p_get_parsermodes(){
'mode' => "plugin_$p",
'obj' => $obj,
);
+ unset($obj); //remove the reference
}
}
diff --git a/inc/pluginutils.php b/inc/pluginutils.php
index 49dd44816..6c758a1be 100644
--- a/inc/pluginutils.php
+++ b/inc/pluginutils.php
@@ -34,29 +34,26 @@ function plugin_list($type){
*
* @param $type string type of plugin to load
* @param $name string name of the plugin to load
- * @param $ref ref will contain the plugin object
- * @return boolean plugin loading successful?
+ * @return object the plugin object or null on failure
*/
-function plugin_load($type,$name,&$ref){
+function &plugin_load($type,$name){
//we keep all loaded plugins available in global scope for reuse
global $DOKU_PLUGINS;
//plugin already loaded?
if($DOKU_PLUGINS[$type][$name] != null){
- $ref = $DOKU_PLUGINS[$type][$name];
- return true;
+ return $DOKU_PLUGINS[$type][$name];
}
//try to load the wanted plugin file
if(!include_once(DOKU_PLUGIN.$name.'/'.$type.'.php')){
- return false;
+ return null;
}
//construct class and instanciate
$class = $type.'_plugin_'.$name;
$DOKU_PLUGINS[$type][$name] = new $class;
- $ref = $DOKU_PLUGINS[$type][$name];
- return true;
+ return $DOKU_PLUGINS[$type][$name];
}