From f787b3c40b9d693a95494113e0b69f1438c2a5f2 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 31 Dec 2021 12:19:19 +0000 Subject: [PATCH] Allow chart dropdown labels to be translatable. Prior to this change, the strings 'Tabular', 'Bar Chart' and 'Pie Chart' were hardcoded. --- CRM/Report/Form.php | 6 ++++++ CRM/Report/Form/Contribute/Lybunt.php | 15 ++++++++------- CRM/Report/Form/Contribute/SoftCredit.php | 12 +++++++----- CRM/Report/Form/Contribute/Summary.php | 12 +++++++----- CRM/Report/Form/Contribute/Sybunt.php | 13 +++++++------ CRM/Report/Form/Contribute/TopDonor.php | 13 +++++++------ CRM/Report/Form/Event/IncomeCountSummary.php | 14 ++++++++------ CRM/Report/Form/Event/Summary.php | 14 ++++++++------ CRM/Report/Form/Mailing/Bounce.php | 13 +++++++------ CRM/Report/Form/Mailing/Clicks.php | 13 +++++++------ CRM/Report/Form/Mailing/Opened.php | 13 +++++++------ CRM/Report/Form/Mailing/Summary.php | 12 +++++++----- CRM/Report/Form/Member/Lapse.php | 1 - CRM/Report/Form/Member/Summary.php | 13 ++++++++----- CRM/Report/Form/Membership/Summary.php | 14 ++++++++------ CRM/Report/Form/Pledge/Pbnp.php | 12 +++++++----- 16 files changed, 109 insertions(+), 81 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 322a8d9b11..6b6d37768d 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -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 diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 95789c10a9..759a62a74b 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -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. * @@ -249,6 +243,13 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { // 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(); @@ -630,7 +631,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $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. diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index a5d1f927d1..15db3e5c93 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -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', @@ -299,6 +294,13 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { // 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; diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 0d829bf8be..cb7a89af49 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -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; @@ -338,6 +333,13 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { $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'; diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index 4349dae5a7..7b77b6827e 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -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', @@ -244,6 +238,13 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { // 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(); diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 4e3ae6e87f..4f11326c08 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -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() { @@ -188,6 +182,13 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { ], ]; + // 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'; diff --git a/CRM/Report/Form/Event/IncomeCountSummary.php b/CRM/Report/Form/Event/IncomeCountSummary.php index fea8a0de4b..c5b7bb2705 100644 --- a/CRM/Report/Form/Event/IncomeCountSummary.php +++ b/CRM/Report/Form/Event/IncomeCountSummary.php @@ -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 = [ @@ -136,6 +130,14 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { ], ], ]; + + // Add charts support + $this->_charts = [ + '' => ts('Tabular'), + 'barChart' => ts('Bar Chart'), + 'pieChart' => ts('Pie Chart'), + ]; + parent::__construct(); } diff --git a/CRM/Report/Form/Event/Summary.php b/CRM/Report/Form/Event/Summary.php index 308d07edaf..a6265e6663 100644 --- a/CRM/Report/Form/Event/Summary.php +++ b/CRM/Report/Form/Event/Summary.php @@ -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 = [ @@ -105,6 +99,14 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { ], ]; $this->_currencyColumn = 'civicrm_participant_fee_currency'; + + // Add charts support + $this->_charts = [ + '' => ts('Tabular'), + 'barChart' => ts('Bar Chart'), + 'pieChart' => ts('Pie Chart'), + ]; + parent::__construct(); } diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index 4df4086508..27027d3586 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -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. * @@ -242,6 +236,13 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { '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(); diff --git a/CRM/Report/Form/Mailing/Clicks.php b/CRM/Report/Form/Mailing/Clicks.php index 7634844176..d56739014c 100644 --- a/CRM/Report/Form/Mailing/Clicks.php +++ b/CRM/Report/Form/Mailing/Clicks.php @@ -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. * @@ -199,6 +193,13 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { '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(); diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index 142d8d3d32..c7a68f2cb4 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -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. * @@ -190,6 +184,13 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { '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(); diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index 1bee34bd33..4b3f5a2b8e 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -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. */ @@ -287,6 +282,13 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { ]; // 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(); } diff --git a/CRM/Report/Form/Member/Lapse.php b/CRM/Report/Form/Member/Lapse.php index 864c70ef34..dad64c28fb 100644 --- a/CRM/Report/Form/Member/Lapse.php +++ b/CRM/Report/Form/Member/Lapse.php @@ -17,7 +17,6 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { protected $_summary = NULL; - protected $_charts = ['' => 'Tabular']; protected $_customGroupExtends = [ 'Membership', ]; diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index 7cb3dd125f..38ca5d7f8b 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -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']; @@ -159,6 +155,13 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { // 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(); diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index ddceca3387..4ba26fb9d8 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -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. */ @@ -117,6 +111,14 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { ], ], ]; + + // Add charts support + $this->_charts = [ + '' => ts('Tabular'), + 'barChart' => ts('Bar Chart'), + 'pieChart' => ts('Pie Chart'), + ]; + parent::__construct(); } diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index e9b97fbf07..e0e6f9f117 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -15,11 +15,6 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { - protected $_charts = [ - '' => 'Tabular', - 'barChart' => 'Bar Chart', - 'pieChart' => 'Pie Chart', - ]; public $_drilldownReport = ['pledge/summary' => 'Link to Detail Report']; protected $_customGroupExtends = [ @@ -160,6 +155,13 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_pledge'); + // Add charts support + $this->_charts = [ + '' => ts('Tabular'), + 'barChart' => ts('Bar Chart'), + 'pieChart' => ts('Pie Chart'), + ]; + $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; $this->_currencyColumn = 'civicrm_pledge_currency'; -- 2.25.1