Changeset 5304
- Timestamp:
- 12/17/08 23:04:21 (7 months ago)
- Location:
- branches
- Files:
-
- 2 added
- 3 modified
-
1.0/lib/Doctrine/Search/Analyzer/Standard.php (modified) (1 diff)
-
1.0/tests/Ticket/1745TestCase.php (added)
-
1.1/lib/Doctrine/Search/Analyzer/Interface.php (modified) (1 diff)
-
1.1/lib/Doctrine/Search/Analyzer/Standard.php (modified) (1 diff)
-
1.1/tests/Ticket/1745TestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/lib/Doctrine/Search/Analyzer/Standard.php
r3884 r5304 274 274 { 275 275 $text = preg_replace('/[\'`�"]/', '', $text); 276 $text = Doctrine_Inflector::unaccent($text); 276 277 $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); 277 278 $text = str_replace(' ', ' ', $text); -
branches/1.1/lib/Doctrine/Search/Analyzer/Interface.php
r5078 r5304 33 33 interface Doctrine_Search_Analyzer_Interface 34 34 { 35 public function analyze($text , $encoding='ISO8859-15');35 public function analyze($text); 36 36 } -
branches/1.1/lib/Doctrine/Search/Analyzer/Standard.php
r5078 r5304 271 271 ); 272 272 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) 280 274 { 281 $old_locale = setlocale(LC_ALL, '0');282 283 // iconv translit does work only if your locale is an unicode284 // 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 305 275 $text = preg_replace('/[\'`�"]/', '', $text); 276 $text = Doctrine_Inflector::unaccent($text); 306 277 $text = preg_replace('/[^A-Za-z0-9]/', ' ', $text); 307 278 $text = str_replace(' ', ' ', $text);