Beispiel #1
0
 /**
  * Perform search
  */
 function performSearch()
 {
     global $ilUser;
     if (!isset($_GET['page_number']) and $this->search_mode != 'in_results') {
         unset($_SESSION['max_page']);
         $this->search_cache->deleteCachedEntries();
     }
     if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS and !$this->getDetails()) {
         ilUtil::sendInfo($this->lng->txt('search_choose_object_type'));
         $this->showSearch();
         return false;
     }
     // Step 1: parse query string
     if (!is_object($query_parser =& $this->__parseQueryString())) {
         ilUtil::sendInfo($query_parser);
         $this->showSearch();
         return false;
     }
     // Step 2: perform object search. Get an ObjectSearch object via factory. Depends on fulltext or like search type.
     $result =& $this->__searchObjects($query_parser);
     // Step 3: perform meta keyword search. Get an MetaDataSearch object.
     $result_meta =& $this->__searchMeta($query_parser, 'keyword');
     $result->mergeEntries($result_meta);
     $result_meta =& $this->__searchMeta($query_parser, 'contribute');
     $result->mergeEntries($result_meta);
     $result_meta =& $this->__searchMeta($query_parser, 'title');
     $result->mergeEntries($result_meta);
     $result_meta =& $this->__searchMeta($query_parser, 'description');
     $result->mergeEntries($result_meta);
     // Perform details search in object specific tables
     if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
         $result = $this->__performDetailsSearch($query_parser, $result);
     }
     // Step 5: Search in results
     if ($this->search_mode == 'in_results') {
         include_once 'Services/Search/classes/class.ilSearchResult.php';
         $old_result_obj = new ilSearchResult($ilUser->getId());
         $old_result_obj->read();
         $result->diffEntriesFromResult($old_result_obj);
     }
     // Step 4: merge and validate results
     $result->filter($this->getRootNode(), $query_parser->getCombination() == 'and');
     $result->save();
     $this->showSearch();
     if (!count($result->getResults())) {
         ilUtil::sendInfo($this->lng->txt('search_no_match'));
     }
     if ($result->isLimitReached()) {
         #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
         #ilUtil::sendInfo($message);
     }
     // Step 6: show results
     $this->addPager($result, 'max_page');
     include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
     $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD);
     $presentation->setResults($result->getResultsForPresentation());
     $presentation->setSubitemIds($result->getSubitemIds());
     $presentation->setPreviousNext($this->prev_link, $this->next_link);
     if ($presentation->render()) {
         //			$this->tpl->setVariable('SEARCH_RESULTS',$presentation->getHTML());
         $this->tpl->setVariable('RESULTS_TABLE', $presentation->getHTML(true));
     }
     return true;
 }
 function showSavedResults()
 {
     global $ilUser;
     // Read old result sets
     include_once 'Services/Search/classes/class.ilSearchResult.php';
     $this->initSearchType(self::TYPE_LOM);
     $result_obj = new ilSearchResult($ilUser->getId());
     $result_obj->read(ADVANCED_SEARCH);
     $this->showSearch();
     // Show them
     if (count($result_obj->getResults())) {
         $this->addPager($result_obj, 'adv_max_page');
         include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
         $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD);
         $presentation->setResults($result_obj->getResultsForPresentation());
         $presentation->setPreviousNext($this->prev_link, $this->next_link);
         if ($presentation->render()) {
             $this->tpl->setVariable('RESULTS', $presentation->getHTML(true));
         }
     }
     return true;
 }