function ReportEditor::report in Forena Reports 7.5
Load and render a report based on a drupal path. In this function the arglist is used to get the full path to the report. Pass parameters or NULL to use get /post parameters.
Return value
unknown
1 call to ReportEditor::report()
- ReportEditor::preview in src/
Editor/ ReportEditor.php
File
- src/
Editor/ ReportEditor.php, line 984 - ReportEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd
Class
Namespace
Drupal\forena\EditorCode
function report($parms = array(), $print = FALSE, $no_cache = FALSE, $filename = '') {
global $user;
global $language;
$this->field_ids = array();
$format = $this->desc['format'];
if ($format == 'web' && $print) {
drupal_add_css(drupal_get_path('module', 'forena') . '/forena.css');
}
$r = $this->frxReport;
// Determine the data to get.
if (!$parms) {
$parms = array_merge($_GET, $_POST);
unset($parms['q']);
}
// Removed this becuase we don't want it to nuke xml.
//else $parms = (array)$parms;
// Allow other modules to alter paramters.
$this
->alterParameters($parms);
//check for default parameters
$missing_parms = $r
->processParameters($parms);
Frx::Skin()
->load($r->skin);
Frx::Skin()
->loadSkinFiles($this->report_name);
$cached_data = FALSE;
$cache = array();
$o = Frx::Document($format);
$o
->header($this->frxReport, $print);
$this->frxReport->allowDirectWrite = $o->allowDirectOutput;
if ($this->frxReport->allowDirectWrite && $filename) {
$this->frxReport->file = fopen($filename, 'w');
}
Frx::Data()
->push($parms, 'parm');
if (!$missing_parms) {
// Check for cache data
if ($r->cache && !$r->preview_mode) {
// Get file modification time for determining if cache needs to be rebuilt.
$entry = @Frx::File()
->getCacheEntry($this->desc['filename']);
$cid = 'forena:report:' . $this->report_name . ':' . drupal_http_build_query($parms);
if (@$r->cache['per_user'] && $user) {
$cid .= ':' . $user->uid;
}
if (@$r->cache['per_doctype']) {
@($cid .= ':' . $format);
}
$cache = cache_get($cid, 'cache');
if (!$cache || isset($r->cache['duration']) && $cache->expire < time() || $cache->created < $entry->mtime || $no_cache) {
$this->field_ids = array();
$r
->render($format);
$time = null;
if (isset($r->cache['duration'])) {
try {
$time = @new DateTime($r->cache['duration']);
} catch (Exception $e) {
drupal_set_message('Invalid Cache Duration', 'error', TRUE);
}
if ($time) {
$time = $time
->getTimeStamp();
}
}
if (!$time) {
$time = CACHE_PERMANENT;
}
$r->cache['content'] = $r->html;
$r->cache['title'] = $r->title;
cache_set($cid, $r->cache, 'cache', $time);
}
else {
$r->html = $cache->data['content'];
$r->title = $cache->data['title'];
}
}
else {
$r
->render($format);
}
}
else {
$r
->parametersForm(array(
'collapsible' => FALSE,
'collapsed' => FALSE,
));
}
$links = '';
if ($r->preview_mode) {
$r_link = str_replace('/', '.', $this->report_name);
$parms = $_GET;
unset($parms['q']);
$links = '<div class="forena-edit-links">';
$links .= $this
->l_icon("reports/{$r_link}/edit/select-data/add-data", 'plus.svg', 'Add Data', $parms, t('Data'));
$links .= '</div>';
}
$content = array(
'#has_data' => $r->blocks_loaded,
'parameter_form' => $r->parameters_form,
'editorLinks' => array(
'#markup' => $this
->editorLinks(),
),
'links' => $this
->documentLinks(),
'content' => array(
'#markup' => $r->html . $links,
),
);
if ($this->frxReport->file) {
$this->frxReport
->writeBuffer();
fclose($this->frxReport->file);
return '';
}
if ($o) {
$output = $o
->render($r, $format, $content);
if ($filename) {
file_put_contents($filename, $output);
return '';
}
if ($print) {
$printed = $o
->output($output);
}
else {
$printed = FALSE;
}
if (!$printed) {
return $output;
}
}
else {
return $content;
}
Frx::Data()
->pop();
}