protected function FrxSyntaxEngine::get_value in Forena Reports 7.2
Same name and namespace in other branches
- 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::get_value()
- 6 FrxSyntaxEngine.inc \FrxSyntaxEngine::get_value()
- 7 FrxSyntaxEngine.inc \FrxSyntaxEngine::get_value()
- 7.3 FrxSyntaxEngine.inc \FrxSyntaxEngine::get_value()
- 7.4 FrxSyntaxEngine.inc \FrxSyntaxEngine::get_value()
Get the value from the data. This is used by token_replace method to extract the data based on the path provided.
Parameters
$data:
$key:
Return value
unknown_type
1 call to FrxSyntaxEngine::get_value()
File
- ./
FrxSyntaxEngine.inc, line 67 - 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
protected function get_value($key, $raw = FALSE) {
$retvar = '';
// Default to theo current context
$data = $this->frxData
->currentContext();
// Determine if we have a . syntax for the id.
$raw_key = $key;
if ($key && strpos($key, '.')) {
@(list($id, $path) = explode('.', $key, 2));
if ($this->frxData
->contextExists($id)) {
$data = $this->frxData
->getContext($id);
$key = $path;
}
}
if (is_array($data)) {
$retvar = @$data[$key];
}
elseif (is_object($data)) {
if (strpos($key, '=') === 0) {
$retvar = $this
->simplexml_evaluate($data, ltrim($key, '='));
}
else {
$rows = $data
->xpath($key);
$x = '';
if ($rows) {
$x = $rows[0];
}
if ($x) {
$retvar = $x
->asXML();
}
// Check to see if there are child nodes
// If so use asXML otherwise string cast.
if ($retvar && strpos($retvar, '<') !== FALSE) {
// Find the end of the first tag.
$p = strpos($retvar, '>');
$retvar = substr_replace($retvar, '', 0, $p + 1);
$p = strrpos($retvar, '<', -1);
$retvar = substr_replace($retvar, '', $p, strlen($retvar) - $p);
}
else {
$retvar = (string) $x;
}
}
}
// Call the formatter object if neccessary
$f = $this->formatter;
if (!$raw && is_object($f) && method_exists($f, 'format')) {
$retvar = $f
->format($retvar, $raw_key, $data);
}
$retvar = trim((string) $retvar);
return $retvar;
}