Nucleus CMS日本語版SVNをgit-svnしたもの。リポジトリの変換作業用
Revisão | 08c339012fc4a8dabd142f9683e08881091766c0 (tree) |
---|---|
Hora | 2008-02-07 15:26:07 |
Autor | kimitake <kimitake@1ca2...> |
Commiter | kimitake |
use "BINARY" for jp search
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/branches/branch-3-3@370 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -20,8 +20,8 @@ | ||
20 | 20 | * |
21 | 21 | * @license http://nucleuscms.org/license.txt GNU General Public License |
22 | 22 | * @copyright Copyright (C) 2002-2007 The Nucleus Group |
23 | - * @version $Id: SEARCH.php,v 1.6 2007-03-27 12:13:56 kimitake Exp $ | |
24 | - * @version $NucleusJP: SEARCH.php,v 1.8 2007/02/04 06:28:46 kimitake Exp $ | |
23 | + * @version $Id: SEARCH.php,v 1.6.2.1 2008-02-07 06:25:50 kimitake Exp $ | |
24 | + * @version $NucleusJP: SEARCH.php,v 1.6 2007/03/27 12:13:56 kimitake Exp $ | |
25 | 25 | */ |
26 | 26 | |
27 | 27 |
@@ -200,30 +200,36 @@ class SEARCH { | ||
200 | 200 | return $result; |
201 | 201 | } |
202 | 202 | |
203 | + function create_temp_a($match, $key, $substrflag){ | |
204 | + $key = $substrflag ? substr($key, 1) : $key; | |
205 | + return "(i.$match LIKE " . (preg_match('/[a-zA-Z]/', $key) ? '' : 'BINARY ') . "'%" . | |
206 | + addslashes($key) . "%') "; | |
207 | + } | |
203 | 208 | |
204 | 209 | function boolean_sql_where_jp_short($string,$match){ |
205 | 210 | $match_a = explode(',',$match); |
206 | - $key_a = explode(' ',$string); | |
211 | + $key_a = explode(' ',$string); | |
207 | 212 | |
208 | 213 | for($ith=0;$ith<count($match_a);$ith++){ |
209 | - $temp_a[$ith] = "(i.$match_a[$ith] LIKE '%" . addslashes($key_a[0]) . "%') "; | |
214 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[0], 0); | |
215 | + | |
210 | 216 | } |
211 | 217 | $like = '('.implode(' or ',$temp_a).')'; |
212 | 218 | |
213 | - for($kn=1; $kn<count($key_a); $kn++){ | |
214 | - if(substr($key_a[$kn],0,1) == ","){ | |
219 | + for($kn=1; $kn<count($key_a); $kn++){ | |
220 | + if(substr($key_a[$kn],0,1) == ","){ | |
215 | 221 | for($ith=0;$ith<count($match_a);$ith++){ |
216 | - $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') "; | |
222 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1); | |
217 | 223 | } |
218 | 224 | $like .=' OR ('. implode(' or ',$temp_a).')'; |
219 | 225 | }elseif(substr($key_a[$kn],0,1) != '-'){ |
220 | 226 | for($ith=0;$ith<count($match_a);$ith++){ |
221 | - $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes($key_a[$kn]) . "%') "; | |
227 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 0); | |
222 | 228 | } |
223 | 229 | $like .=' AND ('. implode(' or ',$temp_a).')'; |
224 | 230 | }else{ |
225 | 231 | for($ith=0;$ith<count($match_a);$ith++){ |
226 | - $temp_a[$ith] = " NOT(i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') "; | |
232 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1); | |
227 | 233 | } |
228 | 234 | $like .=' AND ('. implode(' and ',$temp_a).')'; |
229 | 235 | } |
@@ -20,8 +20,8 @@ | ||
20 | 20 | * |
21 | 21 | * @license http://nucleuscms.org/license.txt GNU General Public License |
22 | 22 | * @copyright Copyright (C) 2002-2007 The Nucleus Group |
23 | - * @version $Id: SEARCH.php,v 1.8 2007-02-04 06:28:46 kimitake Exp $ | |
24 | - * @version $NucleusJP: SEARCH.php,v 1.7 2006/07/20 08:01:52 kimitake Exp $ | |
23 | + * @version $Id: SEARCH.php,v 1.8.2.1 2008-02-07 06:26:07 kimitake Exp $ | |
24 | + * @version $NucleusJP: SEARCH.php,v 1.8 2007/02/04 06:28:46 kimitake Exp $ | |
25 | 25 | */ |
26 | 26 | |
27 | 27 |
@@ -237,30 +237,36 @@ class SEARCH { | ||
237 | 237 | return $result; |
238 | 238 | } |
239 | 239 | |
240 | + function create_temp_a($match, $key, $substrflag){ | |
241 | + $key = $substrflag ? substr($key, 1) : $key; | |
242 | + return "(i.$match LIKE " . (preg_match('/[a-zA-Z]/', $key) ? '' : 'BINARY ') . "'%" . | |
243 | + addslashes($key) . "%') "; | |
244 | + } | |
240 | 245 | |
241 | 246 | function boolean_sql_where_jp_short($string,$match){ |
242 | 247 | $match_a = explode(',',$match); |
243 | - $key_a = explode(' ',$string); | |
248 | + $key_a = explode(' ',$string); | |
244 | 249 | |
245 | 250 | for($ith=0;$ith<count($match_a);$ith++){ |
246 | - $temp_a[$ith] = "(i.$match_a[$ith] LIKE '%" . addslashes($key_a[0]) . "%') "; | |
251 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[0], 0); | |
252 | + | |
247 | 253 | } |
248 | 254 | $like = '('.implode(' or ',$temp_a).')'; |
249 | 255 | |
250 | - for($kn=1; $kn<count($key_a); $kn++){ | |
251 | - if(substr($key_a[$kn],0,1) == ","){ | |
256 | + for($kn=1; $kn<count($key_a); $kn++){ | |
257 | + if(substr($key_a[$kn],0,1) == ","){ | |
252 | 258 | for($ith=0;$ith<count($match_a);$ith++){ |
253 | - $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') "; | |
259 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1); | |
254 | 260 | } |
255 | 261 | $like .=' OR ('. implode(' or ',$temp_a).')'; |
256 | 262 | }elseif(substr($key_a[$kn],0,1) != '-'){ |
257 | 263 | for($ith=0;$ith<count($match_a);$ith++){ |
258 | - $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes($key_a[$kn]) . "%') "; | |
264 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 0); | |
259 | 265 | } |
260 | 266 | $like .=' AND ('. implode(' or ',$temp_a).')'; |
261 | 267 | }else{ |
262 | 268 | for($ith=0;$ith<count($match_a);$ith++){ |
263 | - $temp_a[$ith] = " NOT(i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') "; | |
269 | + $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1); | |
264 | 270 | } |
265 | 271 | $like .=' AND ('. implode(' and ',$temp_a).')'; |
266 | 272 | } |