*/
static function wordReplacements(CRM_Queue_TaskContext $ctx) {
$query = "
-CREATE TABLE IF NOT EXISTS civicrm_word_replacement (
- id int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Word replacement ID',
- find_word varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Word which need to be replaced',
- replace_word varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Word which will replace the word in find',
- is_active tinyint(4) DEFAULT NULL COMMENT 'Is this entry active?',
- domain_id int(10) unsigned DEFAULT NULL COMMENT 'FK to Domain ID. This is for Domain specific word replacement',
- PRIMARY KEY (id),
- UNIQUE KEY UI_find (find_word),
- KEY FK_civicrm_word_replacement_domain_id (domain_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4";
+CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Word replacement ID',
+ `find_word` varchar(255) COMMENT 'Word which need to be replaced',
+ `replace_word` varchar(255) COMMENT 'Word which will replace the word in find',
+ `is_active` tinyint COMMENT 'Is this entry active?',
+ `match_type` enum('wildcardMatch', 'exactMatch') DEFAULT 'wildcardMatch',
+ `domain_id` int unsigned COMMENT 'FK to Domain ID. This is for Domain specific word replacement',
+ PRIMARY KEY ( `id` ),
+ UNIQUE INDEX `UI_find`(find_word),
+ CONSTRAINT FK_civicrm_word_replacement_domain_id FOREIGN KEY (`domain_id`) REFERENCES `civicrm_domain`(`id`)
+) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ ";
$dao = CRM_Core_DAO::executeQuery($query);
self::rebuildWordReplacementTable();
if (!empty($result["values"])) {
foreach ($result["values"] as $value) {
$params = array();
- $params["is_active"] = TRUE;
$params["domain_id"] = $value["id"];
$params["options"] = array('wp-rebuild' => $rebuildEach);
// unserialize word match string
$localeCustomArray = unserialize($value["locale_custom_strings"]);
if (!empty($localeCustomArray)) {
$wordMatchArray = array();
+ // Traverse Language array
foreach ($localeCustomArray as $localCustomData) {
- $wordMatchArray = $localCustomData["enabled"]["wildcardMatch"];
- }
-
- if (!empty($wordMatchArray)) {
- foreach ($wordMatchArray 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;
+ }
+ }
}
}
}