コード例 #1
0
 /**
  * Perform search 
  */
 protected function performSearch()
 {
     global $ilUser, $ilBench;
     unset($_SESSION['vis_references']);
     $filter_query = '';
     if ($this->search_cache->getItemFilter() and ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
         $filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
         foreach ((array) $this->search_cache->getItemFilter() as $obj => $value) {
             if (!$filter_query) {
                 $filter_query .= '+( ';
             } else {
                 $filter_query .= 'OR';
             }
             $filter_query .= ' ' . (string) $filter_settings[$obj]['filter'] . ' ';
         }
         $filter_query .= ') ';
     }
     // begin-patch mime_filter
     $mime_query = '';
     if ($this->search_cache->getMimeFilter() and ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled()) {
         $filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions();
         foreach ($this->search_cache->getMimeFilter() as $mime => $value) {
             if (!$mime_query) {
                 $mime_query .= '+( ';
             } else {
                 $mime_query .= 'OR';
             }
             $mime_query .= ' ' . (string) $filter_settings[$mime]['filter'] . ' ';
         }
         $mime_query .= ') ';
     }
     $filter_query = $filter_query . ' ' . $mime_query;
     include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
     include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
     $qp = new ilLuceneQueryParser($filter_query . ' +(' . $this->search_cache->getQuery() . ')');
     $qp->parse();
     $searcher = ilLuceneSearcher::getInstance($qp);
     $searcher->search();
     // Filter results
     include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
     include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
     $filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
     $filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot()));
     $filter->setCandidates($searcher->getResult());
     $filter->filter();
     if ($filter->getResultObjIds()) {
         $searcher->highlight($filter->getResultObjIds());
     }
     // Show results
     $this->showSearchForm();
     include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
     $presentation = new ilSearchResultPresentation($this);
     $presentation->setResults($filter->getResultIds());
     $presentation->setSearcher($searcher);
     // TODO: other handling required
     $ilBench->start('Lucene', '1500_fo');
     $this->addPager($filter, 'max_page');
     $ilBench->stop('Lucene', '1500_fo');
     $presentation->setPreviousNext($this->prev_link, $this->next_link);
     if ($presentation->render()) {
         $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML(true));
     } else {
         ilUtil::sendInfo(sprintf($this->lng->txt('search_no_match_hint'), $this->search_cache->getQuery()));
     }
 }
コード例 #2
0
 /**
  * Perform search 
  */
 protected function performSearch()
 {
     global $ilUser, $ilBench;
     unset($_SESSION['vis_references']);
     include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
     include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php';
     $qp = new ilLuceneAdvancedQueryParser($this->search_cache->getQuery());
     $qp->parse();
     if (!strlen(trim($qp->getQuery()))) {
         ilUtil::sendInfo($this->lng->txt('msg_no_search_string'));
         $this->showSavedResults();
         return false;
     }
     $searcher = ilLuceneSearcher::getInstance($qp);
     $searcher->search();
     // Filter results
     $ilBench->start('Lucene', 'ResultFilter');
     include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
     include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
     $filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
     $filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot()));
     $filter->setCandidates($searcher->getResult());
     $filter->filter();
     $ilBench->stop('Lucene', 'ResultFilter');
     if ($filter->getResultObjIds()) {
         $searcher->highlight($filter->getResultObjIds());
     }
     // Show results
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_adv_search.html', 'Services/Search');
     include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
     $presentation = new ilSearchResultPresentation($this);
     $presentation->setResults($filter->getResultIds());
     $presentation->setSearcher($searcher);
     // TODO: other handling required
     $ilBench->start('Lucene', '1500_fo');
     $this->addPager($filter, 'max_page');
     $ilBench->stop('Lucene', '1500_fo');
     $presentation->setPreviousNext($this->prev_link, $this->next_link);
     if ($presentation->render()) {
         $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML(true));
     } else {
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     // and finally add search form
     $this->initFormSearch();
     $this->tpl->setVariable('SEARCH_TABLE', $this->form->getHTML());
     if ($filter->getResultIds()) {
         $this->fillAdminPanel();
     }
 }