Page 1 of 1

Greek searches - v.1.3

Posted: Wed 4. Apr 2007, 13:32
by Nik2004
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?

I did it

Posted: Wed 4. Apr 2007, 14:35
by Nik2004
I managed to do it:

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;
}
Then, in /include/inc_front/content/cnt13.article.inc.php:

After

Code: Select all

$content["search_word"][$key] = str_replace("\\*", '.*', $content["search_word"][$key]);
add

Code: Select all

$content["search_word"][$key] = grchars_replace($content["search_word"][$key]);
Finally, after

Code: Select all

$s_text = trim(html_entity_decode($s_text));
add

Code: Select all

$s_text1 = grchars_replace($s_text);
and change next line as follows:

Code: Select all

preg_match_all('/'.implode('|', $content["search_word"]).'/is', $s_text1, $s_result ); //search string

Posted: Thu 12. Apr 2007, 07:07
by Oliver Georgi
very language specific - and might help for Greek only.

Oliver

About greek search hack

Posted: Fri 13. Apr 2007, 11:47
by Nik2004
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.

Posted: Fri 13. Apr 2007, 12:54
by Oliver Georgi
Yes I know. The problem - there is no general "remove all such special chars" function.

Oliver

Posted: Sun 15. Apr 2007, 22:42
by antonis
Hi!

Could anybody direct me in what the respective files-changes would be in order to achieve this in an older installation using version 1.1 rc4?

Thanks a lot!

Posted: Mon 16. Apr 2007, 09:56
by Nik2004
As mentioned in the beginning of the thread, see directions here: http://www.phpwcms.de/forum/viewtopic.php?t=10582