function executeCommandCode(&$text, $command, $charsetName) { if ($command['command'] == 'url_cleanup_iri') { $text = eZCharTransform::commandUrlCleanupIRI($text, $charsetName); return true; } else { if ($command['command'] == 'url_cleanup') { $text = eZCharTransform::commandUrlCleanup($text, $charsetName); return true; } else { if ($command['command'] == 'url_cleanup_compat') { $text = eZCharTransform::commandUrlCleanupCompat($text, $charsetName); return true; } else { if ($command['command'] == 'identifier_cleanup') { $text = strtolower($text); $text = preg_replace(array("#[^a-z0-9_ ]#", "/ /", "/__+/", "/^_|_\$/"), array(" ", "_", "_", ""), $text); return true; } else { if ($command['command'] == 'search_cleanup') { $nonCJKCharsets = $this->nonCJKCharsets(); if (!in_array($charsetName, $nonCJKCharsets)) { // 4 Add spaces after chinese / japanese / korean multibyte characters $codec = eZTextCodec::instance(false, 'unicode'); $unicodeValueArray = $codec->convertString($text); $normalizedTextArray = array(); $bFlag = false; foreach (array_keys($unicodeValueArray) as $valueKey) { // Check for word characters that should be broken up for search if ($unicodeValueArray[$valueKey] >= 12289 and $unicodeValueArray[$valueKey] <= 12542 or $unicodeValueArray[$valueKey] >= 13312 and $unicodeValueArray[$valueKey] <= 40863 or $unicodeValueArray[$valueKey] >= 44032 and $unicodeValueArray[$valueKey] <= 55203) { if ($bFlag) { $normalizedTextArray[] = $unicodeValueArray[$valueKey]; } $normalizedTextArray[] = 32; // A space $normalizedTextArray[] = $unicodeValueArray[$valueKey]; $bFlag = true; } else { if ($bFlag) { $normalizedTextArray[] = 32; // A space } $normalizedTextArray[] = $unicodeValueArray[$valueKey]; $bFlag = false; } } if ($bFlag) { $normalizedTextArray[count($normalizedTextArray) - 1] = 32; } $revCodec = eZTextCodec::instance('unicode', false); // false means use internal charset $text = $revCodec->convertString($normalizedTextArray); } // Make sure dots inside words/numbers are kept, the rest is turned into space $text = preg_replace(array("#(\\.){2,}#", "#^\\.#", "#\\s\\.#", "#\\.\\s#", "#\\.\$#", "#([^0-9])%#"), array(" ", " ", " ", " ", " ", "\$1 "), $text); $ini = eZINI::instance(); if ($ini->variable('SearchSettings', 'EnableWildcard') != 'true') { $text = str_replace("*", " ", $text); } $charset = eZTextCodec::internalCharset(); $hasUTF8 = $charset == "utf-8"; if ($hasUTF8) { $text = preg_replace("#(\\s+)#u", " ", $text); } else { $text = preg_replace("#(\\s+)#", " ", $text); } return true; } else { $ini = eZINI::instance('transform.ini'); $commands = $ini->variable('Extensions', 'Commands'); if (isset($commands[$command['command']])) { list($path, $className) = explode(':', $commands[$command['command']], 2); if (file_exists($path)) { include_once $path; $text = call_user_func_array(array($className, 'executeCommand'), array($text, $command['command'], $charsetName)); return true; } else { eZDebug::writeError("Could not locate include file '{$path}' for transformation '" . $command['command'] . "'"); } } } } } } } return false; }