4 include_once
'Services/Search/classes/class.ilSearchResult.php';
41 if(!isset(self::$_instance))
46 return self::$_instance;
56 $this->search_type = $a_search_type;
57 parent::__construct($ilUser->getId());
62 $this->search_type = $_search_type;
90 $ordered_entries = array();
92 $num_entries = count($a_entries);
93 foreach($this->topics as $oTopic)
95 foreach($a_entries as $aEntry)
97 if($oTopic->getId() == $aEntry[
'topic_id'])
99 $ordered_entries[$aEntry[
'ref_id']] = $aEntry;
103 if(count($ordered_entries) < $num_entries)
105 foreach($a_entries as $aEntry)
107 if(0 == $aEntry[
'topic_id'])
109 $ordered_entries[$aEntry[
'ref_id']] = $aEntry;
114 return is_array($ordered_entries) ? $ordered_entries : array();
128 public function filter($a_root_node, $check_and)
136 $tmp_entries = array();
140 if($check_and && in_array(0, $entry[
'found']))
146 if($type ==
'rolt' or $type ==
'usr' or $type ==
'role')
152 if($this->ilAccess->checkAccessOfUser($this->getUserId(),
157 if($a_root_node == ROOT_FOLDER_ID || $tree->isGrandChild($a_root_node,
$ref_id))
162 $entry[
'type'] = $type;
164 $tmp_entries[
$ref_id] = $entry;
170 $this->results = array();
174 foreach($tmp_entries as $entry)
178 $this->
addResult($entry[
'ref_id'], $entry[
'obj_id'], $entry[
'type']);
179 $this->search_cache->appendToChecked($entry[
'ref_id'], $entry[
'obj_id']);
183 $this->search_cache->setResults($this->results);
189 include_once
'Services/Payment/classes/class.ilPaymentSettings.php';
191 $this->
setMaxHits(($maxhits > 0 ? $maxhits : 20));
202 $objects_with_topics = array();
203 $objects_with_no_topcis = array();
228 if(!(
int)$topic_id && !array_key_exists($result[
'ref_id'], $objects_with_no_topcis))
230 $objects_with_no_topcis[$result[
'ref_id']] =
$result;
234 if((
int)$topic_id != $oTopic->getId())
239 if(!array_key_exists($result[
'ref_id'], $objects_with_topics))
241 $objects_with_topics[$result[
'ref_id']] =
$result;
244 switch($result[
'type'])
255 $type = $result[
'type'];
262 if($result[
'type'] ==
'exc')
265 $subtype =
' ('.$lng->txt($check_sub[0]).
')';
269 'title' => $title.
' '.$subtype,
270 'description' => $description,
271 'type' => $result[
'type'],
272 'obj_id' => $result[
'obj_id'],
273 'topic_id' => $topic_id,
274 'child' => $result[
'child']);
280 if(!array_key_exists($result[
'ref_id'], $objects_with_topics) &&
281 !array_key_exists($result[
'ref_id'], $objects_with_no_topcis))
283 $objects_with_no_topcis[$result[
'ref_id']] =
$result;
286 foreach($objects_with_no_topcis as $result)
288 switch($result[
'type'])
299 $type = $result[
'type'];
307 'description' => $description,
308 'type' => $result[
'type'],
309 'obj_id' => $result[
'obj_id'],
310 'child' => $result[
'child']);
319 return is_array($this->topics) ? $this->topics : array();
323 $this->topics = $a_topics;
328 $this->result_page_number = (int)$a_result_page_number > 0 ? $a_result_page_number : 1;
337 $this->presentation_results[] = $a_presentation_result;
341 return is_array($this->presentation_results) ? $this->presentation_results : array();
346 parent::initUserSearchCache();
348 $this->search_cache->switchSearchType($this->search_type);
351 function addEntry($a_ref_id, $a_type, $found, $a_child_id = 0)
353 global $ilObjDataCache;
355 $a_obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
358 if(!$this->entries[$a_ref_id])
360 $this->entries[$a_ref_id][
'ref_id'] = $a_ref_id;
361 $this->entries[$a_ref_id][
'obj_id'] = $a_obj_id;
362 $this->entries[$a_ref_id][
'type'] = $a_type;
363 $this->entries[$a_ref_id][
'found'] = $found;
365 if($a_child_id and $a_child_id != $a_ref_id)
367 $this->entries[$a_ref_id][
'child'][$a_child_id] = $a_child_id;
373 if($a_child_id and $a_child_id != $a_obj_id)
375 $this->entries[$a_ref_id][
'child'][$a_child_id] = $a_child_id;
380 foreach($found as $position)
384 $this->entries[$a_ref_id][
'found'][$counter] = $position;
394 if($this->entries[$a_ref_id] and is_array($a_childs))
396 foreach($a_childs as $child_id)
400 $this->entries[$a_ref_id][
'child'][$child_id] = $child_id;
410 foreach($result_obj->getEntries() as $entry)
412 $this->
addEntry($entry[
'ref_id'],$entry[
'type'],$entry[
'found']);
421 $this->entries = array();
424 foreach($this->search_cache->getCheckedItems() as
$ref_id => $obj_id)
426 if(isset($new_entries[$ref_id]))
428 $this->
addEntry($new_entries[$ref_id][
'ref_id'],
429 $new_entries[$ref_id][
'type'],
430 $new_entries[$ref_id][
'found']);
432 $new_entries[$ref_id][
'child']);
setResultPageNumber($a_result_page_number)
const SHOW_TOPICS_CONTENT
setSearchType($_search_type)
getResultsForPresentation()
mergeEntries(&$result_obj)
assignEntries($a_entries)
addPresentationResult($a_presentation_result=array())
__updateEntryChilds($a_ref_id, $a_childs)
const SHOW_CONTAINER_CONTENT
static _lookupTitle($a_id)
lookup object title
searchResult stores all result of a search query.
static _lookupTopicId($a_ref_id)
__initSearchSettingsObject()
addEntry($a_ref_id, $a_type, $found, $a_child_id=0)
static _lookupDescription($a_id)
lookup object description
__construct($a_search_type)
diffEntriesFromResult(&$result_obj)
_getInstance($a_search_type)
__updateResultChilds($a_ref_id, $a_childs)
Update childs for a specific result.
addResult($a_ref_id, $a_obj_id, $a_type)
add search result Results are stored with 'ref_id'.
setFilterMode($filter_mode)
static _lookupType($a_id, $a_reference=false)
lookup object type
const SHOW_SPECIAL_CONTENT
filter($a_root_node, $check_and)
Filter search result.
setTopics($a_topics=array())
callListeners($a_ref_id, &$a_data)
static _checkExcSubtype($a_ref_id)