You are here

function forena_report_desc in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 forena.common.inc \forena_report_desc()
  2. 7 forena.common.inc \forena_report_desc()
  3. 7.2 forena.common.inc \forena_report_desc()

Get name from argument 1 or alterntaively from a file name

Parameters

unknown_type $name:

9 calls to forena_report_desc()
forena_admin_params_form in ./forena.admin.inc
forena_data_block_form in ./forena.admin.inc
A form to preview and add data blocks to an existing report
forena_delete_form in ./forena.admin.inc
Form to confirm the delete of a form.
forena_edit_delete_submit in ./forena.admin.inc
Handle delete buttons from edit forms.
forena_fields_form in ./forena.admin.inc

... See full list

File

./forena.common.inc, line 17
Common functions used throughout the project but loaded in this file to keep the module file lean.

Code

function forena_report_desc($name = '') {
  if (!$name) {
    $name = arg(1);
  }

  // Get defined document types
  $doctypes = forena_supported_doctypes();
  $parts = explode('.', $name);
  $name = '';
  if ($parts) {
    foreach ($parts as $part) {
      if (!$doctypes[$part]) {
        $name .= '/' . $part;
      }
      else {
        $desc['format'] = $part;
      }
    }
  }
  $desc['name'] = trim($name, '/');
  $report_path = variable_get('forena_report_repos', 'reports');
  list($dir, $name_part) = explode('/', $name_part, -2);
  if (!$name_part) {
    $dir = '';
  }
  $desc['directory'] = $report_path . '/' . $dir;
  $desc['filename'] = $report_path . '/' . trim($name, ' /') . '.frx';
  $desc['link'] = 'reports/' . trim(str_replace('/', '.', $name), '.');
  if (file_exists($desc['filename'])) {
    $desc['exists'] = TRUE;
  }
  return $desc;
}