public function FrxReport::format in Forena Reports 6
Same name and namespace in other branches
- 6.2 FrxReport.inc \FrxReport::format()
- 7 FrxReport.inc \FrxReport::format()
- 7.2 FrxReport.inc \FrxReport::format()
- 7.3 FrxReport.inc \FrxReport::format()
- 7.4 FrxReport.inc \FrxReport::format()
File
- ./
FrxReport.inc, line 247 - Basic report provider. Controls the rendering of the report.
Class
Code
public function format($value, $key, $data) {
// Determine if there is a field overide entry
$default = '';
$link = '';
$format = '';
$format_str = '';
$target = '';
if ($this->fields) {
$path = 'frx:field[@id="' . $key . '"]';
$formatters = $this->fields
->xpath($path);
if ($formatters) {
foreach ($formatters as $formatter) {
if (isset($formatter['block']) && (string) $formatter['block'] == $this->block || !(string) $formatter['block']) {
//@TODO: Replace the default extraction with something that will get sub elements of the string
$default = (string) $formatter;
$link = (string) $formatter['link'];
$format = (string) $formatter['format'];
$format_str = (string) $formatter['format-string'];
$target = (string) $formatter['target'];
}
}
}
}
if ($format) {
$value = forena_format_data($value, $format, $format_str, $this->teng);
}
// Default if specified
if (!$value && $default) {
$value = $default;
}
if ($link) {
$target = $this->teng
->replace($target, $data, TRUE);
$link = $this->teng
->replace($link, $data, TRUE);
@(list($url, $query) = explode('?', $link));
@(list($query, $queryFrag) = explode('#', $query));
@(list($url, $fragment) = explode('#', $url));
$fragment = $fragment . $queryFrag;
$data = array();
parse_str($query, $data);
if (strpos(strtolower($target), 'popup') === 0) {
$opts = 'status=1';
$options = "status=1";
$attributes = array(
'onclick' => 'window.open(this.href,\'' . $target . '\', "' . $options . '"); return false;',
);
}
else {
$attributes = array(
'target' => $target,
);
}
if (trim($url)) {
$value = l(htmlspecialchars_decode($value), $url, array(
'fragment' => $fragment,
'query' => $data,
'attributes' => $attributes,
'absolute' => TRUE,
));
}
}
return $value;
}