You are here

public function ReportFileSystem::allReports in Forena Reports 8

List all the reports for a language.

Return value

array array containing all reports.

1 call to ReportFileSystem::allReports()
ReportFileSystem::reportsByCategory in src/File/ReportFileSystem.php
Generate an ordered list of reports by category

File

src/File/ReportFileSystem.php, line 69

Class

ReportFileSystem

Namespace

Drupal\forena\File

Code

public function allReports() {
  $this
    ->scan();
  $reports = array();
  $data = $this
    ->allMetadataForExt('frx');
  $def_language = $this->default_language;
  if ($data) {
    foreach ($data as $base_name => $obj) {
      if ($obj->metaData) {
        if ($obj->metaData['language'] != 'en') {
          $rpt_name = substr($base_name, strlen($obj->metaData['language']) + 1);
        }
        else {
          $rpt_name = $base_name;
        }
        if ($obj->metaData['language'] == $this->language) {
          $reports[$rpt_name] = $obj;
        }
        elseif ($obj->metaData['language'] == $def_language && (!isset($reports[$rpt_name]) || $reports[$rpt_name]->metaData['language'] == 'en')) {
          $reports[$rpt_name] = $obj;
        }
        elseif ($obj->metaData['language'] == 'en' && !isset($reports[$rpt_name])) {
          $reports[$rpt_name] = $obj;
        }
      }
    }
  }
  uasort($reports, [
    $this,
    'reportCompare',
  ]);
  return $reports;
}