コード例 #1
0
ファイル: search.php プロジェクト: Gfksx/customisation-db
 /**
  * Initialize the Search
  */
 public static function initialize()
 {
     if (self::$index === false) {
         // Initialize the ezc/Zend Search class
         if (titania::$config->search_backend == 'zend') {
             if (!is_writable(TITANIA_ROOT . self::store_path)) {
                 throw new exception(self::store_path . ' must be writable to use the Zend Lucene Search');
             }
             $handler = new ezcSearchZendLuceneHandler(TITANIA_ROOT . self::store_path);
         } else {
             if (titania::$config->search_backend == 'solr') {
                 $handler = new ezcSearchSolrHandler(titania::$config->search_backend_ip, titania::$config->search_backend_port);
                 // In case Solr would happen to go down..
                 if (!$handler->connection) {
                     // Log this as an error
                     titania::log(TITANIA_ERROR, 'Solr Server not responding');
                     self::$do_not_index = true;
                     return false;
                 }
             } else {
                 throw new exception('We need a proper search backend selected');
             }
         }
         $manager = new ezcSearchEmbeddedManager();
         self::$index = new ezcSearchSession($handler, $manager);
         return true;
     }
 }