From fec2accc99487e0dee7300c58566bb82225f8afd Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sat, 26 Jan 2013 13:13:51 +0100 Subject: Added loadHelper() to DokuWiki_Syntax_Plugin. --- lib/plugins/syntax.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/plugins') diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 552cc747a..f3f234316 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -277,6 +277,26 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { return $conf; } + /** + * Loads a given helper plugin (if enabled) + * + * @author Esther Brunner + * + * @param string $name name of plugin to load + * @param bool $msg if a message should be displayed in case the plugin is not available + * + * @return object helper plugin object + */ + function loadHelper($name, $msg){ + if (!plugin_isdisabled($name)){ + $obj = plugin_load('helper',$name); + }else{ + $obj = null; + } + if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1); + return $obj; + } + /** * Allow the plugin to prevent DokuWiki from reusing an instance * -- cgit v1.2.3 From 5fd9b829e7d9947de0eeead685e0a0cf707eff88 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sat, 26 Jan 2013 20:59:00 +0100 Subject: Reformat last bottom end of the syntax plugin file --- lib/plugins/syntax.php | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'lib/plugins') diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index f3f234316..a6d7ce92c 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -226,56 +226,56 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { $this->localised = true; } - // configuration methods - /** - * getConf($setting) - * - * use this function to access plugin configuration variables - */ - function getConf($setting){ - - if (!$this->configloaded){ $this->loadConfig(); } - - return $this->conf[$setting]; - } - - /** - * loadConfig() - * merges the plugin's default settings with any local settings - * this function is automatically called through getConf() - */ - function loadConfig(){ - global $conf; - - $defaults = $this->readDefaultSettings(); - $plugin = $this->getPluginName(); - - foreach ($defaults as $key => $value) { - if (isset($conf['plugin'][$plugin][$key])) continue; - $conf['plugin'][$plugin][$key] = $value; + // configuration methods + /** + * getConf($setting) + * + * use this function to access plugin configuration variables + */ + function getConf($setting) { + + if(!$this->configloaded) { $this->loadConfig(); } + + return $this->conf[$setting]; } - $this->configloaded = true; - $this->conf =& $conf['plugin'][$plugin]; - } + /** + * loadConfig() + * merges the plugin's default settings with any local settings + * this function is automatically called through getConf() + */ + function loadConfig() { + global $conf; - /** - * read the plugin's default configuration settings from conf/default.php - * this function is automatically called through getConf() - * - * @return array setting => value - */ - function readDefaultSettings() { + $defaults = $this->readDefaultSettings(); + $plugin = $this->getPluginName(); - $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; - $conf = array(); + foreach($defaults as $key => $value) { + if(isset($conf['plugin'][$plugin][$key])) continue; + $conf['plugin'][$plugin][$key] = $value; + } - if (@file_exists($path.'default.php')) { - include($path.'default.php'); + $this->configloaded = true; + $this->conf =& $conf['plugin'][$plugin]; } - return $conf; - } + /** + * read the plugin's default configuration settings from conf/default.php + * this function is automatically called through getConf() + * + * @return array setting => value + */ + function readDefaultSettings() { + + $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; + $conf = array(); + + if(@file_exists($path.'default.php')) { + include($path.'default.php'); + } + + return $conf; + } /** * Loads a given helper plugin (if enabled) @@ -287,13 +287,13 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * * @return object helper plugin object */ - function loadHelper($name, $msg){ - if (!plugin_isdisabled($name)){ - $obj = plugin_load('helper',$name); - }else{ + function loadHelper($name, $msg) { + if(!plugin_isdisabled($name)) { + $obj = plugin_load('helper', $name); + } else { $obj = null; } - if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1); + if(is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.", -1); return $obj; } -- cgit v1.2.3 From 97f59cf7ce28a342fe19606999a65f18d264ef3d Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sun, 27 Jan 2013 22:42:33 +0100 Subject: set $msg argument of loadHelper() default to true. --- lib/plugins/syntax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins') diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index a6d7ce92c..b7839b2b2 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -287,7 +287,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * * @return object helper plugin object */ - function loadHelper($name, $msg) { + function loadHelper($name, $msg = true) { if(!plugin_isdisabled($name)) { $obj = plugin_load('helper', $name); } else { -- cgit v1.2.3