diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -794,14 +794,16 @@ class linkdb implements Iterator, Countable, ArrayAccess | |||
794 | { | 794 | { |
795 | // FIXME: explode(' ',$searchterms) and perform a AND search. | 795 | // FIXME: explode(' ',$searchterms) and perform a AND search. |
796 | // FIXME: accept double-quotes to search for a string "as is"? | 796 | // FIXME: accept double-quotes to search for a string "as is"? |
797 | // Using mb_convert_case($val, MB_CASE_LOWER, 'UTF-8') allows us to perform searches on | ||
798 | // Unicode text. See https://github.com/shaarli/Shaarli/issues/75 for examples. | ||
797 | $filtered=array(); | 799 | $filtered=array(); |
798 | $s = strtolower($searchterms); | 800 | $s = mb_convert_case($searchterms, MB_CASE_LOWER, 'UTF-8'); |
799 | foreach($this->links as $l) | 801 | foreach($this->links as $l) |
800 | { | 802 | { |
801 | $found= (strpos(strtolower($l['title']),$s)!==false) | 803 | $found= (strpos(mb_convert_case($l['title'], MB_CASE_LOWER, 'UTF-8'),$s) !== false) |
802 | || (strpos(strtolower($l['description']),$s)!==false) | 804 | || (strpos(mb_convert_case($l['description'], MB_CASE_LOWER, 'UTF-8'),$s) !== false) |
803 | || (strpos(strtolower($l['url']),$s)!==false) | 805 | || (strpos(mb_convert_case($l['url'], MB_CASE_LOWER, 'UTF-8'),$s) !== false) |
804 | || (strpos(strtolower($l['tags']),$s)!==false); | 806 | || (strpos(mb_convert_case($l['tags'], MB_CASE_LOWER, 'UTF-8'),$s) !== false); |
805 | if ($found) $filtered[$l['linkdate']] = $l; | 807 | if ($found) $filtered[$l['linkdate']] = $l; |
806 | } | 808 | } |
807 | krsort($filtered); | 809 | krsort($filtered); |
@@ -813,12 +815,14 @@ class linkdb implements Iterator, Countable, ArrayAccess | |||
813 | // e.g. print_r($mydb->filterTags('linux programming')); | 815 | // e.g. print_r($mydb->filterTags('linux programming')); |
814 | public function filterTags($tags,$casesensitive=false) | 816 | public function filterTags($tags,$casesensitive=false) |
815 | { | 817 | { |
816 | $t = str_replace(',',' ',($casesensitive?$tags:strtolower($tags))); | 818 | // Same as above, we use UTF-8 conversion to handle various graphemes (i.e. cyrillic, or greek) |
819 | // TODO: is $casesensitive ever true ? | ||
820 | $t = str_replace(',',' ',($casesensitive?$tags:mb_convert_case($tags, MB_CASE_LOWER, 'UTF-8'))); | ||
817 | $searchtags=explode(' ',$t); | 821 | $searchtags=explode(' ',$t); |
818 | $filtered=array(); | 822 | $filtered=array(); |
819 | foreach($this->links as $l) | 823 | foreach($this->links as $l) |
820 | { | 824 | { |
821 | $linktags = explode(' ',($casesensitive?$l['tags']:strtolower($l['tags']))); | 825 | $linktags = explode(' ',($casesensitive?$l['tags']:mb_convert_case($l['tags'], MB_CASE_LOWER, 'UTF-8'))); |
822 | if (count(array_intersect($linktags,$searchtags)) == count($searchtags)) | 826 | if (count(array_intersect($linktags,$searchtags)) == count($searchtags)) |
823 | $filtered[$l['linkdate']] = $l; | 827 | $filtered[$l['linkdate']] = $l; |
824 | } | 828 | } |
@@ -1173,10 +1177,7 @@ function showDaily() | |||
1173 | $PAGE = new pageBuilder; | 1177 | $PAGE = new pageBuilder; |
1174 | $PAGE->assign('linksToDisplay',$linksToDisplay); | 1178 | $PAGE->assign('linksToDisplay',$linksToDisplay); |
1175 | $PAGE->assign('linkcount',count($LINKSDB)); | 1179 | $PAGE->assign('linkcount',count($LINKSDB)); |
1176 | $PAGE->assign('col1',$columns[0]); | 1180 | $PAGE->assign('cols', $columns); |
1177 | $PAGE->assign('col1',$columns[0]); | ||
1178 | $PAGE->assign('col2',$columns[1]); | ||
1179 | $PAGE->assign('col3',$columns[2]); | ||
1180 | $PAGE->assign('day',utf8_encode(strftime('%A %d, %B %Y',linkdate2timestamp($day.'_000000')))); | 1181 | $PAGE->assign('day',utf8_encode(strftime('%A %d, %B %Y',linkdate2timestamp($day.'_000000')))); |
1181 | $PAGE->assign('previousday',$previousday); | 1182 | $PAGE->assign('previousday',$previousday); |
1182 | $PAGE->assign('nextday',$nextday); | 1183 | $PAGE->assign('nextday',$nextday); |