Skip to content

Commit

Permalink
Merge pull request #22349 from braders/chart-label-translatable
Browse files Browse the repository at this point in the history
Allow chart dropdown labels to be translatable.
  • Loading branch information
demeritcowboy authored Jan 3, 2022
2 parents 7437be6 + f787b3c commit dd0aaff
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 81 deletions.
6 changes: 6 additions & 0 deletions CRM/Report/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@ class CRM_Report_Form extends CRM_Core_Form {
*/
public $optimisedForOnlyFullGroupBy = TRUE;

/**
* Determines which chart types are supported for this report
* @var string[]
*/
protected $_charts = [];

/**
* Get the number of rows to show
* @return int
Expand Down
15 changes: 8 additions & 7 deletions CRM/Report/Form/Contribute/Lybunt.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
*/
class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form {

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
* This is the report that links will lead to.
*
Expand Down Expand Up @@ -249,6 +243,13 @@ public function __construct() {
// If we have a campaign, build out the relevant elements
$this->addCampaignFields('civicrm_contribution');

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
Expand Down Expand Up @@ -630,7 +631,7 @@ public function buildChart(&$rows) {
$current_year = $this->_params['yid_value'];
$previous_year = $current_year - 1;
$interval[$previous_year] = $previous_year;
$interval['life_time'] = 'Life Time';
$interval['life_time'] = ts('Life Time');

foreach ($rows as $key => $row) {
// The final row contains the totals so we don't need to include it here.
Expand Down
12 changes: 7 additions & 5 deletions CRM/Report/Form/Contribute/SoftCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form {
protected $_emailFieldCredit = FALSE;
protected $_phoneField = FALSE;
protected $_phoneFieldCredit = FALSE;
protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

protected $_customGroupExtends = [
'Contact',
Expand Down Expand Up @@ -299,6 +294,13 @@ public function __construct() {
// If we have a campaign, build out the relevant elements
$this->addCampaignFields('civicrm_contribution');

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;

Expand Down
12 changes: 7 additions & 5 deletions CRM/Report/Form/Contribute/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
*/
class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];
protected $_customGroupExtends = ['Contribution', 'Contact', 'Individual'];
protected $_customGroupGroupBy = TRUE;

Expand Down Expand Up @@ -338,6 +333,13 @@ public function __construct() {

$this->addCampaignFields('civicrm_contribution', TRUE);

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_tagFilter = TRUE;
$this->_groupFilter = TRUE;
$this->_currencyColumn = 'civicrm_contribution_currency';
Expand Down
13 changes: 7 additions & 6 deletions CRM/Report/Form/Contribute/Sybunt.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
*/
class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form {

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

protected $_customGroupExtends = [
'Contact',
'Individual',
Expand Down Expand Up @@ -244,6 +238,13 @@ public function __construct() {
// If we have a campaign, build out the relevant elements
$this->addCampaignFields('civicrm_contribution');

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
Expand Down
13 changes: 7 additions & 6 deletions CRM/Report/Form/Contribute/TopDonor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form {

public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report'];

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
*/
public function __construct() {
Expand Down Expand Up @@ -188,6 +182,13 @@ public function __construct() {
],
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
$this->_currencyColumn = 'civicrm_contribution_currency';
Expand Down
14 changes: 8 additions & 6 deletions CRM/Report/Form/Event/IncomeCountSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form {

protected $_summary = NULL;

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

protected $_add2groupSupported = FALSE;

protected $_customGroupExtends = [
Expand Down Expand Up @@ -136,6 +130,14 @@ public function __construct() {
],
],
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

parent::__construct();
}

Expand Down
14 changes: 8 additions & 6 deletions CRM/Report/Form/Event/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form {

protected $_summary = NULL;

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

protected $_add2groupSupported = FALSE;

protected $_customGroupExtends = [
Expand Down Expand Up @@ -105,6 +99,14 @@ public function __construct() {
],
];
$this->_currencyColumn = 'civicrm_participant_fee_currency';

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

parent::__construct();
}

Expand Down
13 changes: 7 additions & 6 deletions CRM/Report/Form/Mailing/Bounce.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form {
'Organization',
];

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
* This report has not been optimised for group filtering.
*
Expand Down Expand Up @@ -242,6 +236,13 @@ public function __construct() {
'grouping' => 'contact-fields',
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
Expand Down
13 changes: 7 additions & 6 deletions CRM/Report/Form/Mailing/Clicks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form {
'Organization',
];

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
* This report has not been optimised for group filtering.
*
Expand Down Expand Up @@ -199,6 +193,13 @@ public function __construct() {
'grouping' => 'mailing-fields',
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
Expand Down
13 changes: 7 additions & 6 deletions CRM/Report/Form/Mailing/Opened.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form {
'Organization',
];

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
* This report has not been optimised for group filtering.
*
Expand Down Expand Up @@ -190,6 +184,13 @@ public function __construct() {
'grouping' => 'mailing-fields',
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
Expand Down
12 changes: 7 additions & 5 deletions CRM/Report/Form/Mailing/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form {

public $_drilldownReport = ['mailing/detail' => 'Link to Detail Report'];

protected $_charts = [
'' => 'Tabular',
'barchart' => 'Bar Chart',
];

/**
* Class constructor.
*/
Expand Down Expand Up @@ -287,6 +282,13 @@ public function __construct() {
];
// If we have campaigns enabled, add those elements to both the fields, filters.
$this->addCampaignFields('civicrm_mailing');

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
];

parent::__construct();
}

Expand Down
1 change: 0 additions & 1 deletion CRM/Report/Form/Member/Lapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
class CRM_Report_Form_Member_Lapse extends CRM_Report_Form {

protected $_summary = NULL;
protected $_charts = ['' => 'Tabular'];
protected $_customGroupExtends = [
'Membership',
];
Expand Down
13 changes: 8 additions & 5 deletions CRM/Report/Form/Member/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form {

protected $_summary = NULL;
protected $_interval = NULL;
protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

protected $_add2groupSupported = FALSE;

protected $_customGroupExtends = ['Membership'];
Expand Down Expand Up @@ -159,6 +155,13 @@ public function __construct() {
// If we have campaigns enabled, add those elements to both the fields, filters and group by
$this->addCampaignFields('civicrm_membership', TRUE);

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

$this->_groupFilter = TRUE;
$this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
Expand Down
14 changes: 8 additions & 6 deletions CRM/Report/Form/Membership/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form {

protected $_summary = NULL;

protected $_charts = [
'' => 'Tabular',
'barChart' => 'Bar Chart',
'pieChart' => 'Pie Chart',
];

/**
* Constructor function.
*/
Expand Down Expand Up @@ -117,6 +111,14 @@ public function __construct() {
],
],
];

// Add charts support
$this->_charts = [
'' => ts('Tabular'),
'barChart' => ts('Bar Chart'),
'pieChart' => ts('Pie Chart'),
];

parent::__construct();
}

Expand Down
Loading

0 comments on commit dd0aaff

Please sign in to comment.