public function ReportFileSystem::reportsByCategory in Forena Reports 8
Generate an ordered list of reports by category
Parameters
$categories:
Return value
array Categories
File
- src/
File/ ReportFileSystem.php, line 163
Class
Namespace
Drupal\forena\FileCode
public function reportsByCategory($categories = array()) {
$this
->scan();
$data = $this
->allReports();
$reports = array();
if ($data) {
foreach ($data as $base_name => $obj) {
if ($obj->metaData && @$obj->metaData['category'] && empty($obj->metaData['hidden'])) {
$cache = $obj->metaData;
if (!$categories || array_search($cache['category'], $categories) !== FALSE) {
// Check each callback function to see if we have an error.
$access = TRUE;
if (@$cache['access']) {
$access = FALSE;
foreach ($cache['access'] as $provider => $rights) {
$m = DataManager::instance()
->repository($provider);
foreach ($rights as $right) {
if ($m
->access($right)) {
$access = TRUE;
}
}
}
}
if ($access) {
$reports[$cache['category']][] = array(
'title' => $cache['title'],
'category' => $cache['category'],
'report_name' => $base_name,
);
}
}
}
}
}
$sort = defined('SORT_NATURAL') ? SORT_NATURAL : SORT_REGULAR;
// Sort the reports
if ($reports) {
foreach ($reports as $category => $list) {
uasort($reports[$category], [
$this,
'reportTitleCompare',
]);
}
}
ksort($reports, $sort);
return $reports;
}