diff --git a/Text/Wiki/Parse/Embed.php b/Text/Wiki/Parse/Embed.php index 82d5c1376b6..a7faae02d8d 100755 --- a/Text/Wiki/Parse/Embed.php +++ b/Text/Wiki/Parse/Embed.php @@ -26,6 +26,13 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { 'base' => '/path/to/scripts/' ); + var $file = null; + + var $output = null; + + var $vars = null; + + /** * * The regular expression used to find source text matching this @@ -37,7 +44,7 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { * */ - var $regex = '/(\[\[embed )(.+?)(\]\])/i'; + var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i'; /** @@ -57,12 +64,25 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { function process(&$matches) { - $file = $this->getConf('base') . $matches[2]; - ob_start(); - include($file); - $options = array('text' => ob_get_contents()); - ob_end_clean(); - return $this->wiki->addToken($this->rule, $options); + // save the file location + $this->file = $this->getConf('base', './') . $matches[2]; + + // extract attribs as variables in the local space + $this->vars = $this->getAttrs($matches[3]); + unset($this->vars['this']); + extract($this->vars); + + // run the script + ob_start(); + include($this->file); + $this->output = ob_get_contents(); + ob_end_clean(); + + // done, place the script output directly in the source + return $this->wiki->addToken( + $this->rule, + array('text' => $this->output) + ); } } ?> \ No newline at end of file diff --git a/Text/Wiki/Parse/Include.php b/Text/Wiki/Parse/Include.php index 2bdc4d22475..3be6a990871 100755 --- a/Text/Wiki/Parse/Include.php +++ b/Text/Wiki/Parse/Include.php @@ -24,10 +24,16 @@ class Text_Wiki_Parse_Include extends Text_Wiki_Parse { - $conf = array( + var $conf = array( 'base' => '/path/to/scripts/' ); + var $file = null; + + var $output = null; + + var $vars = null; + /** * * The regular expression used to find source text matching this @@ -39,7 +45,7 @@ class Text_Wiki_Parse_Include extends Text_Wiki_Parse { * */ - var $regex = '/(\[\[include )(.+?)(\]\])/i'; + var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i'; /** @@ -57,12 +63,22 @@ class Text_Wiki_Parse_Include extends Text_Wiki_Parse { function process(&$matches) { - $file = $this->getConf(['base'], './') . $matches[2]; + // save the file location + $this->file = $this->getConf('base', './') . $matches[2]; + + // extract attribs as variables in the local space + $this->vars = $this->getAttrs($matches[3]); + unset($this->vars['this']); + extract($this->vars); + + // run the script ob_start(); - include($file); - $output = ob_get_contents(); + include($this->file); + $this->output = ob_get_contents(); ob_end_clean(); - return $output; + + // done, place the script output directly in the source + return $this->output; } } ?> \ No newline at end of file diff --git a/Text/Wiki/Render/Xhtml/Embed.php b/Text/Wiki/Render/Xhtml/Embed.php index 7e9ce742ff8..4bc6fb7ddcb 100755 --- a/Text/Wiki/Render/Xhtml/Embed.php +++ b/Text/Wiki/Render/Xhtml/Embed.php @@ -17,12 +17,7 @@ class Text_Wiki_Render_Xhtml_Embed extends Text_Wiki_Render { function token($options) { - $file = $this->getConf('base') . $options['path']; - ob_start(); - include($file); - $output = ob_get_contents(); - ob_end_clean(); - return $output; - } + return $options['text']; + } } ?> \ No newline at end of file