[geeklog-cvs] geeklog: Better handling of non English characters in search eng...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon May 25 18:39:34 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/946febf77b59
changeset: 7059:946febf77b59
user:      Sami Barakat
date:      Mon May 25 23:37:23 2009 +0100
description:
Better handling of non English characters in search engine (part of bug #0000874)

diffstat:

 system/classes/search.class.php |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r e81b9150b7c3 -r 946febf77b59 system/classes/search.class.php
--- a/system/classes/search.class.php	Mon May 25 22:45:16 2009 +0100
+++ b/system/classes/search.class.php	Mon May 25 23:37:23 2009 +0100
@@ -663,18 +663,21 @@
         if ($this->_keyType == 'any')
         {
             $searchQuery = str_replace(' ', "</b>' " . $LANG09[57] . " '<b>", $escquery);
-            $searchQuery = "<b>'$searchQuery'</b>";
+            $searchQuery = "'<b>$searchQuery</b>'";
         }
         else if ($this->_keyType == 'all')
         {
             $searchQuery = str_replace(' ', "</b>' " . $LANG09[56] . " '<b>", $escquery);
-            $searchQuery = "<b>'$searchQuery'</b>";
+            $searchQuery = "'<b>$searchQuery</b>'";
         }
         else
         {
             $searchQuery = $LANG09[55] . " '<b>$escquery</b>'";
         }
 
+        // Clean the query string so that sprintf works as expected
+        $searchQuery = str_replace("%", "%%", $searchQuery);
+
         $retval = "{$LANG09[25]} $searchQuery. ";
         if (count($results) == 0)
         {
@@ -685,7 +688,8 @@
         }
         else
         {
-            $retval .= $LANG09[64] . " ($searchtime {$LANG09[27]}). " . COM_createLink($LANG09[61], $url.'refine');
+            $retval .= $LANG09[64] . " ($searchtime {$LANG09[27]}). ";
+            $retval .= str_replace("%", "%%", COM_createLink($LANG09[61], $url.'refine'));
             $retval = '<p>' . $retval . '</p>' . LB;
             $retval = $obj->getFormattedOutput($results, $LANG09[11], $retval, '', $_CONF['search_show_sort'], $_CONF['search_show_limit']);
         }



More information about the geeklog-cvs mailing list