Пример #1
0
 public function performSearch($oResult = null)
 {
     if (!is_object($oResult)) {
         $oResult = ilShopSearchResult::_getInstance(SHOP_CONTENT);
         if ((bool) $this->settings->get('topics_allow_custom_sorting')) {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(true);
             ilShopTopics::_getInstance()->setSortingType((int) $this->getSortingTypeTopics());
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->getSortingDirectionTopics()));
             ilShopTopics::_getInstance()->read();
         } else {
             ilShopTopics::_getInstance()->setIdFilter((int) $this->getTopicId());
             ilShopTopics::_getInstance()->enableCustomSorting(false);
             ilShopTopics::_getInstance()->setSortingType((int) $this->settings->get('topics_sorting_type'));
             ilShopTopics::_getInstance()->setSortingDirection(strtoupper($this->settings->get('topics_sorting_direction')));
             ilShopTopics::_getInstance()->read();
         }
         $topics = ilShopTopics::_getInstance()->getTopics();
         $oResult->setTopics($topics);
         $oResult->setResultPageNumber((int) $_GET['page_number']);
     }
     // query parser
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
     $query_parser->setMinWordLength(0);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         ilUtil::sendInfo($query_parser->getMessage());
     }
     // search
     $types = array('crs', 'lm', 'sahs', 'htlm', 'file', 'tst', 'exc', 'glo');
     if ($this->getType() == '' || $this->getType() == 'title' || $query_parser->getQueryString() == '') {
         include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
         $object_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
         $object_search->setFields(array('title'));
         $object_search->setFilter($types);
         $object_search->setCustomSearchResultObject($oResult);
         $object_search->setFilterShopTopicId((int) $this->getTopicId());
         $res = $object_search->performSearch();
     } else {
         if ($this->getType() == 'author') {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('contribute');
             $meta_search->setFilter($types);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $meta_search->setCustomSearchResultObject($oResult);
             $res = $meta_search->performSearch();
         } else {
             include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('title');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res = $meta_search->performSearch();
             $meta_search = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
             $meta_search->setMode('keyword');
             $meta_search->setFilter($types);
             $meta_search->setCustomSearchResultObject($oResult);
             $meta_search->setFilterShopTopicId((int) $this->getTopicId());
             $res->mergeEntries($meta_search->performSearch());
         }
     }
     $res->filter(ROOT_FOLDER_ID, true);
     $res->save();
     if (!count($res->getResults())) {
         ilUtil::sendInfo($this->lng->txt('payment_shop_not_objects_found'));
     }
     $this->showTopicsContent($res);
     $this->addPager($res);
     return;
 }