function forena_generate_doc in Forena Reports 7
Same name and namespace in other branches
- 6 forena.common.inc \forena_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:
2 calls to forena_generate_doc()
- forena_render_report in ./
forena.module - Render report with some data
- forena_report in ./
forena.module - 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
- ./
forena.common.inc, line 845 - Common functions used throughout the project but loaded in this file to keep the module file lean.
Code
function forena_generate_doc($format, $output, $options = array()) {
$doc = forena_get_doctypes($format);
if ($doc) {
$all_methods = $doc
->doc_types();
$method = $all_methods[$format];
$ret = $doc
->{$method}($output, $options);
}
if ($ret) {
// 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");
print $ret;
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");
print $ret;
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");
print $ret;
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");
print $ret;
break;
default:
return $ret;
}
// Print the output.
}
else {
return $ret;
}
}