summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-02-01 00:36:38 -0800
committerAndreas Gohr <andi@splitbrain.org>2013-02-01 00:36:38 -0800
commit1ad6d1a0687d4d11adac3b49cb5eefa8abc551c0 (patch)
tree5a7efcd2d6ac2c0861382ac8636a34411b509298 /lib
parent957e84c6d04b3287613860d79d564d971531db98 (diff)
parente1cc03e353022c84d330ba3d9d5cba92cd4878a6 (diff)
downloadrpg-1ad6d1a0687d4d11adac3b49cb5eefa8abc551c0.tar.gz
rpg-1ad6d1a0687d4d11adac3b49cb5eefa8abc551c0.tar.bz2
Merge pull request #167 from Klap-in/master
Adds loadHelper to Syntax class and litte code reformat
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/syntax.php106
1 files changed, 63 insertions, 43 deletions
diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php
index 552cc747a..b7839b2b2 100644
--- a/lib/plugins/syntax.php
+++ b/lib/plugins/syntax.php
@@ -226,56 +226,76 @@ 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];
+ }
+
+ /**
+ * 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;
+ }
+
+ $this->configloaded = true;
+ $this->conf =& $conf['plugin'][$plugin];
}
- $this->configloaded = true;
- $this->conf =& $conf['plugin'][$plugin];
- }
+ /**
+ * read the plugin's default configuration settings from conf/default.php
+ * this function is automatically called through getConf()
+ *
+ * @return array setting => value
+ */
+ function readDefaultSettings() {
- /**
- * 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();
- $path = DOKU_PLUGIN.$this->getPluginName().'/conf/';
- $conf = array();
+ if(@file_exists($path.'default.php')) {
+ include($path.'default.php');
+ }
- if (@file_exists($path.'default.php')) {
- include($path.'default.php');
+ return $conf;
}
- return $conf;
- }
+ /**
+ * Loads a given helper plugin (if enabled)
+ *
+ * @author Esther Brunner <wikidesign@gmail.com>
+ *
+ * @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 = true) {
+ 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