Пример #1
0
 /**
  * parse query string, using query parser instance
  * @return object of query parser or error message if an error occured
  * @access public
  */
 function &__parseQueryString($a_string)
 {
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
     $query_parser->setCombination(QP_COMBINATION_OR);
     $query_parser->setMinWordLength(1, true);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
 /**
  * parse query string, using query parser instance
  * @return object of query parser or error message if an error occured
  * @access public
  */
 function &__parseQueryString($a_string, $a_combination_or = true)
 {
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
     $query_parser->setCombination($a_combination_or ? QP_COMBINATION_OR : QP_COMBINATION_AND);
     $query_parser->setMinWordLength(1, true);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
 /**
  * This function is only used by the ajax request if searching for ILIAS references. It builds the html for the search results.
  */
 public function searchObjects()
 {
     global $lng;
     $search = $_POST['search_for'];
     $dest = $_POST['dest'];
     $html = "";
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($search);
     $query_parser->setMinWordLength(1, true);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         $html .= $query_parser->getMessage() . "<br />";
     }
     // only like search since fulltext does not support search with less than 3 characters
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($query_parser);
     $res = $object_search->performSearch();
     //$res->setRequiredPermission('copy');
     $res->filter(ROOT_FOLDER_ID, true);
     if (!count($results = $res->getResultsByObjId())) {
         $html .= $lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />";
     }
     $results = $this->parseSearchResults($results);
     foreach ($results as $entry) {
         $tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection");
         foreach ((array) $entry['refs'] as $reference) {
             include_once './Services/Tree/classes/class.ilPathGUI.php';
             $path = new ilPathGUI();
             $tpl->setCurrentBlock('result');
             $tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " > " . $entry['title']);
             $tpl->setVariable('RESULT_REF', $reference);
             $tpl->setVariable('FIELD_ID', $dest);
             $tpl->parseCurrentBlock();
         }
         $html .= $tpl->get();
     }
     echo $html;
     exit;
 }
Пример #4
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 parseQueryString()
 {
     include_once 'Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
     $query_parser->setCombination($this->getCombination());
     $query_parser->parse();
     if (!$query_parser->validate()) {
         return $query_parser->getMessage();
     }
     return $query_parser;
 }
 /**
  * Search source
  * @return 
  */
 protected function searchSource()
 {
     global $tree, $ilObjDataCache, $lng, $ilCtrl, $tpl;
     if (isset($_POST['tit'])) {
         ilUtil::sendInfo($this->lng->txt('wizard_search_list'));
         $_SESSION['source_query'] = $_POST['tit'];
     } else {
         $_POST['tit'] = $_SESSION['source_query'];
     }
     $this->initFormSearch();
     $this->form->setValuesByPost();
     if (!$this->form->checkInput()) {
         ilUtil::sendFailure($lng->txt('msg_no_search_string'), true);
         $ilCtrl->returnToParent($this);
         return false;
     }
     include_once './Services/Search/classes/class.ilQueryParser.php';
     $query_parser = new ilQueryParser($this->form->getInput('tit'));
     $query_parser->setMinWordLength(1, true);
     $query_parser->setCombination(QP_COMBINATION_AND);
     $query_parser->parse();
     if (!$query_parser->validate()) {
         ilUtil::sendFailure($query_parser->getMessage(), true);
         $ilCtrl->returnToParent($this);
     }
     // only like search since fulltext does not support search with less than 3 characters
     include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
     $object_search = new ilLikeObjectSearch($query_parser);
     $object_search->setFilter(array($_REQUEST['new_type']));
     $res = $object_search->performSearch();
     $res->setRequiredPermission('copy');
     $res->filter(ROOT_FOLDER_ID, true);
     if (!count($results = $res->getResultsByObjId())) {
         ilUtil::sendFailure($this->lng->txt('search_no_match'), true);
         $ilCtrl->returnToParent($this);
     }
     include_once './Services/Object/classes/class.ilObjectCopySearchResultTableGUI.php';
     $table = new ilObjectCopySearchResultTableGUI($this, 'searchSource', $_REQUEST['new_type']);
     $table->setSelectedReference($this->getSource());
     $table->parseSearchResults($results);
     $tpl->setContent($table->getHTML());
 }
 private function parseQueryString($query_string)
 {
     $oQueryParser = new ilQueryParser($query_string);
     $oQueryParser->setCombination('or');
     $oQueryParser->parse();
     if (!$oQueryParser->validate()) {
         return $oQueryParser->getMessage();
     }
     return $oQueryParser;
 }