Пример #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;
 }
 private function searchObjects($query_parser)
 {
     // create new search result object and assign the sorted topics
     $oSearchResult = ilShopSearchResult::_getInstance(SHOP_ADVANCED_SEARCH);
     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();
     }
     $oSearchResult->setTopics(ilShopTopics::_getInstance()->getTopics());
     $oSearchResult->setResultPageNumber((int) $_GET['page_number']);
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     $res = null;
     $obj_search = ilObjectSearchFactory::_getShopObjectSearchInstance($query_parser);
     $obj_search->setFilterShopTopicId((int) $this->getTopicId());
     $obj_search->setFilter($this->getFilter());
     $obj_search->setCustomSearchResultObject($oSearchResult);
     $res = $obj_search->performSearch();
     $meta_search_c = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_c->setMode('contribute');
     $meta_search_c->setFilter($this->getFilter());
     $meta_search_c->setFilterShopTopicId((int) $this->getTopicId());
     $meta_search_c->setCustomSearchResultObject($oSearchResult);
     $res->mergeEntries($meta_search_c->performSearch());
     $meta_search_t = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_t->setMode('title');
     $meta_search_t->setFilter($this->getFilter());
     $meta_search_t->setCustomSearchResultObject($oSearchResult);
     $meta_search_t->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_t->performSearch());
     $meta_search_k = ilObjectSearchFactory::_getShopMetaDataSearchInstance($query_parser);
     $meta_search_k->setMode('keyword');
     $meta_search_k->setFilter($this->getFilter());
     $meta_search_k->setCustomSearchResultObject($oSearchResult);
     $meta_search_k->setFilterShopTopicId((int) $this->getTopicId());
     $res->mergeEntries($meta_search_k->performSearch());
     return $res;
 }