public function FrxSyntaxEngine::replace in Forena Reports 7.2
Same name and namespace in other branches
- 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 6 FrxSyntaxEngine.inc \FrxSyntaxEngine::replace()
- 7 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 129 - 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, $raw = FALSE) {
if (is_array($text)) {
foreach ($text as $key => $value) {
$text[$key] = $this
->replace($value, $raw);
}
return $text;
}
//Otherswise assume text
$match = array();
$o_text = $text;
// Put the data on the stack.
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));
}
}
}
return $text;
}