34 include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
36 define(
'DEFAULT_SEARCH',0);
37 define(
'ADVANCED_SEARCH',1);
38 define(
'SHOP_CONTENT',2);
39 define(
'SHOP_ADVANCED_SEARCH',3);
40 define(
'ADVANCED_MD_SEARCH',4);
75 $this->user_id = $a_user_id;
79 $this->user_id = $ilUser->getId();
92 $this->permission = $a_permission;
103 $this->user_id = $a_user_id;
112 return $this->entries ? $this->entries : array();
117 return $this->limit_reached ?
true :
false;
122 $this->max_hits = $a_max_hits;
126 return $this->max_hits;
138 return ($a_counter < $this->offset) ?
false :
true;
151 function addEntry($a_obj_id,$a_type,$found,$a_child_id = 0)
154 if(!$this->entries[$a_obj_id])
156 $this->entries[$a_obj_id][
'obj_id'] = $a_obj_id;
157 $this->entries[$a_obj_id][
'type'] = $a_type;
158 $this->entries[$a_obj_id][
'found'] = $found;
160 if($a_child_id and $a_child_id != $a_obj_id)
162 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
168 if($a_child_id and $a_child_id != $a_obj_id)
170 $this->entries[$a_obj_id][
'child'][$a_child_id] = $a_child_id;
175 foreach($found as $position)
179 $this->entries[$a_obj_id][
'found'][$counter] = $position;
205 foreach($result_obj->getEntries() as $entry)
207 $this->
addEntry($entry[
'obj_id'],$entry[
'type'],$entry[
'found']);
223 $this->entries = array();
226 foreach($this->search_cache->getCheckedItems() as
$ref_id => $obj_id)
228 if(isset($new_entries[$obj_id]))
230 $this->
addEntry($new_entries[$obj_id][
'obj_id'],
231 $new_entries[$obj_id][
'type'],
232 $new_entries[$obj_id][
'found']);
234 $new_entries[$obj_id][
'child']);
248 $this->entries = array();
250 foreach($result_obj->getEntries() as $entry)
252 $obj_id = $entry[
'obj_id'];
253 if(isset($new_entries[$obj_id]))
255 $this->
addEntry($new_entries[$obj_id][
'obj_id'],
256 $new_entries[$obj_id][
'type'],
257 $new_entries[$obj_id][
'found']);
260 $new_entries[$obj_id][
'child']);
277 $this->results[$a_ref_id][
'ref_id'] = $a_ref_id;
278 $this->results[$a_ref_id][
'obj_id'] = $a_obj_id;
279 $this->results[$a_ref_id][
'type'] = $a_type;
284 return $this->results ? $this->results : array();
299 return $ids ? $ids : array();
307 $tmp_res[$res_data[
'obj_id']][] =
$ref_id;
309 return $tmp_res ? $tmp_res : array();
322 foreach($this->results as
$result)
324 if(in_array($result[
'obj_id'],$obj_ids))
328 $obj_ids[] = $result[
'obj_id'];
331 return $objects ? $objects : array();
340 $res[$result[
'ref_id']] = $result[
'obj_id'];
350 $res[$row[
'obj_id']] = $row[
'child'];
369 public function filter($a_root_node,$check_and)
379 if($check_and and in_array(0,$entry[
'found']))
390 $counter += count($entry[
'child']);
394 $this->limit_reached =
true;
404 if($this->search_cache->isFailed($ref_id))
409 if($this->search_cache->isChecked($ref_id) and !$this->
isOffsetReached($offset_counter))
424 if($this->ilAccess->checkAccessOfUser($this->getUserId(),
431 if($a_root_node == ROOT_FOLDER_ID or $tree->isGrandChild($a_root_node,$ref_id))
434 #if($this->callListeners($ref_id,$entry))
437 $this->
addResult($ref_id,$entry[
'obj_id'],$type);
438 $this->search_cache->appendToChecked($ref_id,$entry[
'obj_id']);
447 $this->limit_reached =
true;
448 $this->search_cache->setResults($this->results);
455 $this->search_cache->appendToFailed($ref_id);
458 $this->search_cache->setResults($this->results);
472 $this->results = array();
473 foreach($tmp_results as
$result)
475 if($tree->isGrandChild($a_root_node,$result[
'ref_id']) and $tree->isInTree($result[
'ref_id']))
477 $this->
addResult($result[
'ref_id'],$result[
'obj_id'],$result[
'type']);
494 $this->search_cache->save();
505 $this->results = $this->search_cache->getResults();
518 if($this->entries[$a_obj_id] and is_array($a_childs))
520 foreach($a_childs as $child_id)
524 $this->entries[$a_obj_id][
'child'][$child_id] = $child_id;
540 if($this->results[$a_ref_id] and is_array($a_childs))
542 foreach($a_childs as $child_id)
544 $this->results[$a_ref_id][
'child'][$child_id] = $child_id;
555 include_once
'Services/Search/classes/class.ilSearchSettings.php';
559 $this->
setMaxHits($this->search_settings->getMaxHits());
570 include_once(
'Services/Search/classes/class.ilUserSearchCache.php');
572 $this->offset = $this->
getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
607 $this->observers[] = array(
'class' => $a_class,
608 'method' => $a_method);
613 foreach($this->observers as $observer)
615 $class =& $observer[
'class'];
618 if(!$class->$method($a_ref_id,$a_data))