diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-01-20 00:33:50 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-01-20 00:33:50 +0100 |
commit | 4ac671408cc43220ad93ba92a9f74bbc16068837 (patch) | |
tree | f5c9221085d2ac6ff81701f01966cab833761a57 | |
parent | a939d432e8277f7c7fe336ff0326a44669d8fb62 (diff) | |
download | rpg-4ac671408cc43220ad93ba92a9f74bbc16068837.tar.gz rpg-4ac671408cc43220ad93ba92a9f74bbc16068837.tar.bz2 |
moved plugin base class to inc
darcs-hash:20070119233350-7ad00-a8ae733093693a55c2566f5ee698a7b4aa3a833a.gz
-rw-r--r-- | inc/plugin.php (renamed from lib/plugins/base.php) | 44 | ||||
-rw-r--r-- | lib/plugins/action.php | 4 | ||||
-rw-r--r-- | lib/plugins/admin.php | 2 | ||||
-rw-r--r-- | lib/plugins/syntax.php | 44 |
4 files changed, 45 insertions, 49 deletions
diff --git a/lib/plugins/base.php b/inc/plugin.php index a895166e6..045f3d229 100644 --- a/lib/plugins/base.php +++ b/inc/plugin.php @@ -1,18 +1,14 @@ <?php /** - * Admin Plugin Prototype - * + * DokuWiki Plugin base class + * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Christopher Smith <chris@jalakai.co.uk> */ -// must be run within Dokuwiki -if(!defined('DOKU_INC')) die(); - -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); /** - * All DokuWiki plugins to extend the admin function - * need to inherit from this class + * Do not inherit directly from this class, instead inherit from the specialized + * ones in lib/plugin */ class DokuWiki_Plugin { @@ -36,7 +32,7 @@ class DokuWiki_Plugin { function getInfo(){ trigger_error('getInfo() not implemented in '.get_class($this), E_USER_WARNING); } - + // plugin introspection methods // extract from class name, format = <plugin type>_plugin_<name>[_<component name>] function getPluginType() { list($t) = explode('_', get_class($this), 2); return $t; } @@ -55,10 +51,10 @@ class DokuWiki_Plugin { */ function getLang($id) { if (!$this->localised) $this->setupLocale(); - + return (isset($this->lang[$id]) ? $this->lang[$id] : ''); } - + /** * locale_xhtml($id) * @@ -71,7 +67,7 @@ class DokuWiki_Plugin { function locale_xhtml($id) { return p_cached_output($this->localFN($id)); } - + /** * localFN($id) * prepends appropriate path for a language dependent filename @@ -87,9 +83,9 @@ class DokuWiki_Plugin { } return $file; } - + /** - * setupLocale() + * setupLocale() * reads all the plugins language dependent strings into $this->lang * this function is automatically called by getLang() */ @@ -100,19 +96,19 @@ class DokuWiki_Plugin { $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'); + @include($path.'en/lang.php'); if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); - + $this->lang = $lang; $this->localised = true; } - + // configuration methods /** * getConf($setting) - * + * * use this function to access plugin configuration variables */ function getConf($setting){ @@ -121,7 +117,7 @@ class DokuWiki_Plugin { return $this->conf[$setting]; } - + /** * loadConfig() * merges the plugin's default settings with any local settings @@ -139,7 +135,7 @@ class DokuWiki_Plugin { } $this->configloaded = true; - $this->conf =& $conf['plugin'][$plugin]; + $this->conf =& $conf['plugin'][$plugin]; } /** @@ -194,12 +190,12 @@ class DokuWiki_Plugin { return "<a href='$link'$class$target$more>$title</a>"; } - /** + /** * output text string through the parser, allows dokuwiki markup to be used * very ineffecient for small pieces of data - try not to use */ function render($text, $format='xhtml') { - return p_render($format, p_get_instructions($text),$info); + return p_render($format, p_get_instructions($text),$info); } // deprecated functions @@ -208,4 +204,4 @@ class DokuWiki_Plugin { function plugin_email($e, $n='', $c='', $m='') { return $this->email($e, $n, $c, $m); } function plugin_link($l, $t='', $c='', $to='', $m='') { return $this->external_link($l, $t, $c, $to, $m); } function plugin_render($t, $f='xhtml') { return $this->render($t, $f); } -}
\ No newline at end of file +} diff --git a/lib/plugins/action.php b/lib/plugins/action.php index 05d8735b9..4891349cb 100644 --- a/lib/plugins/action.php +++ b/lib/plugins/action.php @@ -9,7 +9,7 @@ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_PLUGIN.'base.php'); +require_once(DOKU_INC.'inc/plugin.php'); /** * All DokuWiki plugins to extend the admin function @@ -21,4 +21,4 @@ class DokuWiki_Action_Plugin extends DokuWiki_Plugin { trigger_error('register() not implemented in '.get_class($this), E_USER_WARNING); } -}
\ No newline at end of file +} diff --git a/lib/plugins/admin.php b/lib/plugins/admin.php index 22867a93d..00a07a054 100644 --- a/lib/plugins/admin.php +++ b/lib/plugins/admin.php @@ -9,7 +9,7 @@ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_PLUGIN.'base.php'); +require_once(DOKU_INC.'inc/plugin.php'); /** * All DokuWiki plugins to extend the admin function diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 770356c3a..eb70dd1ff 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -1,7 +1,7 @@ <?php /** * Syntax Plugin Prototype - * + * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> */ @@ -47,12 +47,12 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { function getType(){ trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING); } - + /** * Allowed Mode Types * - * Defines the mode types for other dokuwiki markup that maybe nested within the - * plugin's own markup. Needs to return an array of one or more of the mode types + * Defines the mode types for other dokuwiki markup that maybe nested within the + * plugin's own markup. Needs to return an array of one or more of the mode types * defined in $PARSER_MODES in parser.php */ function getAllowedTypes() { @@ -95,7 +95,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { /** * Handles the actual output creation. - * + * * The function must not assume any other of the classes methods have been run * during the object's current life. The only reliable data it receives are its * parameters. @@ -120,7 +120,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); } - + /** * There should be no need to override these functions */ @@ -132,7 +132,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { $allowedModeTypes = $this->getAllowedTypes(); foreach($allowedModeTypes as $mt) { $this->allowedModes = array_merge($this->allowedModes, $PARSER_MODES[$mt]); - } + } $idx = array_search(substr(get_class($this), 7), $this->allowedModes); if ($idx !== false) { @@ -140,8 +140,8 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { } $this->allowedModesSetup = true; } - - return parent::accepts($mode); + + return parent::accepts($mode); } // plugin introspection methods @@ -163,10 +163,10 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { */ function getLang($id) { if (!$this->localised) $this->setupLocale(); - + return (isset($this->lang[$id]) ? $this->lang[$id] : ''); } - + /** * locale_xhtml($id) * @@ -179,7 +179,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { function locale_xhtml($id) { return p_cached_output($this->localFN($id)); } - + /** * localFN($id) * prepends appropriate path for a language dependent filename @@ -195,30 +195,30 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { } return $file; } - + /** - * setupLocale() + * setupLocale() * reads all the plugins language dependent strings into $this->lang * this function is automatically called by getLang() */ function setupLocale() { if ($this->localised) return; - + global $conf; // definitely don't invoke "global $lang" $path = DOKU_PLUGIN.$this->getPluginName().'/lang/'; - + // don't include once, in case several plugin components require the same language file - @include($path.'en/lang.php'); + @include($path.'en/lang.php'); if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); - + $this->lang = $lang; $this->localised = true; } - + // configuration methods /** * getConf($setting) - * + * * use this function to access plugin configuration variables */ function getConf($setting){ @@ -227,7 +227,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { return $this->conf[$setting]; } - + /** * loadConfig() * merges the plugin's default settings with any local settings @@ -245,7 +245,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { } $this->configloaded = true; - $this->conf =& $conf['plugin'][$plugin]; + $this->conf =& $conf['plugin'][$plugin]; } /** |