Commit ccec9e01 authored by cxiao's avatar cxiao

Clean up templates for crm_core_report and make it cross theme compitable

parent 97491725
......@@ -60,22 +60,34 @@ function crm_core_report_theme() {
// - report items
// - widgets
// - report index
return array(
'crm_core_report_index' => array(
'template' => 'crm-core-report-index',
'variables' => array('report_index' => NULL),
'path' => drupal_get_path('module', 'crm_core_report') . '/templates',
),
'crm_core_report_index_item' => array(
'template' => 'crm-core-report-index-item',
'variables' => array('title' => NULL, 'report' => NULL),
'variables' => array('reports' => NULL, 'report_items' => array()),
'path' => drupal_get_path('module', 'crm_core_report') . '/templates',
),
);
}
/**
* Preprocess report index
*/
function crm_core_report_preprocess_crm_core_report_index(&$variables) {
$report_items = array();
$reports = $variables['reports'];
if (!empty($reports)) {
foreach ($reports as $key => $item) {
$items = array();
foreach ($item['reports'] as $report) {
$items[] = l($report['title'], $report['path']) . '<br />' . $report['description'];
}
$report_items[] = theme('item_list', array('items' => $items, 'title' => $item['title']));
}
}
$variables['report_items'] = $report_items;
}
/**
* Constructs a list of registered reports and widgets for CRM Core
......
<?php
/**
* @file
* Default display of reports for CRM Core
*
* Available variables:
*
* - $reports: associative array listing all reports available
* in the system. Each entry is an array with the following keys:
* - title: A title for the report grouping.
* - reports: A list of the reports to be found. This is an array
* keyed by individual reports, and includes the following keys:
* - title: title for the report
* - description: a description of the report
* - path: a path to the report
* - widgets: A list of widgets indexed by CRM Core.
*/
?>
<div class="crm_core_reports">
<?php
foreach($reports as $item => $listing){
print theme('crm_core_report_index_item', array('title' => $listing['title'], 'report' => $listing['reports']));
}
?>
</div>
<?php
/**
* @file
* Default display of reports for CRM Core
......@@ -17,19 +16,13 @@
* - widgets: A list of widgets indexed by CRM Core. These can be ignored
* in this template, or used if you want to be funny.
*/
?>
<h3><?php print $title; ?></h3>
<div class="item-info">
<?php
$reports = array();
foreach($report as $item => $val){
$reports[] = l(t($val['title']), $val['path']) . '<br>' . t($val['description']);
}
if(sizeof($reports) > 0) {
print theme_item_list(array('items' => $reports, 'title' => NULL, 'type' => 'ul', 'attributes' => array()));
}
?>
<div class="crm_core_reports">
<?php foreach($report_items as $item): ?>
<div class="item-info">
<?php print $item; ?>
</div>
<?php endforeach; ?>
</div>
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