X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FWordReplacement.php;h=3becc858d1de8c99e8e7bf9a3250028606d5c9a8;hb=b824d5c0a288d8c466a85715cdb8eac5e8b669ec;hp=8dd64935a99d06d193313fa1497d21adf38c130e;hpb=51900a630990035f8b775411368a25760b68af0b;p=civicrm-core.git diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index 8dd64935a9..3becc858d1 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); } @@ -67,7 +67,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { static function getWordReplacement($reset = NULL) { static $wordReplacement = NULL; if (!$wordReplacement || $reset) { - $wordReplacement = new CRM_Core_BAO_WordRepalcement(); + $wordReplacement = new CRM_Core_BAO_WordReplacement(); $wordReplacement->id = CRM_Core_Config::wordReplacementID(); if (!$wordReplacement->find(TRUE)) { CRM_Core_Error::fatal(); @@ -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,14 +139,23 @@ 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; - } else { - $overrides['disabled'][$dao->match_type][$dao->find_word] = $dao->replace_word; + $overrides['enabled'][$dao->match_type][$dao->find_word] = $dao->replace_word; + } + else { + $overrides['disabled'][$dao->match_type][$dao->find_word] = $dao->replace_word; } } $config = CRM_Core_Config::singleton(); @@ -220,19 +229,19 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { $wordMatchArray = array(); // Traverse Language array foreach ($localeCustomArray as $localCustomData) { - // Traverse status array "enabled" "disabled" - foreach ($localCustomData as $status => $matchTypes) { - $params["is_active"] = ($status == "enabled")?TRUE:FALSE; - // Traverse Match Type array "wildcardMatch" "exactMatch" - foreach ($matchTypes as $matchType => $words) { - $params["match_type"] = $matchType; - foreach ($words as $word => $replace) { - $params["find_word"] = $word; - $params["replace_word"] = $replace; - $wordReplacementCreateParams[] = $params; - } - } - } + // Traverse status array "enabled" "disabled" + foreach ($localCustomData as $status => $matchTypes) { + $params["is_active"] = ($status == "enabled")?TRUE:FALSE; + // Traverse Match Type array "wildcardMatch" "exactMatch" + foreach ($matchTypes as $matchType => $words) { + $params["match_type"] = $matchType; + foreach ($words as $word => $replace) { + $params["find_word"] = $word; + $params["replace_word"] = $replace; + $wordReplacementCreateParams[] = $params; + } + } + } } } }