if (empty($this->_instanceValues)) {
CRM_Core_Error::fatal("Report could not be loaded.");
}
-
+ $this->_title = $this->_instanceValues['title'];
if (!empty($this->_instanceValues['permission']) &&
(!(CRM_Core_Permission::check($this->_instanceValues['permission']) ||
CRM_Core_Permission::check('administer Reports')
function getDefaultValues() {
return $this->_defaults;
}
+ /**
+ * Getter for $_title
+ * @return string $_title
+ */
+ function getTitle() {
+ return $this->_title;
+ }
function addColumns() {
$options = array();
* @access public
*/
function civicrm_api3_report_template_getrows($params) {
- list($rows, $instance) = _civicrm_api3_report_template_getrows($params);
- return civicrm_api3_create_success($rows, $params, 'report_template');
+ list($rows, $instance, $labels) = _civicrm_api3_report_template_getrows($params);
+ return civicrm_api3_create_success($rows, $params, 'report_template', 'getrows', CRM_Core_DAO::$_nullObject, $labels);
}
function _civicrm_api3_report_template_getrows($params) {
$reportInstance->setOffsetValue($options['offset']);
$reportInstance->beginPostProcessCommon();
$sql = $reportInstance->buildQuery();
- $rows = array();
+ $rows = $metadata = array();
$reportInstance->buildRows($sql, $rows);
- return array($rows, $reportInstance);
+ $metadata['title'] = $reportInstance->getTitle();
+ foreach ($reportInstance->_columnHeaders as $key => $header) {
+ //would be better just to expect reports to provide titles but reports are not consistent
+ //NB I think these are already translated
+ $metadata['labels'][$key] = !empty($header['title']) ? $header['title'] : '';
+ }
+ return array($rows, $reportInstance, $metadata);
}
function civicrm_api3_report_template_getstatistics($params) {
- list($rows, $reportInstance) = _civicrm_api3_report_template_getrows($params);
+ list($rows, $reportInstance, $labels) = _civicrm_api3_report_template_getrows($params);
$stats = $reportInstance->statistics($rows);
return civicrm_api3_create_success($stats, $params, 'report_template');
}
'civicrm_country_name' => 'United States',
),
),
+ 'title' => '',
+ 'labels' => array(
+ 'civicrm_contact_sort_name' => 'Contact Name',
+ 'civicrm_contact_id' => 'Internal Contact ID',
+ 'civicrm_address_street_address' => 'Street Address',
+ 'civicrm_address_city' => 'City',
+ 'civicrm_country_name' => 'Country',
+ ),
);
return $expectedResult;
$result = $this->callAPIAndDocument('report_template', 'getrows', array(
'report_id' => 'contact/summary',
), __FUNCTION__, __FILE__, $description, 'Getrows', 'getrows');
+ $this->assertEquals('Contact Name', $result['labels']['civicrm_contact_sort_name']);
//the second part of this test has been commented out because it relied on the db being reset to
// it's base state