示例#1
0
 /**
  * Add a file to the search index.
  * @param $articleId int
  * @param $type int
  * @param $fileId int
  */
 function updateFileIndex($articleId, $type, $fileId)
 {
     import('classes.file.ArticleFileManager');
     $fileMgr = new ArticleFileManager($articleId);
     $file =& $fileMgr->getFile($fileId);
     if (isset($file)) {
         $parser =& SearchFileParser::fromFile($file);
     }
     if (isset($parser)) {
         if ($parser->open()) {
             $searchDao =& DAORegistry::getDAO('ArticleSearchDAO');
             $objectId = $searchDao->insertObject($articleId, $type, $fileId);
             $position = 0;
             while (($text = $parser->read()) !== false) {
                 ArticleSearchIndex::indexObjectKeywords($objectId, $text, $position);
             }
             $parser->close();
         }
     }
 }