Public Member Functions | |
| ilSearchResult ($a_user_id, $a_obj_id=0) | |
| Constructor public. | |
| getUserId () | |
| getType () | |
| setObjId ($a_obj_id) | |
| getObjId () | |
| setTitle ($a_title) | |
| getTitle () | |
| setTarget ($a_target) | |
| getTarget () | |
| createLink () | |
| updateTitle ($a_title) | |
| __init () | |
| 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 () | |
| 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 () | |
| getUniqueResults () | |
| Get unique results. | |
| getResultsForPresentation () | |
| filter ($a_root_node, $check_and) | |
| 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 | |
| $ilias | |
| $title | |
| $obj_id | |
| $user_id | |
| $target | |
| $permission = 'visible' | |
| $entries = array() | |
| $results = array() | |
| $observers = array() | |
| $ilAccess | |
| $limit_reached = false | |
| $result | |
Definition at line 33 of file class.ilSearchResult.php.
| ilSearchResult::__init | ( | ) |
Definition at line 159 of file class.ilSearchResult.php.
References $query, $res, $row, getObjId(), setTarget(), and setTitle().
Referenced by ilSearchResult().
{
if($this->getObjId())
{
$query = "SELECT * FROM ".TABLE_SEARCH_DATA." ".
"WHERE obj_id = '".$this->getObjId()."' ".
"AND user_id = '".$this->getUserId()."'";
$res = $this->ilias->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setTitle($row->title);
$this->setTarget(unserialize(stripslashes($row->target)));
}
return true;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilSearchResult::__initSearchSettingsObject | ( | ) |
Definition at line 505 of file class.ilSearchResult.php.
Referenced by filter(), and ilSearchResult().
{
include_once 'Services/Search/classes/class.ilSearchSettings.php';
$this->search_settings = new ilSearchSettings();
}
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 468 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 490 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 131 of file class.ilSearchResult.php.
References $counter.
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 521 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 255 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 527 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::createLink | ( | ) |
Definition at line 96 of file class.ilSearchResult.php.
References $target, ilObjUser::_getLinkToObject(), ilObjGroup::_getLinkToObject(), and getTarget().
{
$target = $this->getTarget();
switch($target["type"])
{
case "lm":
include_once "./content/classes/class.ilObjContentObject.php";
if($target["subtype"] == "meta")
{
return list($book["link"],$book["target"]) = ilObjContentObject::_getLinkToObject($target["id"],"meta");
}
else
{
return list($book["link"],$book["target"]) =
ilObjContentObject::_getLinkToObject($target["id"],"content",$target["page_id"]);
}
break;
case "dbk":
include_once "./content/classes/class.ilObjDlBook.php";
if($target["subtype"] == "meta")
{
return list($book["link"],$book["target"]) = ilObjDlBook::_getLinkToObject($target["id"],"meta");
}
else
{
return list($book["link"],$book["target"]) =
ilObjDlBook::_getLinkToObject($target["id"],"content",$target["page_id"]);
}
break;
case "grp":
include_once "./classes/class.ilObjGroup.php";
return list($group["link"],$group["target"]) = ilObjGroup::_getLinkToObject($target["id"]);
case "usr":
include_once "./classes/class.ilObjUser.php";
return list($group["link"],$group["target"]) = ilObjUser::_getLinkToObject($target["id"]);
}
}
Here is the call 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 200 of file class.ilSearchResult.php.
References $obj_id, $result, __updateEntryChilds(), addEntry(), and getEntries().
{
$new_entries = $this->getEntries();
$this->entries = array();
foreach($result_obj->getResults() as $result)
{
$obj_id = $result['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 | |||
| ) |
Definition at line 320 of file class.ilSearchResult.php.
References $counter, $ref_id, $tree, $type, __initSearchSettingsObject(), __updateResultChilds(), ilObject::_getAllReferences(), ilObject::_lookupType(), addResult(), callListeners(), getEntries(), getMaxHits(), and getRequiredPermission().
{
global $tree;
$this->__initSearchSettingsObject();
// get ref_ids and check access
$counter = 0;
foreach($this->getEntries() as $entry)
{
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;
}
// Rbac objects
foreach(ilObject::_getAllReferences($entry['obj_id']) as $ref_id)
{
$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->__updateResultChilds($ref_id,$entry['child']);
$counter += count($entry['child']);
// Stop if maximum of hits is reached
if(++$counter > $this->getMaxHits())
{
$this->limit_reached = true;
return true;
}
}
}
}
}
}
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 392 of file class.ilSearchResult.php.
References $result, $tree, __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 101 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 115 of file class.ilSearchResult.php.
Referenced by filter().
{
return $this->max_hits;
}
Here is the caller graph for this function:| ilSearchResult::getObjId | ( | ) |
Definition at line 75 of file class.ilSearchResult.php.
Referenced by __init().
{
return $this->obj_id;
}
Here is the caller graph for this function:| ilSearchResult::getRequiredPermission | ( | ) |
Definition at line 86 of file class.ilSearchResult.php.
Referenced by filter().
{
return $this->permission;
}
Here is the caller graph for this function:| ilSearchResult::getResults | ( | ) |
Definition at line 262 of file class.ilSearchResult.php.
Referenced by filterResults(), getResultsForPresentation(), and save().
{
return $this->results ? $this->results : array();
}
Here is the caller graph for this function:| ilSearchResult::getResultsForPresentation | ( | ) |
Definition at line 289 of file class.ilSearchResult.php.
References $result, $title, $type, 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::getTarget | ( | ) |
Definition at line 91 of file class.ilSearchResult.php.
Referenced by createLink().
{
return $this->target;
}
Here is the caller graph for this function:| ilSearchResult::getTitle | ( | ) |
Definition at line 83 of file class.ilSearchResult.php.
{
return $this->title;
}
| ilSearchResult::getType | ( | ) |
Definition at line 67 of file class.ilSearchResult.php.
{
return "sea";
}
| 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 274 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 96 of file class.ilSearchResult.php.
{
return $this->user_id;
}
| ilSearchResult::getUserId | ( | ) |
Definition at line 62 of file class.ilSearchResult.php.
Referenced by read(), and save().
{
return $this->user_id;
}
Here is the caller graph for this function:| ilSearchResult::ilSearchResult | ( | $ | a_user_id, | |
| $ | a_obj_id = 0 | |||
| ) |
Constructor public.
Definition at line 47 of file class.ilSearchResult.php.
References $ilias, and __init().
{
global $ilias;
define("TABLE_SEARCH_DATA","search_data");
$this->ilias =& $ilias;
$this->obj_id = $a_obj_id;
$this->user_id = $a_user_id;
$this->__init();
}
Here is the call graph for this function:| ilSearchResult::ilSearchResult | ( | $ | a_user_id = 0 |
) |
Constructor public.
Definition at line 58 of file class.ilSearchResult.php.
References $ilAccess, $ilias, __initSearchSettingsObject(), and setMaxHits().
{
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->setMaxHits($this->search_settings->getMaxHits());
$this->db =& $ilDB;
}
Here is the call 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 225 of file class.ilSearchResult.php.
References $obj_id, __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 106 of file class.ilSearchResult.php.
{
return $this->limit_reached ? true : false;
}
| ilSearchResult::mergeEntries | ( | &$ | result_obj | ) |
merge entries of this instance and another result object
| object | result_obj public |
Definition at line 183 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 172 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 442 of file class.ilSearchResult.php.
References $query, $res, $row, and getUserId().
{
if($this->getUserId() and $this->getUserId() != ANONYMOUS_USER_ID)
{
$query = "SELECT search_result FROM usr_search ".
"WHERE usr_id = '".$this->getUserId()."' ".
"AND search_type = '".$a_type."'";
$res = $this->db->query($query);
if($res->numRows())
{
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
$this->results = unserialize(stripslashes($row->search_result));
}
}
}
Here is the call graph for this function:| ilSearchResult::save | ( | $ | a_type = DEFAULT_SEARCH |
) |
Save search results.
| integer | DEFAULT_SEARCH or ADVANCED_SEARCH public |
Definition at line 417 of file class.ilSearchResult.php.
References $query, $res, getResults(), and getUserId().
{
if ($this->getUserId() and $this->getUserId() != ANONYMOUS_USER_ID)
{
$query = "DELETE FROM usr_search WHERE usr_id = '".$this->getUserId()."' ".
"AND search_type = '".$a_type."'";
$this->db->query($query);
$query = "INSERT INTO usr_search ".
"VALUES('".$this->getUserId()."','".addslashes(serialize($this->getResults()))."','".$a_type."')";
$res = $this->db->query($query);
return true;
}
return false;
}
Here is the call graph for this function:| ilSearchResult::setMaxHits | ( | $ | a_max_hits | ) |
Definition at line 111 of file class.ilSearchResult.php.
Referenced by ilSearchResult().
{
$this->max_hits = $a_max_hits;
}
Here is the caller graph for this function:| ilSearchResult::setObjId | ( | $ | a_obj_id | ) |
Definition at line 71 of file class.ilSearchResult.php.
{
$this->obj_id = $a_obj_id;
}
| ilSearchResult::setRequiredPermission | ( | $ | a_permission | ) |
Set the required permission for the rbac checks in function 'filter()'.
Definition at line 81 of file class.ilSearchResult.php.
{
$this->permission = $a_permission;
}
| ilSearchResult::setTarget | ( | $ | a_target | ) |
Definition at line 87 of file class.ilSearchResult.php.
Referenced by __init().
{
$this->target = $a_target;
}
Here is the caller graph for this function:| ilSearchResult::setTitle | ( | $ | a_title | ) |
Definition at line 79 of file class.ilSearchResult.php.
Referenced by __init().
{
$this->title = $a_title;
}
Here is the caller graph for this function:| ilSearchResult::setUserId | ( | $ | a_user_id | ) |
Definition at line 92 of file class.ilSearchResult.php.
{
$this->user_id = $a_user_id;
}
| ilSearchResult::updateTitle | ( | $ | a_title | ) |
Definition at line 145 of file class.ilSearchResult.php.
| ilSearchResult::$entries = array() |
Definition at line 41 of file class.ilSearchResult.php.
| ilSearchResult::$ilAccess |
Definition at line 47 of file class.ilSearchResult.php.
Referenced by ilSearchResult().
| ilSearchResult::$ilias |
Definition at line 36 of file class.ilSearchResult.php.
Referenced by ilSearchResult().
| ilSearchResult::$limit_reached = false |
Definition at line 50 of file class.ilSearchResult.php.
| ilSearchResult::$obj_id |
Definition at line 39 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), and intersectEntries().
| ilSearchResult::$observers = array() |
Definition at line 43 of file class.ilSearchResult.php.
| ilSearchResult::$permission = 'visible' |
Definition at line 38 of file class.ilSearchResult.php.
| ilSearchResult::$result |
Definition at line 53 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), filterResults(), getResultsForPresentation(), and getUniqueResults().
| ilSearchResult::$results = array() |
Definition at line 42 of file class.ilSearchResult.php.
| ilSearchResult::$target |
Definition at line 41 of file class.ilSearchResult.php.
Referenced by createLink().
| ilSearchResult::$title |
Definition at line 38 of file class.ilSearchResult.php.
Referenced by getResultsForPresentation().
| ilSearchResult::$user_id |
Definition at line 40 of file class.ilSearchResult.php.
1.7.1