Commit baa0338f authored by David Metzler's avatar David Metzler
Browse files

Report list now pulled form file cache.

parent 7f06e8b8
......@@ -25,6 +25,39 @@ class FrxReportFile extends FrxFile {
parent::__construct($default_directory, $directories, array('frx', 'skinfo', 'css', 'js'));
}
/**
* List all the reports for a language.
* @return unknown
*/
public function allReports() {
GLOBAL $language;
$reports = array();
$data = $this->validateAllCache('frx');
if ($data) foreach ($data as $base_name => $obj) {
if ($obj->cache && $obj->cache['language'] == $language->language) {
$obj->name = $base_name;
$reports[ $obj->cache['category'] . $obj->cache['title']] = $obj;
}
}
dpm($reports);
uasort($reports, 'FrxReportFile::reportCompare');
dpm($reports);
return $reports;
}
static public function reportCompare($a, $b) {
$c = strnatcasecmp($a->cache['category'], $b->cache['category']);
if (!$c) {
$c = strnatcasecmp($a->cache['title'], $b->cache['title']);
}
return $c;
}
/**
* Generate an ordered list of reports by category
* @param $categories
* @return array Categories
*/
public function reportsByCategory($categories = array()) {
GLOBAL $language;
$data = $this->validateAllCache('frx');
......
......@@ -29,15 +29,15 @@ function forena_admin_reports() {
drupal_add_js(drupal_get_path('module', 'forena') . '/forena.admin.js');
drupal_add_js('sites/all/libraries/dataTables/media/js/jquery.dataTables.min.js');
}
$headers = array(t('title'), t('name'), t('category'), t('operation'));
$result = db_query('SELECT * FROM {forena_reports} where language=:language ORDER BY category,title', array(':language' => $language->language));
$headers = array(t('category'), t('title'), t('name'), t('operation'));
$result = Frx::File()->allReports();
foreach ($result as $row) {
$rpt = str_replace('/', '.', $row->report_name);
$rpt = str_replace('/', '.', $row->name);
$edit = l(t('Edit'), 'reports/' . $rpt . '/edit');
$clone = l(t('Clone'), 'reports/add/' . $rpt);
$delete = l(t('Delete'), 'reports/' . $rpt . '/delete', array('query' => array('destination' => 'admin/structure/reports')));
$title = l(t($row->title), 'reports/' . $rpt);
$data[] = array($title, $row->report_name, $row->category, $edit . ' ' . $clone . ' ' . $delete);
$title = l(t($row->cache['title']), 'reports/' . $rpt);
$data[] = array($row->cache['category'], $title, $row->name, $edit . ' ' . $clone . ' ' . $delete);
}
$output .= '<div id="forena-reports-list">';
$output .= theme_table(array('header' => $headers, 'rows' => $data, 'attributes' => array('class' => array( 'dataTable-paged')), 'caption' => '', 'sticky' => TRUE, 'colgroups' => array(), 'empty' => ''));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment