function FrxReportGenerator::generate_doc in Forena Reports 7.2
Same name and namespace in other branches
- 6.2 FrxReportGenerator.inc \FrxReportGenerator::generate_doc()
@return: The document in the requested format. Returns a string if not able to format.
Parameters
unknown_type $format: The extension of the document to be rendered:
unknown_type $output: The string of the page to be displayed:
1 call to FrxReportGenerator::generate_doc()
- FrxReportGenerator::report in ./
FrxReportGenerator.inc - 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.
File
- ./
FrxReportGenerator.inc, line 603 - Common functions used throughout the project but loaded in this file to keep the module file lean.
Class
Code
function generate_doc($format, $output, $options = array(), $print = TRUE) {
watchdog('debug', 'format' . $format);
$doc = $this
->get_doctypes($format);
if ($doc) {
$all_methods = $doc
->doc_types();
$method = $all_methods[$format];
$ret = $doc
->{$method}($output, $options);
}
if ($ret && $print) {
// If an object was found, set the appropriate mime type (header doctype).
// $flen = strlen($ret);
switch ($format) {
case 'doc':
header('Content-Type: application/msword');
header('Cache-Control:');
header('Pragma:');
header("Cache-Control: must-revalidate");
break;
case 'pdf':
header('Content-Type: application/pdf');
header('Cache-Control:');
header('Pragma:');
header("Cache-Control: must-revalidate");
header("Content-Disposition: attachment; filename=report.pdf");
break;
case 'xls':
header('Content-Type: application/msexcel');
header('Cache-Control:');
header('Pragma:');
header("Cache-Control: must-revalidate");
header("Content-Disposition: attachment; filename=report.xls");
break;
case 'csv':
header('Content-Type: application/csv');
header('Cache-Control:');
header('Pragma:');
header("Cache-Control: must-revalidate");
header("Content-Disposition: attachment; filename=report.csv");
break;
case 'svg':
header('Content-Type: image/svg+xml');
header('Cache-Control:');
header('Pragma:');
header('Cache-Control: must-revalidate');
break;
}
}
return $ret;
}