Greek searches - v.1.3
Greek searches - v.1.3
Following this thread http://www.phpwcms.de/forum/viewtopic.php?t=13646 I tested search (using ISO-8859-7 and greek in MySQL) and I found that it does not work right.
Searches should be case- and accent- INSENSITIVE, as per my message: http://www.phpwcms.de/forum/viewtopic.p ... ight=greek.
Currently, in v1.3 if I search for the word "ΓΙΑΝΝΟΥΤΣΟΥ" using any keyword like "Γιαννούτσου" or "ΓΙΑΝΝΟΎΤΣΟΥ" or "ΓιαννΟΥΤΣΟΥ" the article will not be found. One has to use capitals ONLY (whole word or part) to find it.
Any suggestions?
Searches should be case- and accent- INSENSITIVE, as per my message: http://www.phpwcms.de/forum/viewtopic.p ... ight=greek.
Currently, in v1.3 if I search for the word "ΓΙΑΝΝΟΥΤΣΟΥ" using any keyword like "Γιαννούτσου" or "ΓΙΑΝΝΟΎΤΣΟΥ" or "ΓιαννΟΥΤΣΟΥ" the article will not be found. One has to use capitals ONLY (whole word or part) to find it.
Any suggestions?
I did it
I managed to do it:
Add function in /include/inc_front/content/cnt_functions/cnt13.func.inc.php:
Then, in /include/inc_front/content/cnt13.article.inc.php:
After
add
Finally, after
add
and change next line as follows:
Add function in /include/inc_front/content/cnt_functions/cnt13.func.inc.php:
Code: Select all
function grchars_replace($text) {
// convert all greek chars to lower case, non-accented ones for search ****
$text = str_replace(chr(220), chr(225), $text);
$text = str_replace(chr(193), chr(225), $text);
$text = str_replace(chr(182), chr(225), $text);
$text = str_replace(chr(194), chr(226), $text);
$text = str_replace(chr(195), chr(227), $text);
$text = str_replace(chr(196), chr(228), $text);
$text = str_replace(chr(197), chr(229), $text);
$text = str_replace(chr(184), chr(229), $text);
$text = str_replace(chr(221), chr(229), $text);
$text = str_replace(chr(198), chr(230), $text);
$text = str_replace(chr(199), chr(231), $text);
$text = str_replace(chr(185), chr(231), $text);
$text = str_replace(chr(222), chr(231), $text);
$text = str_replace(chr(200), chr(232), $text);
$text = str_replace(chr(201), chr(233), $text);
$text = str_replace(chr(186), chr(233), $text);
$text = str_replace(chr(218), chr(233), $text);
$text = str_replace(chr(223), chr(233), $text);
$text = str_replace(chr(250), chr(233), $text);
$text = str_replace(chr(192), chr(233), $text);
$text = str_replace(chr(202), chr(234), $text);
$text = str_replace(chr(203), chr(235), $text);
$text = str_replace(chr(204), chr(236), $text);
$text = str_replace(chr(205), chr(237), $text);
$text = str_replace(chr(206), chr(238), $text);
$text = str_replace(chr(207), chr(239), $text);
$text = str_replace(chr(188), chr(239), $text);
$text = str_replace(chr(252), chr(239), $text);
$text = str_replace(chr(208), chr(240), $text);
$text = str_replace(chr(209), chr(241), $text);
$text = str_replace(chr(211), chr(243), $text);
$text = str_replace(chr(242), chr(243), $text);
$text = str_replace(chr(212), chr(244), $text);
$text = str_replace(chr(213), chr(245), $text);
$text = str_replace(chr(219), chr(245), $text);
$text = str_replace(chr(190), chr(245), $text);
$text = str_replace(chr(253), chr(245), $text);
$text = str_replace(chr(251), chr(245), $text);
$text = str_replace(chr(224), chr(245), $text);
$text = str_replace(chr(214), chr(246), $text);
$text = str_replace(chr(215), chr(247), $text);
$text = str_replace(chr(216), chr(248), $text);
$text = str_replace(chr(217), chr(249), $text);
$text = str_replace(chr(191), chr(249), $text);
$text = str_replace(chr(254), chr(249), $text);
return $text;
}
After
Code: Select all
$content["search_word"][$key] = str_replace("\\*", '.*', $content["search_word"][$key]);
Code: Select all
$content["search_word"][$key] = grchars_replace($content["search_word"][$key]);
Code: Select all
$s_text = trim(html_entity_decode($s_text));
Code: Select all
$s_text1 = grchars_replace($s_text);
Code: Select all
preg_match_all('/'.implode('|', $content["search_word"]).'/is', $s_text1, $s_result ); //search string
- Oliver Georgi
- Site Admin
- Posts: 9906
- Joined: Fri 3. Oct 2003, 22:22
- Contact:
About greek search hack
You are right Oliver, but it was my only way out. If I could, I would do it in a more robust way, but I'm not a professional coder... I have to do it the easy way. You may want to do in a way so as searh works right when greek encoding is selected.
I posted my solution in case it might help some other greek users.
I posted my solution in case it might help some other greek users.
- Oliver Georgi
- Site Admin
- Posts: 9906
- Joined: Fri 3. Oct 2003, 22:22
- Contact:
As mentioned in the beginning of the thread, see directions here: http://www.phpwcms.de/forum/viewtopic.php?t=10582