Project

General

Profile

1 1420 Luisehahne
<?php
2
/**
3
 *
4
 * @category        frontend
5
 * @package         search
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18 1442 Luisehahne
/*
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.
22 1420 Luisehahne
23 1442 Luisehahne
	--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
}
36 1420 Luisehahne
if(!isset($search_lang)) $search_lang = LANGUAGE;
37 1442 Luisehahne
$t = array();
38 1420 Luisehahne
39 1442 Luisehahne
/*
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
}
48 1420 Luisehahne
49 1442 Luisehahne
// local german settings
50 1420 Luisehahne
if($search_lang=='DE') { // add special handling for german umlauts (ä==ae, ...)
51 1442 Luisehahne
	// 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
69 1420 Luisehahne
}
70
71 1442 Luisehahne
// 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
}
76 1420 Luisehahne
77 1442 Luisehahne
// 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
}