Revision 1442
Added by Luisehahne over 14 years ago
| search_convert.php | ||
|---|---|---|
| 15 | 15 |
* @lastmodified $Date$ |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 |
/* |
|
| 19 |
ATTN: to include your local changes DO NOT alter this file! |
|
| 20 |
Instead, create your own local file search_convert_local.php |
|
| 21 |
which will stay intact even after upgrading Website Baker. |
|
| 18 | 22 |
|
| 19 |
// Must include code to stop this file being access directly |
|
| 20 |
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
|
| 21 |
|
|
| 23 |
--Example search_convert_local.php -------------------------- |
|
| 24 |
// allows the user to enter Krasic to find Krašić |
|
| 25 |
$t["s"] = array("š","s");
|
|
| 26 |
$t["S"] = array("Š","S");
|
|
| 27 |
$t["c"] = array("ć","c");
|
|
| 28 |
$t["C"] = array("Ć","C");
|
|
| 29 |
... |
|
| 30 |
--END ------------------------------------------------------- |
|
| 31 |
*/ |
|
| 32 |
if(!defined('WB_URL')) {
|
|
| 33 |
header('Location: ../index.php');
|
|
| 34 |
exit(0); |
|
| 35 |
} |
|
| 22 | 36 |
if(!isset($search_lang)) $search_lang = LANGUAGE; |
| 37 |
$t = array(); |
|
| 23 | 38 |
|
| 24 |
// umlaut to '(upper|lower)' for preg_match() |
|
| 25 |
// this is UTF-8-encoded |
|
| 26 |
// there is no need for a translation-table anymore since we use u-switch (utf-8) for preg-functions |
|
| 27 |
// remember that we use the i-switch, too. [No need for (ae|Ae)] |
|
| 39 |
/* |
|
| 40 |
ATTN: |
|
| 41 |
This file MUST be UTF-8-encoded |
|
| 42 |
*/ |
|
| 43 |
// test encoding |
|
| 44 |
if('á'!="\xc3\xa1") {
|
|
| 45 |
trigger_error('Wrong encoding for file search_convert.php!', E_USER_NOTICE);
|
|
| 46 |
return; |
|
| 47 |
} |
|
| 28 | 48 |
|
| 29 |
$string_ul_umlaut = array(); |
|
| 30 |
$string_ul_regex = array(); |
|
| 31 |
|
|
| 32 |
// but add some national stuff |
|
| 49 |
// local german settings |
|
| 33 | 50 |
if($search_lang=='DE') { // add special handling for german umlauts (ä==ae, ...)
|
| 34 |
$string_ul_umlaut_add = array( |
|
| 35 |
"\xc3\x9f", // german SZ-Ligatur |
|
| 36 |
"\xc3\xa4", // german ae |
|
| 37 |
"\xc3\xb6", // german oe |
|
| 38 |
"\xc3\xbc", // german ue |
|
| 39 |
"\xc3\x84", // german Ae |
|
| 40 |
"\xc3\x96", // german Oe |
|
| 41 |
"\xc3\x9c", // german Ue |
|
| 42 |
// these are not that usual |
|
| 43 |
"\xEF\xAC\x84", // german ffl-ligatur |
|
| 44 |
"ffl", // german ffl-ligatur |
|
| 45 |
"\xEF\xAC\x83", // german ffi-ligatur |
|
| 46 |
"ffi", // german ffi-ligatur |
|
| 47 |
"0xEF\xAC\x80", // german ff-Ligatur |
|
| 48 |
"ff", // german ff-Ligatur |
|
| 49 |
"\xEF\xAC\x81", // german fi-ligatur |
|
| 50 |
"fi", // german fi-ligatur |
|
| 51 |
"\xEF\xAC\x82", // german fl-ligatur |
|
| 52 |
"fl", // german fl-ligatur |
|
| 53 |
"\xEF\xAC\x85", // german st-Ligatur (long s) |
|
| 54 |
"st", // german st-Ligatur |
|
| 55 |
"\xEF\xAC\x86" // german st-ligatur (round-s) |
|
| 56 |
); |
|
| 57 |
$string_ul_regex_add = array( |
|
| 58 |
"(\xc3\x9f|ss)", // german SZ.Ligatur |
|
| 59 |
"(\xc3\xa4|ae)", // german ae |
|
| 60 |
"(\xc3\xb6|oe)", // german oe |
|
| 61 |
"(\xc3\xbc|ue)", // german ue |
|
| 62 |
"(\xc3\x84|Ae)", // german Ae |
|
| 63 |
"(\xc3\x96|Oe)", // german Oe |
|
| 64 |
"(\xc3\x9c|Ue)", // german Ue |
|
| 65 |
// these are not that usual |
|
| 66 |
"(\xEF\xAC\x84|ffl)", // german ffl-ligatur |
|
| 67 |
"(\xEF\xAC\x84|ffl)", // german ffl-ligatur |
|
| 68 |
"(\xEF\xAC\x83|ffi)", // german ffi-ligatur |
|
| 69 |
"(\xEF\xAC\x83|ffi)", // german ffi-ligatur |
|
| 70 |
"(\xEF\xAC\x80|ff)", // german ff-Ligatur |
|
| 71 |
"(\xEF\xAC\x80|ff)", // german ff-Ligatur |
|
| 72 |
"(\xEF\xAC\x81|fi)", // german fi-Ligatur |
|
| 73 |
"(\xEF\xAC\x81|fi)", // german fi-Ligatur |
|
| 74 |
"(\xEF\xAC\x82|fl)", // german fl-ligatur |
|
| 75 |
"(\xEF\xAC\x82|fl)", // german fl-ligatur |
|
| 76 |
"(\xEF\xAC\x85|st)", // german st-Ligatur (long s) |
|
| 77 |
"(\xEF\xAC\x85|st|\xEF\xAC\x86)", // german st-Ligaturs |
|
| 78 |
"(\xEF\xAC\x86|st)" // german st-ligatur (round-s) |
|
| 79 |
); |
|
| 80 |
$string_ul_umlaut = array_merge($string_ul_umlaut_add, $string_ul_umlaut); |
|
| 81 |
$string_ul_regex = array_merge($string_ul_regex_add, $string_ul_regex); |
|
| 51 |
// in german the character 'ß' may be written as 'ss', too. So for each 'ß' look for ('ß' OR 'ss')
|
|
| 52 |
$t["ß"] = array("ß" ,"ss"); // german SZ-Ligatur
|
|
| 53 |
$t["ä"] = array("ä" ,"ae"); // german ae
|
|
| 54 |
$t["ö"] = array("ö" ,"oe"); // german oe
|
|
| 55 |
$t["ü"] = array("ü" ,"ue"); // german ue
|
|
| 56 |
// the search itself is case-insensitiv, but strtr() (which is used to convert the search-string) isn't, |
|
| 57 |
// so we have to supply upper-case characters, too! |
|
| 58 |
$t["Ä"] = array("Ä" ,"Ae"); // german Ae
|
|
| 59 |
$t["Ö"] = array("Ö" ,"Oe"); // german Oe
|
|
| 60 |
$t["Ü"] = array("Ü" ,"Ue"); // german Ue
|
|
| 61 |
// and for each 'ss' look for ('ß' OR 'ss'), too
|
|
| 62 |
$t["ss"] = array("ß" ,"ss"); // german SZ-Ligatur
|
|
| 63 |
$t["ae"] = array("ä" ,"ae"); // german ae
|
|
| 64 |
$t["oe"] = array("ö" ,"oe"); // german oe
|
|
| 65 |
$t["ue"] = array("ü" ,"ue"); // german ue
|
|
| 66 |
$t["Ae"] = array("Ä" ,"Ae"); // german Ae
|
|
| 67 |
$t["Oe"] = array("Ö" ,"Oe"); // german Oe
|
|
| 68 |
$t["Ue"] = array("Ü" ,"Ue"); // german Ue
|
|
| 82 | 69 |
} |
| 83 | 70 |
|
| 71 |
// local Turkish settings |
|
| 72 |
if($search_lang=='TR') { // add special i/I-handling for Turkish
|
|
| 73 |
$t["i"] = array("i", "İ");
|
|
| 74 |
$t["I"] = array("I", "ı");
|
|
| 75 |
} |
|
| 84 | 76 |
|
| 85 |
?> |
|
| 77 |
// include user-supplied file |
|
| 78 |
if(file_exists(WB_PATH.'/search/search_convert_local.php')) |
|
| 79 |
include(WB_PATH.'/search/search_convert_local.php'); |
|
| 80 |
|
|
| 81 |
// create arrays |
|
| 82 |
global $search_table_umlauts_local; |
|
| 83 |
$search_table_umlauts_local = array(); |
|
| 84 |
foreach($t as $o=>$a) {
|
|
| 85 |
$alt = ''; |
|
| 86 |
if(empty($o) || empty($a) || !is_array($a)) continue; |
|
| 87 |
foreach($a as $c) {
|
|
| 88 |
if(empty($c)) continue; |
|
| 89 |
$alt .= preg_quote($c,'/').'|'; |
|
| 90 |
} |
|
| 91 |
$alt = rtrim($alt, '|'); |
|
| 92 |
$search_table_umlauts_local[$o] = "($alt)"; |
|
| 93 |
} |
|
| 94 |
// create array for use with frontent.functions.php (highlighting) |
|
| 95 |
$string_ul_umlaut = array_keys($search_table_umlauts_local); |
|
| 96 |
$string_ul_regex = array_values($search_table_umlauts_local); |
|
| 97 |
|
|
| 98 |
|
|
| 99 |
global $search_table_sql_local; |
|
| 100 |
$search_table_sql_local = array(); |
|
| 101 |
foreach($t as $o=>$a) {
|
|
| 102 |
if(empty($o) || empty($a) || !is_array($a)) continue; |
|
| 103 |
$i = 0; |
|
| 104 |
foreach($a as $c) {
|
|
| 105 |
if(empty($c)) continue; |
|
| 106 |
if($o==$c) { $i++; continue; }
|
|
| 107 |
$search_table_sql_local[$i++][$o] = $c; |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
Also available in: Unified diff
bug fixed in class.database.php methode field_add in call field_exists
update search, pls test, (Tks to Thorn)