summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris <chris@teacherscpd.co.uk>2005-07-28 02:57:20 +0200
committerchris <chris@teacherscpd.co.uk>2005-07-28 02:57:20 +0200
commita6d2d9fa1831e896d45fef6db1d4846a043a8387 (patch)
tree7a3b852b170563876cae2dac1ffa051b973d6550
parentd74aace9ed8079a5a2430f3c0cc56ff39934279b (diff)
downloadrpg-a6d2d9fa1831e896d45fef6db1d4846a043a8387.tar.gz
rpg-a6d2d9fa1831e896d45fef6db1d4846a043a8387.tar.bz2
syntax plugin class update: add getAllowedTypes() method (compatible with plugins written prior to the patch, although they should be updated!)
darcs-hash:20050728005720-50fdc-e384bbca7c4f334659e19bedfd675621b7989c80.gz
-rw-r--r--lib/plugins/syntax.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php
index bf03fdf2c..59b02d7dc 100644
--- a/lib/plugins/syntax.php
+++ b/lib/plugins/syntax.php
@@ -16,6 +16,8 @@ require_once(DOKU_INC.'inc/parser/parser.php');
*/
class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
+ var $allowedModesSetup = false;
+
/**
* General Info
*
@@ -40,6 +42,17 @@ 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
+ * defined in $PARSER_MODES in parser.php
+ */
+ function getAllowedTypes() {
+ return array();
+ }
/**
* Paragraph Type
@@ -48,6 +61,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
* for correct XHTML nesting. Should return one of the following:
*
* 'normal' - The plugin can be used inside paragraphs
+
* 'block' - Open paragraphs need to be closed before plugin output
* 'stack' - Special case. Plugin wraps other paragraphs.
*
@@ -59,6 +73,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
/**
* Handler to prepare matched data for the rendering process
+ * This function is called statically - it may not reference any object properties
*
* Usually you should only need the $match param.
*
@@ -74,6 +89,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
/**
* Handles the actual output creation.
+ * This function is called statically - it may not reference any object properties
*
* The function should always check for the given mode and return false
* when a mode isn't supported.
@@ -94,6 +110,26 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode {
function render($mode, &$renderer, $data) {
trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING);
}
+
+ /**
+ * There should be no need to override this function
+ */
+ function accepts($mode) {
+
+ if (!$allowedModesSetup) {
+ global $PARSER_MODES;
+
+ $allowedModeTypes = $this->getAllowedTypes();
+ foreach($allowedModeTypes as $mt) {
+ array_merge($this->allowedModes, $PARSER_MODES[$mt]);
+ }
+
+ unset($this->allowedModes[array_search(substr(get_class($this), 7), $this->allowedModes)]);
+ $allowedModesSetup = true;
+ }
+
+ return parent::accepts($mode);
+ }
}