[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/search/Zend/Search/Lucene/Analysis/TokenFilter/ -> LowerCaseUtf8.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to license@zend.com so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Search_Lucene
  17   * @subpackage Analysis
  18   * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   */
  21  
  22  
  23  /** Zend_Search_Lucene_Analysis_TokenFilter */
  24  require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
  25  
  26  
  27  /**
  28   * Lower case Token filter.
  29   *
  30   * @category   Zend
  31   * @package    Zend_Search_Lucene
  32   * @subpackage Analysis
  33   * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  34   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  35   */
  36  
  37  class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_Lucene_Analysis_TokenFilter
  38  {
  39      /**
  40       * Object constructor
  41       */
  42      public function __construct()
  43      {
  44          if (!function_exists('mb_strtolower')) {
  45              // mbstring extension is disabled
  46              require_once 'Zend/Search/Lucene/Exception.php';
  47              throw new Zend_Search_Lucene_Exception('Utf8 compatible lower case filter needs mbstring extension to be enabled.');
  48          }
  49      }
  50      
  51      /**
  52       * Normalize Token or remove it (if null is returned)
  53       *
  54       * @param Zend_Search_Lucene_Analysis_Token $srcToken
  55       * @return Zend_Search_Lucene_Analysis_Token
  56       */
  57      public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
  58      {
  59          $newToken = new Zend_Search_Lucene_Analysis_Token(
  60                                       mb_strtolower($srcToken->getTermText(), 'UTF-8'),
  61                                       $srcToken->getStartOffset(),
  62                                       $srcToken->getEndOffset());
  63  
  64          $newToken->setPositionIncrement($srcToken->getPositionIncrement());
  65  
  66          return $newToken;
  67      }
  68  }
  69  


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7