diff options
author | Gerry Weißbach <gerry.w@gammaproduction.de> | 2014-12-22 10:31:30 +0100 |
---|---|---|
committer | Gerry Weißbach <gerry.w@gammaproduction.de> | 2014-12-22 10:31:30 +0100 |
commit | 8da2ebf4f4261eb8f54df5704b5d9af283b5402d (patch) | |
tree | 9c63975e3898c949e1784e30e81a5ed3da7fca93 /inc/plugin.php | |
parent | 5e7f4d50cbbc788c9c0483a0a2ff1b536e4ffe8c (diff) | |
parent | 1bf4abb07f65e28578bae98aad457cb768d8b44f (diff) | |
download | rpg-8da2ebf4f4261eb8f54df5704b5d9af283b5402d.tar.gz rpg-8da2ebf4f4261eb8f54df5704b5d9af283b5402d.tar.bz2 |
Merge remote-tracking branch 'splitbrain/master'
Diffstat (limited to 'inc/plugin.php')
-rw-r--r-- | inc/plugin.php | 102 |
1 files changed, 70 insertions, 32 deletions
diff --git a/inc/plugin.php b/inc/plugin.php index fbfc0325f..9d9b2044c 100644 --- a/inc/plugin.php +++ b/inc/plugin.php @@ -30,7 +30,7 @@ class DokuWiki_Plugin { * desc - Short description of the plugin (Text only) * url - Website with more information on the plugin (eg. syntax description) */ - function getInfo() { + public function getInfo(){ $parts = explode('_', get_class($this)); $info = DOKU_PLUGIN . '/' . $parts[2] . '/plugin.info.txt'; if(@file_exists($info)) return confToHash($info); @@ -48,16 +48,27 @@ class DokuWiki_Plugin { // plugin introspection methods // extract from class name, format = <plugin type>_plugin_<name>[_<component name>] - function getPluginType() { + /** + * @return string plugin type + */ + public function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; } - function getPluginName() { - list($t, $p, $n) = explode('_', get_class($this), 4); + + /** + * @return string plugin name + */ + public function getPluginName() { + list(/* $t */, /* $p */, $n) = explode('_', get_class($this), 4); return $n; } - function getPluginComponent() { - list($t, $p, $n, $c) = explode('_', get_class($this), 4); + + /** + * @return string component name + */ + public function getPluginComponent() { + list(/* $t */, /* $p */, /* $n */, $c) = explode('_', get_class($this), 4); return (isset($c)?$c:''); } @@ -71,7 +82,7 @@ class DokuWiki_Plugin { * @param string $id id of the string to be retrieved * @return string string in appropriate language or english if not available */ - function getLang($id) { + public function getLang($id) { if (!$this->localised) $this->setupLocale(); return (isset($this->lang[$id]) ? $this->lang[$id] : ''); @@ -86,16 +97,18 @@ class DokuWiki_Plugin { * @param string $id id of language dependent wiki page * @return string parsed contents of the wiki page in xhtml format */ - function locale_xhtml($id) { + public function locale_xhtml($id) { return p_cached_output($this->localFN($id)); } /** - * localFN($id) - * prepends appropriate path for a language dependent filename + * Prepends appropriate path for a language dependent filename * plugin equivalent of localFN() + * + * @param string $id id of localization file + * @return string wiki text */ - function localFN($id) { + public function localFN($id) { global $conf; $plugin = $this->getPluginName(); $file = DOKU_CONF.'plugin_lang/'.$plugin.'/'.$conf['lang'].'/'.$id.'.txt'; @@ -110,21 +123,33 @@ class DokuWiki_Plugin { } /** - * setupLocale() - * reads all the plugins language dependent strings into $this->lang - * this function is automatically called by getLang() + * Reads all the plugins language dependent strings into $this->lang + * this function is automatically called by getLang() */ function setupLocale() { - if ($this->localised) return; + if($this->localised) return; - global $conf; // definitely don't invoke "global $lang" - $path = DOKU_PLUGIN.$this->getPluginName().'/lang/'; + global $conf, $config_cascade; // definitely don't invoke "global $lang" + $path = DOKU_PLUGIN . $this->getPluginName() . '/lang/'; $lang = array(); // don't include once, in case several plugin components require the same language file - @include($path.'en/lang.php'); - if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); + @include($path . 'en/lang.php'); + foreach($config_cascade['lang']['plugin'] as $config_file) { + if(@file_exists($config_file . $this->getPluginName() . '/en/lang.php')) { + include($config_file . $this->getPluginName() . '/en/lang.php'); + } + } + + if($conf['lang'] != 'en') { + @include($path . $conf['lang'] . '/lang.php'); + foreach($config_cascade['lang']['plugin'] as $config_file) { + if(@file_exists($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php')) { + include($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php'); + } + } + } $this->lang = $lang; $this->localised = true; @@ -140,7 +165,7 @@ class DokuWiki_Plugin { * @param mixed $notset what to return if the setting is not available * @return mixed */ - function getConf($setting, $notset=false){ + public function getConf($setting, $notset=false){ if (!$this->configloaded){ $this->loadConfig(); } @@ -177,7 +202,7 @@ class DokuWiki_Plugin { * * @return array setting => value */ - function readDefaultSettings() { + protected function readDefaultSettings() { $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; $conf = array(); @@ -196,10 +221,9 @@ class DokuWiki_Plugin { * * @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 + * @return DokuWiki_Plugin|null helper plugin object */ - function loadHelper($name, $msg = true){ + public function loadHelper($name, $msg = true){ $obj = plugin_load('helper',$name); if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.",-1); return $obj; @@ -211,8 +235,14 @@ class DokuWiki_Plugin { /** * email * standardised function to generate an email link according to obfuscation settings + * + * @param string $email + * @param string $name + * @param string $class + * @param string $more + * @return string html */ - function email($email, $name='', $class='', $more='') { + public function email($email, $name='', $class='', $more='') { if (!$email) return $name; $email = obfuscate($email); if (!$name) $name = $email; @@ -223,8 +253,15 @@ class DokuWiki_Plugin { /** * external_link * standardised function to generate an external link according to conf settings + * + * @param string $link + * @param string $title + * @param string $class + * @param string $target + * @param string $more + * @return string */ - function external_link($link, $title='', $class='', $target='', $more='') { + public function external_link($link, $title='', $class='', $target='', $more='') { global $conf; $link = htmlentities($link); @@ -247,11 +284,12 @@ class DokuWiki_Plugin { * Instead use render_text() * * @deprecated 2014-01-22 - * @param $name - * @param $arguments + * + * @param string $name + * @param array $arguments * @return null|string */ - function __call($name, $arguments) { + public function __call($name, $arguments) { if($name == 'render'){ dbg_deprecated('render_text()'); if(!isset($arguments[1])) $arguments[1] = 'xhtml'; @@ -265,11 +303,11 @@ class DokuWiki_Plugin { * output text string through the parser, allows dokuwiki markup to be used * very ineffecient for small pieces of data - try not to use * - * @param string $text wiki markup to parse + * @param string $text wiki markup to parse * @param string $format output format * @return null|string */ - function render_text($text, $format='xhtml') { + public function render_text($text, $format='xhtml') { return p_render($format, p_get_instructions($text),$info); } @@ -278,7 +316,7 @@ class DokuWiki_Plugin { * * @return bool false if the plugin has to be instantiated */ - function isSingleton() { + public function isSingleton() { return true; } } |