From f15ba5a868f425c7f227d01ad20b56a93c535eae Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 16 Feb 2021 09:12:20 +1300 Subject: [PATCH] dev/translation#65 Further remove moneyValueFormat We deprecated this a while back. It is now removed except for behind the scenes setting & getting of the value - which can go after we do a universe search or after a few more months --- CRM/Admin/Form/Setting/Localization.php | 1 - CRM/Utils/Money.php | 21 ++++--------------- api/v3/examples/Setting/GetFields.ex.php | 15 ------------- .../CRM/Admin/Form/Setting/Localization.tpl | 6 +----- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index 9dc3ae7c50..037e3aee6a 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -35,7 +35,6 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { 'monetaryThousandSeparator' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'monetaryDecimalPoint' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'moneyformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, - 'moneyvalueformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'provinceLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, ]; diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index 786fccd64c..08119a5402 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -43,14 +43,12 @@ class CRM_Utils_Money { * @param string $format * The desired currency format. * @param bool $onlyNumber - * @param string $valueFormat - * The desired monetary value display format (e.g. '%!i'). * * @return string * formatted monetary string * */ - public static function format($amount, $currency = NULL, $format = NULL, $onlyNumber = FALSE, $valueFormat = NULL) { + public static function format($amount, $currency = NULL, $format = NULL, $onlyNumber = FALSE) { if (CRM_Utils_System::isNull($amount)) { return ''; @@ -62,14 +60,6 @@ class CRM_Utils_Money { $format = $config->moneyformat; } - if (!$valueFormat) { - $valueFormat = $config->moneyvalueformat; - } - - if (!empty($valueFormat) && $valueFormat !== '%!i') { - CRM_Core_Error::deprecatedWarning('Having a Money Value format other than %!i is deprecated, please report this on the GitLab Issue https://lab.civicrm.org/dev/core/-/issues/1494 with the relevant moneyValueFormat you use.'); - } - if (!$currency) { $currency = $config->defaultCurrency; } @@ -96,7 +86,7 @@ class CRM_Utils_Money { CRM_Core_Error::deprecatedWarning('Passing empty currency to CRM_Utils_Money::format is deprecated if you need it for display without currency call CRM_Utils_Money::formatLocaleNumericRounded'); } - $amount = self::formatNumericByFormat($amount, $valueFormat); + $amount = self::formatNumericByFormat($amount); // If it contains tags, means that HTML was passed and the // amount is already converted properly, // so don't mess with it again. @@ -181,10 +171,7 @@ class CRM_Utils_Money { * @return string */ protected static function formatLocaleNumeric($amount) { - if (CRM_Core_Config::singleton()->moneyvalueformat !== '%!i') { - CRM_Core_Error::deprecatedWarning('Having a Money Value format other than !%i is deprecated, please report this on GitLab with the relevant moneyValueFormat you use.'); - } - return self::formatNumericByFormat($amount, CRM_Core_Config::singleton()->moneyvalueformat); + return self::formatNumericByFormat($amount); } /** @@ -304,7 +291,7 @@ class CRM_Utils_Money { * * @return string */ - protected static function formatNumericByFormat($amount, $valueFormat) { + protected static function formatNumericByFormat($amount, $valueFormat = '%!i') { // money_format() exists only in certain PHP install (CRM-650) // setlocale() affects native gettext (CRM-11054, CRM-9976) if (is_numeric($amount) && function_exists('money_format')) { diff --git a/api/v3/examples/Setting/GetFields.ex.php b/api/v3/examples/Setting/GetFields.ex.php index 19b17e6e5a..b906e47d3f 100644 --- a/api/v3/examples/Setting/GetFields.ex.php +++ b/api/v3/examples/Setting/GetFields.ex.php @@ -1774,21 +1774,6 @@ function setting_getfields_expectedresult() { 'description' => '', 'help_text' => '', ], - 'moneyvalueformat' => [ - 'group_name' => 'Localization Preferences', - 'group' => 'localization', - 'name' => 'moneyvalueformat', - 'type' => 'String', - 'quick_form_type' => 'Element', - 'html_type' => 'text', - 'default' => '%!i', - 'add' => '4.3', - 'title' => 'Monetary Value Display', - 'is_domain' => 1, - 'is_contact' => 0, - 'description' => '', - 'help_text' => '', - ], 'defaultCurrency' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', diff --git a/templates/CRM/Admin/Form/Setting/Localization.tpl b/templates/CRM/Admin/Form/Setting/Localization.tpl index 9666278ac6..be6d4b5c9a 100644 --- a/templates/CRM/Admin/Form/Setting/Localization.tpl +++ b/templates/CRM/Admin/Form/Setting/Localization.tpl @@ -69,11 +69,7 @@ {$form.moneyformat.label} {help id='moneyformat' title=$form.moneyformat.label} {$form.moneyformat.html} - - {$form.moneyvalueformat.label} {help id='moneyvalueformat' title=$form.moneyvalueformat.label} - {$form.moneyvalueformat.html}
Note that this setting is proposed to be deprecated as per this Gitlab Issue - - + {$form.customTranslateFunction.label} {help id='customTranslateFunction' title=$form.customTranslateFunction.label} {$form.customTranslateFunction.html} -- 2.25.1