commandUrlCleanup() static public method

static public commandUrlCleanup ( $text, $charsetName )
Beispiel #1
0
 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;
 }
<?php

// Cached transformation data
// Type: Group:urlalias
// Charset: utf-8
// Cached transformation data
$data = array('table' => array('' => ' ', ' ' => ' ', '״' => '"', '׳' => '\\"', 'ײ' => 'yy', 'ױ' => 'wy', 'װ' => 'ww', 'ת' => 't', 'ש' => 's', 'ר' => 'r', 'ק' => 'q', 'צ' => 'z', 'ץ' => 'z', 'פ' => 'p', 'ף' => 'p', 'ע' => '\\"', 'ס' => 's', 'נ' => 'n', 'ן' => 'n', 'מ' => 'm', 'ם' => 'm', 'ל' => 'l', 'כ' => 'k', 'ך' => 'k', 'י' => 'y', 'ט' => 't', 'ח' => 'h', 'ז' => 'z', 'ו' => 'o', 'ה' => 'h', 'ד' => 'd', 'ג' => 'g', 'ב' => 'b', 'א' => '\\"', '׃' => ':', '׀' => '|', 'ֿ' => '', '־' => '\\"', 'ֽ' => '', 'ּ' => '', 'ֻ' => 'u', 'ֺ' => '', 'ֹ' => 'o', 'ָ' => 'e', 'ַ' => 'a', 'ֶ' => 'e', 'ֵ' => 'e', 'ִ' => 'i', 'ֳ' => 'o', 'ֲ' => 'a', 'ֱ' => 'e', 'ְ' => '', '֯' => '' . "" . '', '֮' => '' . "" . '', '֭' => '' . "" . '', '֬' => '' . "" . '', '֫' => '' . "" . '', '֪' => '' . "" . '', '֩' => '' . "" . '', '֨' => '' . "" . '', '֧' => '' . "" . '', '֦' => '' . "" . '', '֥' => '' . "" . '', '֤' => '' . "" . '', '֣' => '' . "" . '', '֡' => '' . "" . '', '֠' => '' . "" . '', '֟' => '' . "" . '', '֞' => '' . "" . '', '֝' => '' . "" . '', '֜' => '' . "" . '', '֛' => '' . "" . '', '֚' => '' . "" . '', '֙' => '' . "" . '', '֘' => '' . "" . '', '֗' => '' . "" . '', '֖' => '' . "" . '', '֕' => '' . "" . '', '֔' => '' . "" . '', '֓' => '' . "" . '', '֒' => '' . "" . '', '֑' => '' . "" . '', 'ӹ' => 'y', 'Ӹ' => 'Y', 'ӵ' => 'ch', 'Ӵ' => 'CH', 'ӳ' => 'u', 'Ӳ' => 'U', 'ӱ' => 'u', 'Ӱ' => 'U', 'ӯ' => 'u', 'Ӯ' => 'U', 'ӭ' => 'e', 'Ӭ' => 'E', 'ӫ' => 'ө', 'Ӫ' => 'Ө', 'ӧ' => 'o', 'Ӧ' => 'O', 'ӥ' => 'i', 'Ӥ' => 'I', 'ӣ' => 'i', 'Ӣ' => 'I', 'ӟ' => 'z', 'Ӟ' => 'Z', 'ӝ' => 'zh', 'Ӝ' => 'ZH', 'ӛ' => 'ә', 'Ӛ' => 'Ә', 'ӗ' => 'e', 'Ӗ' => 'E', 'ӓ' => 'a', 'Ӓ' => 'A', 'ӑ' => 'a', 'Ӑ' => 'A', 'ӂ' => 'zh', 'Ӂ' => 'ZH', 'ѷ' => 'ѵ', 'Ѷ' => 'Ѵ', 'џ' => 'dz', 'ў' => 'v', 'ѝ' => 'i', 'ќ' => 'kj', 'ћ' => 'c', 'њ' => 'nj', 'љ' => 'lj', 'ј' => 'j', 'ї' => 'yi', 'і' => 'i', 'ѕ' => 'z', 'є' => 'e', 'ѓ' => 'g', 'ђ' => 'dj', 'ё' => 'io', 'ѐ' => 'ie', 'я' => 'ya', 'ю' => 'yu', 'э' => 'e', 'ь' => '\\"', 'ы' => 'y', 'ъ' => '\\"', 'щ' => 'sch', 'ш' => 'sh', 'ч' => 'ch', 'ц' => 'c', 'х' => 'h', 'ф' => 'f', 'у' => 'u', 'т' => 't', 'с' => 's', 'р' => 'r', 'п' => 'p', 'о' => 'o', 'н' => 'n', 'м' => 'm', 'л' => 'l', 'к' => 'k', 'й' => 'j', 'и' => 'i', 'з' => 'z', 'ж' => 'zh', 'е' => 'e', 'д' => 'd', 'г' => 'g', 'в' => 'v', 'б' => 'b', 'а' => 'a', 'Я' => 'YA', 'Ю' => 'YU', 'Э' => 'E', 'Ь' => '\\"', 'Ы' => 'Y', 'Ъ' => '\\"', 'Щ' => 'SCH', 'Ш' => 'SH', 'Ч' => 'CH', 'Ц' => 'C', 'Х' => 'H', 'Ф' => 'F', 'У' => 'U', 'Т' => 'T', 'С' => 'S', 'Р' => 'R', 'П' => 'P', 'О' => 'O', 'Н' => 'N', 'М' => 'M', 'Л' => 'L', 'К' => 'K', 'Й' => 'J', 'И' => 'I', 'З' => 'Z', 'Ж' => 'ZH', 'Е' => 'E', 'Д' => 'D', 'Г' => 'G', 'В' => 'V', 'Б' => 'B', 'А' => 'A', 'Џ' => 'DZ', 'Ў' => 'V', 'Ѝ' => 'I', 'Ќ' => 'KJ', 'Ћ' => 'Ts', 'Њ' => 'NJ', 'Љ' => 'LJ', 'Ј' => 'J', 'Ї' => 'YI', 'І' => 'II', 'Ѕ' => 'DS', 'Є' => 'IE', 'Ѓ' => 'G', 'Ђ' => 'D', 'Ё' => 'IO', 'Ѐ' => 'IE', 'ϻ' => '', 'Ϻ' => '', 'Ϲ' => '', 'ϸ' => '', 'Ϸ' => '', '϶' => 'e', 'ϵ' => 'e', 'ϴ' => '', 'ϳ' => 'j', 'ϲ' => '', 'ϱ' => 'r', 'ϰ' => '', 'ϯ' => '', 'Ϯ' => '', 'ϭ' => '', 'Ϭ' => '', 'ϫ' => '', 'Ϫ' => '', 'ϩ' => '', 'Ϩ' => '', 'ϧ' => '', 'Ϧ' => '', 'ϥ' => '', 'Ϥ' => '', 'ϣ' => '', 'Ϣ' => '', 'ϡ' => '900', 'Ϡ' => 'S', 'ϟ' => '90', 'Ϟ' => 'K', 'ϝ' => 'f', 'Ϝ' => 'F', 'ϛ' => 's', 'Ϛ' => '6', 'ϙ' => 'k', 'Ϙ' => 'K', 'ϗ' => '&', 'ϖ' => 'pi', 'ϕ' => 'phi', 'ϔ' => 'Y', 'ϓ' => 'Y', 'ϒ' => 'Y', 'ϑ' => 'th', 'ϐ' => 'b', 'ώ' => 'ho', 'ύ' => 'hu', 'ό' => 'ho', 'ϋ' => 'y', 'ϊ' => 'i', 'ω' => 'o', 'ψ' => 'ps', 'χ' => 'ch', 'φ' => 'ph', 'υ' => 'y', 'τ' => 't', 'σ' => 's', 'ς' => 's', 'ρ' => 'r', 'π' => 'p', 'ο' => 'o', 'ξ' => 'x', 'ν' => 'n', 'μ' => 'm', 'λ' => 'l', 'κ' => 'k', 'ι' => 'i', 'θ' => 'th', 'η' => 'e', 'ζ' => 'z', 'ε' => 'e', 'δ' => 'd', 'γ' => 'g', 'β' => 'v', 'α' => 'a', 'ΰ' => 'y', 'ί' => 'hi', 'ή' => 'he', 'έ' => 'he', 'ά' => 'ha', 'Ϋ' => 'Y', 'Ϊ' => 'I', 'Ω' => 'O', 'Ψ' => 'Ps', 'Χ' => 'Ch', 'Φ' => 'Ph', 'Υ' => 'Y', 'Τ' => 'T', 'Σ' => 'S', 'Ρ' => 'R', 'Π' => 'P', 'Ο' => 'O', 'Ξ' => 'X', 'Ν' => 'N', 'Μ' => 'M', 'Λ' => 'L', 'Κ' => 'K', 'Ι' => 'I', 'Θ' => 'Th', 'Η' => 'E', 'Ζ' => 'Z', 'Ε' => 'E', 'Δ' => 'D', 'Γ' => 'G', 'Β' => 'V', 'Α' => 'A', 'ΐ' => 'I', 'Ώ' => 'Ho', 'Ύ' => 'Hu', 'Ό' => 'Ho', 'Ί' => 'Hi', 'Ή' => 'He', 'Έ' => 'He', '·' => '·', 'Ά' => 'Ha', '΅' => '¨', '΄' => ' ', ';' => '?', 'ͺ' => ' ', '͵' => '\\"', 'ʹ' => '\\"', '˝' => '"', 'ˏ' => '"', 'ˎ' => '"', 'ˋ' => '"', 'ˊ' => '"', 'ſ' => 's', 'ž' => 'z', 'Ž' => 'Z', 'ż' => 'z', 'Ż' => 'Z', 'ź' => 'z', 'Ź' => 'Z', 'Ÿ' => 'Y', 'ŷ' => 'y', 'Ŷ' => 'Y', 'ŵ' => 'w', 'Ŵ' => 'W', 'ų' => 'u', 'Ų' => 'U', 'ű' => 'u', 'Ű' => 'U', 'ů' => 'u', 'Ů' => 'U', 'ŭ' => 'u', 'Ŭ' => 'U', 'ū' => 'u', 'Ū' => 'U', 'ũ' => 'u', 'Ũ' => 'U', 'ŧ' => 't', 'Ŧ' => 'T', 'ť' => 't', 'Ť' => 'T', 'ţ' => 't', 'Ţ' => 'T', 'š' => 's', 'Š' => 'S', 'ş' => 's', 'Ş' => 'S', 'ŝ' => 's', 'Ŝ' => 'S', 'ś' => 's', 'Ś' => 'S', 'ř' => 'r', 'Ř' => 'R', 'ŗ' => 'r', 'Ŗ' => 'R', 'ŕ' => 'r', 'Ŕ' => 'R', 'œ' => 'oe', 'Œ' => 'OE', 'ő' => 'o', 'Ő' => 'O', 'ŏ' => 'o', 'Ŏ' => 'O', 'ō' => 'o', 'Ō' => 'O', 'ŋ' => 'n', 'Ŋ' => 'N', 'ʼn' => '"n', 'ň' => 'n', 'Ň' => 'N', 'ņ' => 'n', 'Ņ' => 'N', 'ń' => 'n', 'Ń' => 'N', 'ł' => 'l', 'Ł' => 'L', 'ŀ' => 'l', 'Ŀ' => 'L', 'ľ' => 'l', 'Ľ' => 'L', 'ļ' => 'l', 'Ļ' => 'L', 'ĺ' => 'l', 'Ĺ' => 'L', 'ĸ' => 'k', 'ķ' => 'k', 'Ķ' => 'K', 'ĵ' => 'j', 'Ĵ' => 'J', 'ij' => 'ij', 'IJ' => 'IJ', 'ı' => 'i', 'İ' => 'I', 'į' => 'i', 'Į' => 'I', 'ĭ' => 'i', 'Ĭ' => 'I', 'ī' => 'i', 'Ī' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I', 'ħ' => 'h', 'Ħ' => 'H', 'ĥ' => 'h', 'Ĥ' => 'H', 'ģ' => 'g', 'Ģ' => 'G', 'ġ' => 'g', 'Ġ' => 'G', 'ğ' => 'g', 'Ğ' => 'G', 'ĝ' => 'g', 'Ĝ' => 'G', 'ě' => 'e', 'Ě' => 'E', 'ę' => 'e', 'Ę' => 'E', 'ė' => 'e', 'Ė' => 'E', 'ĕ' => 'e', 'Ĕ' => 'E', 'ē' => 'e', 'Ē' => 'E', 'đ' => 'd', 'Đ' => 'D', 'ď' => 'd', 'Ď' => 'D', 'č' => 'c', 'Č' => 'C', 'ċ' => 'c', 'Ċ' => 'C', 'ĉ' => 'c', 'Ĉ' => 'C', 'ć' => 'c', 'Ć' => 'C', 'ą' => 'a', 'Ą' => 'A', 'ă' => 'a', 'Ă' => 'A', 'ā' => 'a', 'Ā' => 'A', 'ÿ' => 'y', 'þ' => 'th', 'ý' => 'y', 'ü' => 'ue', 'û' => 'u', 'ú' => 'u', 'ù' => 'u', 'ø' => 'oe', '÷' => '/', 'ö' => 'oe', 'õ' => 'o', 'ô' => 'o', 'ó' => 'o', 'ò' => 'o', 'ñ' => 'n', 'ð' => 'd', 'ï' => 'i', 'î' => 'i', 'í' => 'i', 'ì' => 'i', 'ë' => 'e', 'ê' => 'e', 'é' => 'e', 'è' => 'e', 'ç' => 'c', 'æ' => 'ae', 'å' => 'aa', 'ä' => 'ae', 'ã' => 'a', 'â' => 'a', 'á' => 'a', 'à' => 'a', 'ß' => 'ss', 'Þ' => 'TH', 'Ý' => 'Y', 'Ü' => 'Ue', 'Û' => 'U', 'Ú' => 'U', 'Ù' => 'U', 'Ø' => 'OE', '×' => '*', 'Ö' => 'Oe', 'Õ' => 'O', 'Ô' => 'O', 'Ó' => 'O', 'Ò' => 'O', 'Ñ' => 'N', 'Ð' => 'D', 'Ï' => 'I', 'Î' => 'I', 'Í' => 'I', 'Ì' => 'I', 'Ë' => 'E', 'Ê' => 'E', 'É' => 'E', 'È' => 'E', 'Ç' => 'C', 'Æ' => 'AE', 'Å' => 'AA', 'Ä' => 'Ae', 'Ã' => 'A', 'Â' => 'A', 'Á' => 'A', 'À' => 'A', '¿' => '?', '¾' => '3/4', '½' => '1/2', '¼' => '1/4', '»' => '"', 'º' => '1', '¹' => '1', '´' => '"', '³' => '3', '²' => '2', '±' => '+-', '®' => '(R)', '­' => '', '«' => '"', 'ª' => 'a', '©' => '(C)', '¡' => '!', ' ' => ' ', 'Ÿ' => 'Y', 'œ' => 'oe', 'Œ' => 'OE', '~' => '-', '`' => '"', '\'' => '"'));
$text = strtr($text, $data['table']);
$text = eZCharTransform::commandUrlCleanup($text, 'utf-8');