From 6cf5bb6f55e085ec23af226d0a18e97cb985dbd5 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Fri, 18 Oct 2013 13:20:02 -0700 Subject: [PATCH] Fix notices and formatting for word replacement --- CRM/Core/BAO/WordReplacement.php | 26 +++++++++++++++++--------- CRM/Core/I18n.php | 11 +++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index 8dd64935a9..615e933be2 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -40,10 +40,10 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { function __construct() { parent::__construct(); - } + } /** * Takes a bunch of params that are needed to match certain criteria and - * retrieves the relevant objects. + * retrieves the relevant objects. * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the flattened values @@ -52,7 +52,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { * @access public * @static */ - + static function retrieve(&$params, &$defaults) { return CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_WordRepalcement', $params, $defaults); } @@ -102,8 +102,8 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { */ static function create($params) { if(array_key_exists("domain_id",$params) === FALSE) { - $params["domain_id"] = CRM_Core_Config::domainID(); - } + $params["domain_id"] = CRM_Core_Config::domainID(); + } $wordReplacement = new CRM_Core_DAO_WordReplacement(); $wordReplacement->copyValues($params); $wordReplacement->save(); @@ -112,7 +112,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { } return $wordReplacement; } - + /** * Delete website * @@ -139,9 +139,17 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { * @see civicrm_domain.locale_custom_strings */ public static function getAllAsConfigArray($id) { - $query = "SELECT find_word,replace_word,is_active,match_type FROM civicrm_word_replacement WHERE domain_id = ".CRM_Utils_Type::escape($id, 'Integer'); - $dao = CRM_Core_DAO::executeQuery($query); - + $query = " +SELECT find_word,replace_word,is_active,match_type +FROM civicrm_word_replacement +WHERE domain_id = %1 +"; + $params = array( 1 => array($id, 'Integer')); + + $dao = CRM_Core_DAO::executeQuery($query, $params); + + $overrides = array(); + while ($dao->fetch()) { if ($dao->is_active==1) { $overrides['enabled'][$dao->match_type][$dao->find_word] = $dao->replace_word; diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 1197825540..3daf48efc3 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -240,7 +240,8 @@ class CRM_Core_I18n { // do all wildcard translations first $config = CRM_Core_Config::singleton(); - $stringTable = CRM_Utils_Array::value($config->lcMessages, + $stringTable = CRM_Utils_Array::value( + $config->lcMessages, $config->localeCustomStrings ); @@ -255,15 +256,13 @@ class CRM_Core_I18n { } } - if (!$exactMatch && + if ( + !$exactMatch && isset($stringTable['enabled']['wildcardMatch']) ) { $search = array_keys($stringTable['enabled']['wildcardMatch']); $replace = array_values($stringTable['enabled']['wildcardMatch']); - $text = str_replace($search, - $replace, - $text - ); + $text = str_replace($search, $replace, $text); } // dont translate if we've done exactMatch already -- 2.25.1