From 38479cbba628ee76a92ff5f3c974cfa8e6ce9e61 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 29 Nov 2012 16:06:43 +0100 Subject: some coding style improvements - removed some dead/unused code - fixed phpdoc - added typing on methods --- lib/plugins/syntax.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/plugins/syntax.php') diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 8b94493e4..552cc747a 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -84,13 +84,13 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * * Usually you should only need the $match param. * - * @param $match string The text matched by the patterns - * @param $state int The lexer state for the match - * @param $pos int The character position of the matched text - * @param $handler Doku_Handler Reference to the Doku_Handler object - * @return array Return an array with all data you want to use in render + * @param string $match The text matched by the patterns + * @param int $state The lexer state for the match + * @param int $pos The character position of the matched text + * @param Doku_Handler $handler Reference to the Doku_Handler object + * @return array Return an array with all data you want to use in render */ - function handle($match, $state, $pos, &$handler){ + function handle($match, $state, $pos, Doku_Handler &$handler){ trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); } @@ -117,7 +117,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * @param $data array data created by handler() * @return boolean rendered correctly? */ - function render($format, &$renderer, $data) { + function render($format, Doku_Renderer &$renderer, $data) { trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); } -- cgit v1.2.3 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/syntax.php') 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/syntax.php') 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/syntax.php') 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