Skip to content

Commit

Permalink
fixed bugs 1571 and 1573
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.php.net/repository/pear/packages/Text_Wiki/trunk@161094 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Paul M Jones committed Jun 11, 2004
1 parent 7ebbcc9 commit c3d4bcc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
34 changes: 27 additions & 7 deletions Text/Wiki/Parse/Embed.php
Expand Up @@ -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
Expand All @@ -37,7 +44,7 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse {
*
*/

var $regex = '/(\[\[embed )(.+?)(\]\])/i';
var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i';


/**
Expand All @@ -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)
);
}
}
?>
28 changes: 22 additions & 6 deletions Text/Wiki/Parse/Include.php
Expand Up @@ -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
Expand All @@ -39,7 +45,7 @@ class Text_Wiki_Parse_Include extends Text_Wiki_Parse {
*
*/

var $regex = '/(\[\[include )(.+?)(\]\])/i';
var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';


/**
Expand All @@ -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;
}
}
?>
9 changes: 2 additions & 7 deletions Text/Wiki/Render/Xhtml/Embed.php
Expand Up @@ -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'];
}
}
?>

0 comments on commit c3d4bcc

Please sign in to comment.