Greek searches - v.1.3

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
Nik2004
Posts: 132
Joined: Mon 9. Aug 2004, 14:31
Location: Athens,Greece

Greek searches - v.1.3

Post 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?
Nik2004
Posts: 132
Joined: Mon 9. Aug 2004, 14:31
Location: Athens,Greece

I did it

Post 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
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

very language specific - and might help for Greek only.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Nik2004
Posts: 132
Joined: Mon 9. Aug 2004, 14:31
Location: Athens,Greece

About greek search hack

Post 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.
User avatar
Oliver Georgi
Site Admin
Posts: 9907
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Yes I know. The problem - there is no general "remove all such special chars" function.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
antonis
Posts: 35
Joined: Mon 7. Jun 2004, 14:55

Post 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!
Nik2004
Posts: 132
Joined: Mon 9. Aug 2004, 14:31
Location: Athens,Greece

Post by Nik2004 »

As mentioned in the beginning of the thread, see directions here: http://www.phpwcms.de/forum/viewtopic.php?t=10582
Post Reply