public function FrxInclude::render in Forena Reports 7.4
Same name and namespace in other branches
- 6.2 plugins/FrxInclude.inc \FrxInclude::render()
- 7.2 plugins/FrxInclude.inc \FrxInclude::render()
- 7.3 renderers/FrxInclude.inc \FrxInclude::render()
Default Render action, which simply does normal forena rendering. You can use renderDomNode at any time to generate the default forena rendering methods.
Return value
Ambigous <string, unknown, unknown_type, text, mixed>
Overrides FrxRenderer::render
File
- renderers/
FrxInclude.inc, line 9 - FrxInclude Include a reference to another report as an asset. @author davidmetzler
Class
- FrxInclude
- @file FrxInclude Include a reference to another report as an asset. @author davidmetzler
Code
public function render() {
// Get data from source
$attributes = $this
->mergedAttributes();
$output = '';
// Determine data type
$include = @$attributes['src'];
$title = @$attributes['title'];
// Quit if we have no data.
if (!$include) {
return '';
}
// Reformat URL
@(list($url, $query_str) = @explode('?', $include));
$url = $this->teng
->replace($url, TRUE);
$report_url = $url;
$parts = @explode('/', $url);
$file = @$parts[count($parts) - 1];
$parts = explode('.', $file);
// Determine file extention
$ext = count($parts) > 1 ? $parts[count($parts) - 1] : '';
$query = array();
if ($query_str) {
parse_str($query_str, $query);
foreach ($query as $key => $value) {
$query[$key] = $this->teng
->replace($value, TRUE);
}
}
// Build URL
$options = array(
'query' => $query,
);
$url = url($url, $options);
$mode = isset($attributes['mode']) ? $attributes['mode'] : '';
if (!$mode) {
// Try and default in old method for loading.
if ($this->format == 'web' && strlen($ext) <= 4) {
$mode = 'reference';
}
}
switch ($mode) {
case 'ajax':
if (strpos($url, '/nojs/') === FALSE) {
if (!isset($attributes['id'])) {
$attributes['id'] = 'frx-include';
}
$id = @$attributes['id'];
$url = url("{$report_url}/nojs/{$id}/replace", $options);
if (isset($attributes['class'])) {
$attributes['class'] .= ' use-ajax forena-autoload';
}
else {
$attributes['class'] = 'use-ajax forena-autoload';
}
}
$output = $this
->render_reference($url, $ext, $attributes, $title);
break;
case 'reference':
$output = $this
->render_reference($url, $ext, $attributes, $title);
break;
case 'inline':
default:
$output = forena_report_include(str_replace('reports/', '', $report_url), $query);
}
return $output;
}