function FrxDrupalApplication::load_report in Forena Reports 7.2
Same name and namespace in other branches
- 6.2 FrxDrupalApplication.inc \FrxDrupalApplication::load_report()
- 7.3 FrxDrupalApplication.inc \FrxDrupalApplication::load_report()
- 7.4 FrxDrupalApplication.inc \FrxDrupalApplication::load_report()
Accepts the name of a file
Returns a xml object of the file.
Overrides FrxHostApplication::load_report
File
- ./
FrxDrupalApplication.inc, line 117 - HostApp.inc Defines all the interface points between the host application and Forena. Each of these methods must be specified in order for Forena to function properly. The base class here is drupal, so those
Class
Code
function load_report($report_name) {
$r = null;
global $language;
$r_text = '';
if ($report_name) {
$i_report_name = $report_name;
$report_path = $this
->configuration('report_repos');
$int_filename = $report_path . '/' . $language->language . '/' . $report_name . '.frx';
$filename = $report_path . '/' . $report_name . '.frx';
if (file_exists($int_filename) && @$_GET['language'] != 'en') {
$i_report_name = $language->language . '/' . $report_name;
$r_text = file_get_contents($int_filename);
$modified = filemtime($int_filename);
$filename = $int_filename;
}
elseif (file_exists($filename)) {
$r_text = file_get_contents($filename);
$modified = filemtime($filename);
}
$result = db_query("SELECT * FROM {forena_reports} WHERE report_name=:report_name AND language=:language", array(
':report_name' => $report_name,
':language' => $language->language,
));
$save = FALSE;
if ($rpt = $result
->fetchObject()) {
// If the file modification time has changed then save.
if ($modified && $rpt->modified != $modified) {
$save = TRUE;
}
// If the report has been altered by a user then use that.
if ($rpt->altered == -1) {
if ($rpt->src) {
$r_text = $rpt->src;
}
}
}
else {
if ($r_text) {
$save = TRUE;
}
}
if ($save) {
require_once 'forena.admin.inc';
forena_save_report($i_report_name, $r_text, FALSE);
}
return $r_text;
}
}