Changeset 5304

Show
Ignore:
Timestamp:
12/17/08 23:04:21 (7 months ago)
Author:
jwage
Message:

[1.0, 1.1] Fixed issue with accented characters with Searchable behavior (closes #1745)

Location:
branches
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Search/Analyzer/Standard.php

    r3884 r5304  
    274274    { 
    275275        $text = preg_replace('/[\'`�"]/', '', $text); 
     276        $text = Doctrine_Inflector::unaccent($text); 
    276277        $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); 
    277278        $text = str_replace('  ', ' ', $text); 
  • branches/1.1/lib/Doctrine/Search/Analyzer/Interface.php

    r5078 r5304  
    3333interface Doctrine_Search_Analyzer_Interface 
    3434{ 
    35     public function analyze($text, $encoding='ISO8859-15'); 
     35    public function analyze($text); 
    3636} 
  • branches/1.1/lib/Doctrine/Search/Analyzer/Standard.php

    r5078 r5304  
    271271                            ); 
    272272 
    273     /** 
    274     * Translit $text from $encoding to regular ASCII 
    275     * @param string $text 
    276     * @param string $encoding 
    277     * @return string translitterated text 
    278     */ 
    279     private function translit($text,$encoding) 
     273    public function analyze($text) 
    280274    { 
    281         $old_locale = setlocale(LC_ALL, '0'); 
    282  
    283         // iconv translit does work only if your locale is an unicode 
    284         // locale, so let's move to an unicode locale :-) 
    285         setlocale(LC_ALL, 'en_US.UTF8'); 
    286  
    287         $r = ''; 
    288         $s1 = iconv($encoding, 'ASCII//TRANSLIT', $text); 
    289         for ($i = 0; $i < strlen($s1); $i++) 
    290         { 
    291             $ch1 = $s1[$i]; 
    292             $ch2 = mb_substr($text, $i, 1); 
    293  
    294             $r .= $ch1=='?'?$ch2:$ch1; 
    295         } 
    296  
    297         setlocale(LC_ALL, $old_locale); 
    298         return $r; 
    299     } 
    300  
    301     public function analyze($text, $encoding='ISO-8859-15') 
    302     { 
    303         $text = $this->translit($text,$encoding);  
    304  
    305275        $text = preg_replace('/[\'`�"]/', '', $text); 
     276        $text = Doctrine_Inflector::unaccent($text); 
    306277        $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); 
    307278        $text = str_replace('  ', ' ', $text);