Public Member Functions | |
| ilSearchResult ($a_user_id=0) | |
| Constructor public. | |
| setRequiredPermission ($a_permission) | |
| Set the required permission for the rbac checks in function 'filter()'. | |
| getRequiredPermission () | |
| setUserId ($a_user_id) | |
| getUserId () | |
| getEntries () | |
| isLimitReached () | |
| setMaxHits ($a_max_hits) | |
| getMaxHits () | |
| isOffsetReached ($a_counter) | |
| Check if offset is reached. | |
| addEntry ($a_obj_id, $a_type, $found, $a_child_id=0) | |
| add search result entry Entries are stored with 'obj_id'. | |
| numEntries () | |
| Check number of entries public. | |
| mergeEntries (&$result_obj) | |
| merge entries of this instance and another result object | |
| diffEntriesFromResult (&$result_obj) | |
| diff entries of this instance and another result object Used for search in results | |
| intersectEntries (&$result_obj) | |
| Build intersection of entries (all entries that are present in both result sets). | |
| addResult ($a_ref_id, $a_obj_id, $a_type) | |
| add search result Results are stored with 'ref_id'. | |
| getResults () | |
| getResultsByObjId () | |
| getUniqueResults () | |
| Get unique results. | |
| getResultsForPresentation () | |
| filter ($a_root_node, $check_and) | |
| Filter search result. | |
| filterResults ($a_root_node) | |
| Filter search area of result set public. | |
| save ($a_type=DEFAULT_SEARCH) | |
| Save search results. | |
| read ($a_type=DEFAULT_SEARCH) | |
| read search results | |
| __updateEntryChilds ($a_obj_id, $a_childs) | |
| Update childs for a specific entry. | |
| __updateResultChilds ($a_ref_id, $a_childs) | |
| Update childs for a specific result. | |
| __initSearchSettingsObject () | |
| addObserver (&$a_class, $a_method) | |
| The observer is used to call functions for filtering result. | |
| callListeners ($a_ref_id, &$a_data) | |
Data Fields | |
| $permission = 'visible' | |
| $user_id | |
| $entries = array() | |
| $results = array() | |
| $observers = array() | |
| $ilias | |
| $ilAccess | |
| $limit_reached = false | |
| $result | |
Protected Attributes | |
| $search_cache = null | |
| $offset = 0 | |
Private Member Functions | |
| initUserSearchCache () | |
| Init user search cache. | |
Definition at line 40 of file class.ilSearchResult.php.
| ilSearchResult::__initSearchSettingsObject | ( | ) |
Definition at line 533 of file class.ilSearchResult.php.
References setMaxHits().
Referenced by ilSearchResult().
{
include_once 'Services/Search/classes/class.ilSearchSettings.php';
$this->search_settings = new ilSearchSettings();
$this->setMaxHits($this->search_settings->getMaxHits());
#$this->setMaxHits(2);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilSearchResult::__updateEntryChilds | ( | $ | a_obj_id, | |
| $ | a_childs | |||
| ) |
Update childs for a specific entry.
| integer | object object_id | |
| array | array of child ids. E.g 'pg', 'st' private |
Definition at line 496 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), intersectEntries(), and mergeEntries().
{
if($this->entries[$a_obj_id] and is_array($a_childs))
{
foreach($a_childs as $child_id)
{
if($child_id)
{
$this->entries[$a_obj_id]['child'][$child_id] = $child_id;
}
}
return true;
}
return false;
}
Here is the caller graph for this function:| ilSearchResult::__updateResultChilds | ( | $ | a_ref_id, | |
| $ | a_childs | |||
| ) |
Update childs for a specific result.
| integer | object ref_id | |
| array | array of child ids. E.g 'pg', 'st' private |
Definition at line 518 of file class.ilSearchResult.php.
Referenced by filter(), and filterResults().
{
if($this->results[$a_ref_id] and is_array($a_childs))
{
foreach($a_childs as $child_id)
{
$this->results[$a_ref_id]['child'][$child_id] = $child_id;
}
return true;
}
return false;
}
Here is the caller graph for this function:| ilSearchResult::addEntry | ( | $ | a_obj_id, | |
| $ | a_type, | |||
| $ | found, | |||
| $ | a_child_id = 0 | |||
| ) |
add search result entry Entries are stored with 'obj_id'.
This method is typically called to store db query results.
| integer | object object_id | |
| string | obj_type 'lm' or 'crs' ... | |
| array | value position of query parser words in query string | |
| integer | child id e.g id of page or chapter public |
Definition at line 147 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), intersectEntries(), and mergeEntries().
{
// Create new entry if it not exists
if(!$this->entries[$a_obj_id])
{
$this->entries[$a_obj_id]['obj_id'] = $a_obj_id;
$this->entries[$a_obj_id]['type'] = $a_type;
$this->entries[$a_obj_id]['found'] = $found;
if($a_child_id and $a_child_id != $a_obj_id)
{
$this->entries[$a_obj_id]['child'][$a_child_id] = $a_child_id;
}
}
else
{
// replace or add child ('pg','st') id
if($a_child_id and $a_child_id != $a_obj_id)
{
$this->entries[$a_obj_id]['child'][$a_child_id] = $a_child_id;
}
// UPDATE FOUND
$counter = 0;
foreach($found as $position)
{
if($position)
{
$this->entries[$a_obj_id]['found'][$counter] = $position;
}
$counter++;
}
}
return true;
}
Here is the caller graph for this function:| ilSearchResult::addObserver | ( | &$ | a_class, | |
| $ | a_method | |||
| ) |
The observer is used to call functions for filtering result.
Every callback function should support the following parameters: array of ids. E.g: ref_id = 5,array(obj_id = 1,type = 'crs'), The function should return true or false.
| object | class of callback function | |
| string | name of callback method public |
Definition at line 564 of file class.ilSearchResult.php.
{
$this->observers[] = array('class' => $a_class,
'method' => $a_method);
return true;
}
| ilSearchResult::addResult | ( | $ | a_ref_id, | |
| $ | a_obj_id, | |||
| $ | a_type | |||
| ) |
add search result Results are stored with 'ref_id'.
This method is typically called after checking access of entries.
| integer | ref_id | |
| integer | obj_id | |
| string | obj_type 'lm' or 'crs' ... public |
Definition at line 271 of file class.ilSearchResult.php.
Referenced by filter(), and filterResults().
{
$this->results[$a_ref_id]['ref_id'] = $a_ref_id;
$this->results[$a_ref_id]['obj_id'] = $a_obj_id;
$this->results[$a_ref_id]['type'] = $a_type;
}
Here is the caller graph for this function:| ilSearchResult::callListeners | ( | $ | a_ref_id, | |
| &$ | a_data | |||
| ) |
Definition at line 570 of file class.ilSearchResult.php.
Referenced by filter().
{
foreach($this->observers as $observer)
{
$class =& $observer['class'];
$method = $observer['method'];
if(!$class->$method($a_ref_id,$a_data))
{
return false;
}
}
return true;
}
Here is the caller graph for this function:| ilSearchResult::diffEntriesFromResult | ( | &$ | result_obj | ) |
diff entries of this instance and another result object Used for search in results
| object | result_obj public |
Definition at line 216 of file class.ilSearchResult.php.
References $ref_id, __updateEntryChilds(), addEntry(), and getEntries().
{
$new_entries = $this->getEntries();
$this->entries = array();
// Get all checked objects
foreach($this->search_cache->getCheckedItems() as $ref_id => $obj_id)
{
if(isset($new_entries[$obj_id]))
{
$this->addEntry($new_entries[$obj_id]['obj_id'],
$new_entries[$obj_id]['type'],
$new_entries[$obj_id]['found']);
$this->__updateEntryChilds($new_entries[$obj_id]['obj_id'],
$new_entries[$obj_id]['child']);
}
}
}
Here is the call graph for this function:| ilSearchResult::filter | ( | $ | a_root_node, | |
| $ | check_and | |||
| ) |
Filter search result.
Do RBAC checks.
Allows paging of results for referenced objects
public
| int | root node id | |
| bool | check and boolean search |
Definition at line 358 of file class.ilSearchResult.php.
References $ref_id, __updateResultChilds(), ilObject::_getAllReferences(), ilObject::_lookupType(), addResult(), callListeners(), getEntries(), getMaxHits(), getRequiredPermission(), and isOffsetReached().
{
global $tree;
// get ref_ids and check access
$counter = 0;
$offset_counter = 0;
foreach($this->getEntries() as $entry)
{
// boolean and failed continue
if($check_and and in_array(0,$entry['found']))
{
continue;
}
// Types like role, rolt, user do not need rbac checks
$type = ilObject::_lookupType($entry['obj_id']);
if($type == 'rolt' or $type == 'usr' or $type == 'role')
{
if($this->callListeners($entry['obj_id'],$entry))
{
$this->addResult($entry['obj_id'],$entry['obj_id'],$type);
$counter += count($entry['child']);
// Stop if maximum of hits is reached
if(++$counter > $this->getMaxHits())
{
$this->limit_reached = true;
return true;
}
}
continue;
}
// Check referenced objects
foreach(ilObject::_getAllReferences($entry['obj_id']) as $ref_id)
{
// Failed check: if ref id check is failed by previous search
if($this->search_cache->isFailed($ref_id))
{
continue;
}
// Offset check
if($this->search_cache->isChecked($ref_id) and !$this->isOffsetReached($offset_counter))
{
++$offset_counter;
continue;
}
// RBAC check
$type = ilObject::_lookupType($ref_id, true);
if($this->ilAccess->checkAccessOfUser($this->getUserId(),
$this->getRequiredPermission(),
'',
$ref_id,
$type,
$entry['obj_id']))
{
if($a_root_node == ROOT_FOLDER_ID or $tree->isGrandChild($a_root_node,$ref_id))
{
// Call listeners
if($this->callListeners($ref_id,$entry))
{
$this->addResult($ref_id,$entry['obj_id'],$type);
$this->search_cache->appendToChecked($ref_id,$entry['obj_id']);
$this->__updateResultChilds($ref_id,$entry['child']);
$counter++;
$offset_counter++;
// Stop if maximum of hits is reached
if($counter >= $this->getMaxHits())
{
$this->limit_reached = true;
$this->search_cache->setResults($this->results);
return true;
}
}
}
continue;
}
$this->search_cache->appendToFailed($ref_id);
}
}
$this->search_cache->setResults($this->results);
return false;
}
Here is the call graph for this function:| ilSearchResult::filterResults | ( | $ | a_root_node | ) |
Filter search area of result set public.
Definition at line 447 of file class.ilSearchResult.php.
References $result, __updateResultChilds(), addResult(), and getResults().
{
global $tree;
$tmp_results = $this->getResults();
$this->results = array();
foreach($tmp_results as $result)
{
if($tree->isGrandChild($a_root_node,$result['ref_id']) and $tree->isInTree($result['ref_id']))
{
$this->addResult($result['ref_id'],$result['obj_id'],$result['type']);
$this->__updateResultChilds($result['ref_id'],$result['child']);
}
}
return true;
}
Here is the call graph for this function:| ilSearchResult::getEntries | ( | ) |
Definition at line 106 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), filter(), intersectEntries(), and numEntries().
{
return $this->entries ? $this->entries : array();
}
Here is the caller graph for this function:| ilSearchResult::getMaxHits | ( | ) |
Definition at line 120 of file class.ilSearchResult.php.
Referenced by filter(), and initUserSearchCache().
{
return $this->max_hits;
}
Here is the caller graph for this function:| ilSearchResult::getRequiredPermission | ( | ) |
Definition at line 91 of file class.ilSearchResult.php.
Referenced by filter().
{
return $this->permission;
}
Here is the caller graph for this function:| ilSearchResult::getResults | ( | ) |
Definition at line 278 of file class.ilSearchResult.php.
Referenced by filterResults(), getResultsByObjId(), and getResultsForPresentation().
{
return $this->results ? $this->results : array();
}
Here is the caller graph for this function:| ilSearchResult::getResultsByObjId | ( | ) |
Definition at line 283 of file class.ilSearchResult.php.
References $ref_id, and getResults().
{
$tmp_res = array();
foreach($this->getResults() as $ref_id => $res_data)
{
$tmp_res[$res_data['obj_id']][] = $ref_id;
}
return $tmp_res ? $tmp_res : array();
}
Here is the call graph for this function:| ilSearchResult::getResultsForPresentation | ( | ) |
Definition at line 315 of file class.ilSearchResult.php.
References $result, $title, ilObject::_lookupDescription(), ilObject::_lookupTitle(), and getResults().
{
foreach($this->getResults() as $result)
{
switch($result['type'])
{
// learning material
case "sahs":
case "lm":
case "dbk":
case "htlm":
$type = "lres";
break;
default:
$type = $result['type'];
break;
}
$title = ilObject::_lookupTitle($result['obj_id']);
$description = ilObject::_lookupDescription($result['obj_id']);
$presentation_result[$type][] = array('ref_id' => $result['ref_id'],
'title' => $title,
'description' => $description,
'type' => $result['type'],
'obj_id' => $result['obj_id'],
'child' => $result['child']);
}
return $presentation_result ? $presentation_result : array();
}
Here is the call graph for this function:| ilSearchResult::getUniqueResults | ( | ) |
Get unique results.
Return an array of obj_id (No multiple results for references) Results are stored with 'ref_id'. This method is typically called after checking access of entries. public
Definition at line 300 of file class.ilSearchResult.php.
References $result.
{
$obj_ids = array();
foreach($this->results as $result)
{
if(in_array($result['obj_id'],$obj_ids))
{
continue;
}
$obj_ids[] = $result['obj_id'];
$objects[] = $result;
}
return $objects ? $objects : array();
}
| ilSearchResult::getUserId | ( | ) |
Definition at line 101 of file class.ilSearchResult.php.
Referenced by initUserSearchCache().
{
return $this->user_id;
}
Here is the caller graph for this function:| ilSearchResult::ilSearchResult | ( | $ | a_user_id = 0 |
) |
Constructor public.
Definition at line 64 of file class.ilSearchResult.php.
References $ilAccess, $ilias, __initSearchSettingsObject(), and initUserSearchCache().
{
global $ilias,$ilAccess,$ilDB,$ilUser;
$this->ilAccess =& $ilAccess;
if($a_user_id)
{
$this->user_id = $a_user_id;
}
else
{
$this->user_id = $ilUser->getId();
}
$this->__initSearchSettingsObject();
$this->initUserSearchCache();
$this->db =& $ilDB;
}
Here is the call graph for this function:| ilSearchResult::initUserSearchCache | ( | ) | [private] |
Init user search cache.
private
Definition at line 548 of file class.ilSearchResult.php.
References ilUserSearchCache::_getInstance(), getMaxHits(), and getUserId().
Referenced by ilSearchResult().
{
include_once('Services/Search/classes/class.ilUserSearchCache.php');
$this->search_cache = ilUserSearchCache::_getInstance($this->getUserId());
$this->offset = $this->getMaxHits() * ($this->search_cache->getResultPageNumber() - 1) ;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilSearchResult::intersectEntries | ( | &$ | result_obj | ) |
Build intersection of entries (all entries that are present in both result sets).
| object | result_obj public |
Definition at line 241 of file class.ilSearchResult.php.
References __updateEntryChilds(), addEntry(), and getEntries().
{
$new_entries = $this->getEntries();
$this->entries = array();
foreach($result_obj->getEntries() as $entry)
{
$obj_id = $entry['obj_id'];
if(isset($new_entries[$obj_id]))
{
$this->addEntry($new_entries[$obj_id]['obj_id'],
$new_entries[$obj_id]['type'],
$new_entries[$obj_id]['found']);
$this->__updateEntryChilds($new_entries[$obj_id]['obj_id'],
$new_entries[$obj_id]['child']);
}
}
}
Here is the call graph for this function:| ilSearchResult::isLimitReached | ( | ) |
Definition at line 111 of file class.ilSearchResult.php.
{
return $this->limit_reached ? true : false;
}
| ilSearchResult::isOffsetReached | ( | $ | a_counter | ) |
Check if offset is reached.
public
| int | current counter of result |
Definition at line 132 of file class.ilSearchResult.php.
Referenced by filter().
{
return ($a_counter < $this->offset) ? false : true;
}
Here is the caller graph for this function:| ilSearchResult::mergeEntries | ( | &$ | result_obj | ) |
merge entries of this instance and another result object
| object | result_obj public |
Definition at line 199 of file class.ilSearchResult.php.
References __updateEntryChilds(), and addEntry().
{
foreach($result_obj->getEntries() as $entry)
{
$this->addEntry($entry['obj_id'],$entry['type'],$entry['found']);
$this->__updateEntryChilds($entry['obj_id'],$entry['child']);
}
return true;
}
Here is the call graph for this function:| ilSearchResult::numEntries | ( | ) |
Check number of entries public.
Definition at line 188 of file class.ilSearchResult.php.
References getEntries().
{
return count($this->getEntries());
}
Here is the call graph for this function:| ilSearchResult::read | ( | $ | a_type = DEFAULT_SEARCH |
) |
read search results
| integer | DEFAULT_SEARCH or ADVANCED_SEARCH public |
Definition at line 483 of file class.ilSearchResult.php.
{
$this->results = $this->search_cache->getResults();
}
| ilSearchResult::save | ( | $ | a_type = DEFAULT_SEARCH |
) |
Save search results.
| integer | DEFAULT_SEARCH or ADVANCED_SEARCH public |
Definition at line 472 of file class.ilSearchResult.php.
{
$this->search_cache->save();
return false;
}
| ilSearchResult::setMaxHits | ( | $ | a_max_hits | ) |
Definition at line 116 of file class.ilSearchResult.php.
Referenced by __initSearchSettingsObject().
{
$this->max_hits = $a_max_hits;
}
Here is the caller graph for this function:| ilSearchResult::setRequiredPermission | ( | $ | a_permission | ) |
Set the required permission for the rbac checks in function 'filter()'.
Definition at line 86 of file class.ilSearchResult.php.
{
$this->permission = $a_permission;
}
| ilSearchResult::setUserId | ( | $ | a_user_id | ) |
Definition at line 97 of file class.ilSearchResult.php.
{
$this->user_id = $a_user_id;
}
| ilSearchResult::$entries = array() |
Definition at line 45 of file class.ilSearchResult.php.
| ilSearchResult::$ilAccess |
Definition at line 54 of file class.ilSearchResult.php.
Referenced by ilSearchResult().
| ilSearchResult::$ilias |
Definition at line 53 of file class.ilSearchResult.php.
Referenced by ilSearchResult().
| ilSearchResult::$limit_reached = false |
Definition at line 57 of file class.ilSearchResult.php.
| ilSearchResult::$observers = array() |
Definition at line 47 of file class.ilSearchResult.php.
ilSearchResult::$offset = 0 [protected] |
Definition at line 50 of file class.ilSearchResult.php.
| ilSearchResult::$permission = 'visible' |
Definition at line 42 of file class.ilSearchResult.php.
| ilSearchResult::$result |
Definition at line 58 of file class.ilSearchResult.php.
Referenced by filterResults(), getResultsForPresentation(), and getUniqueResults().
| ilSearchResult::$results = array() |
Definition at line 46 of file class.ilSearchResult.php.
ilSearchResult::$search_cache = null [protected] |
Definition at line 49 of file class.ilSearchResult.php.
| ilSearchResult::$user_id |
Definition at line 44 of file class.ilSearchResult.php.
1.7.1