public function FrxSyntaxEngine::replace in Forena Reports 6
Same name and namespace in other branches
- 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 7 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 7.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 7.3 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 7.4 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
Parameters
$text text that needs replacing:
$data:
Return value
unknown_type
File
- ./
FrxSyntaxEngine.inc, line 159 - FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.
Class
Code
public function replace($text, $data = '', $raw = FALSE) {
$match = array();
$o_text = $text;
// Put the data on the stack.
if ($data) {
$this
->push_data($data);
}
if (preg_match_all($this->tpattern, $o_text, $match)) {
//list($params) = $match[1];
$i = 0;
foreach ($match[0] as $match_num => $token) {
$path = trim($token, $this->trim_chars);
$value = $this
->get_value($path, $raw);
$pos = strpos($text, $token);
if ($pos !== FALSE) {
$text = substr_replace($text, $value, $pos, strlen($token));
}
}
}
if ($data) {
$this
->pop_data();
}
return $text;
}