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. | |
| setUserId ($a_user_id) | |
| getUserId () | |
| getEntries () | |
| isLimitReached () | |
| 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 () | |
| 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 () | |
Data Fields | |
| $ilias | |
| $title | |
| $obj_id | |
| $user_id | |
| $target | |
| $entries = 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 418 of file class.ilSearchResult.php.
Referenced by filter().
{
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 381 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 403 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 94 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::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 218 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::createLink | ( | ) |
Definition at line 96 of file class.ilSearchResult.php.
References $target, ilObjUser::_getLinkToObject(), ilObjGroup::_getLinkToObject(), ilObjContentObject::_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 163 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 261 of file class.ilSearchResult.php.
References $counter, $ref_id, $tree, $type, __initSearchSettingsObject(), __updateResultChilds(), ilObject::_getAllReferences(), ilObject::_lookupType(), addResult(), and getEntries().
{
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;
}
foreach(ilObject::_getAllReferences($entry['obj_id']) as $ref_id)
{
$type = ilObject::_lookupType($ref_id, true);
if($this->ilAccess->checkAccess('visible','',$ref_id,$type,$entry['obj_id']))
{
if($a_root_node == ROOT_FOLDER_ID or $tree->isGrandChild($a_root_node,$ref_id))
{
$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->search_settings->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 305 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 72 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::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::getResults | ( | ) |
Definition at line 225 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 230 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::getUserId | ( | ) |
Definition at line 67 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 = 0 |
) |
| 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::intersectEntries | ( | &$ | result_obj | ) |
Build intersection of entries (all entries that are present in both result sets).
| object | result_obj public |
Definition at line 188 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 77 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 146 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 135 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 355 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 330 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::setObjId | ( | $ | a_obj_id | ) |
Definition at line 71 of file class.ilSearchResult.php.
{
$this->obj_id = $a_obj_id;
}
| 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 63 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 39 of file class.ilSearchResult.php.
| ilSearchResult::$ilAccess |
Definition at line 43 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 46 of file class.ilSearchResult.php.
| ilSearchResult::$obj_id |
Definition at line 39 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), and intersectEntries().
| ilSearchResult::$result |
Definition at line 49 of file class.ilSearchResult.php.
Referenced by diffEntriesFromResult(), filterResults(), and getResultsForPresentation().
| 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