Class for storing search result. More...
Collaboration diagram for ilUserSearchCache:Public Member Functions | |
| switchSearchType ($a_type) | |
| switch to search type reads entries from database | |
| getResults () | |
| Get results. | |
| setResults ($a_results) | |
| Set results. | |
| addResult ($a_result_item) | |
| Append result. | |
| appendToFailed ($a_ref_id) | |
| Append failed id. | |
| isFailed ($a_ref_id) | |
| check if reference has failed access | |
| appendToChecked ($a_ref_id, $a_obj_id) | |
| Append checked id. | |
| isChecked ($a_ref_id) | |
| Check if reference was already checked. | |
| getCheckedItems () | |
| Get all checked items. | |
| setResultPageNumber ($a_number) | |
| Set result page number. | |
| getResultPageNumber () | |
| get result page number | |
| delete () | |
| Delete user entries. | |
| save () | |
| Save entries. | |
Static Public Member Functions | |
| static | _getInstance ($a_usr_id) |
| Get singleton instance. | |
Data Fields | |
| const | DEFAULT_SEARCH = 0 |
| const | ADVANCED_SEARCH = 1 |
| const | ADVANCED_MD_SEARCH = 4 |
Private Member Functions | |
| __construct ($a_usr_id) | |
| Constructor. | |
| read () | |
| Read user entries. | |
Private Attributes | |
| $db | |
| $usr_id | |
| $search_type = self::DEFAULT_SEARCH | |
| $search_result = array() | |
| $checked = array() | |
| $failed = array() | |
| $page_number = 1 | |
Static Private Attributes | |
| static | $instance = null |
Class for storing search result.
Allows paging of result sets
Definition at line 35 of file class.ilUserSearchCache.php.
| ilUserSearchCache::__construct | ( | $ | a_usr_id | ) | [private] |
Constructor.
private
Definition at line 59 of file class.ilUserSearchCache.php.
References read().
{
global $ilDB;
$this->db = $ilDB;
$this->usr_id = $a_usr_id;
$this->search_type = self::DEFAULT_SEARCH;
$this->read();
}
Here is the call graph for this function:| static ilUserSearchCache::_getInstance | ( | $ | a_usr_id | ) | [static] |
Get singleton instance.
public
| int | usr_id |
Definition at line 77 of file class.ilUserSearchCache.php.
Referenced by ilSearchResultPresentationGUI::ilSearchResultPresentationGUI(), ilSearchResult::initUserSearchCache(), ilSearchGUI::initUserSearchCache(), and ilAdvancedSearchGUI::initUserSearchCache().
{
if(is_object(self::$instance) and self::$instance)
{
return self::$instance;
}
return self::$instance = new ilUserSearchCache($a_usr_id);
}
Here is the caller graph for this function:| ilUserSearchCache::addResult | ( | $ | a_result_item | ) |
Append result.
public
| array(int,int,string) | array(ref_id,obj_id,type) |
Definition at line 131 of file class.ilUserSearchCache.php.
{
$this->search_result[$a_result_item['ref_id']]['ref_id'] = $a_result_item['ref_id'];
$this->search_result[$a_result_item['ref_id']]['obj_id'] = $a_result_item['obj_id'];
$this->search_result[$a_result_item['ref_id']]['type'] = $a_result_item['type'];
return true;
}
| ilUserSearchCache::appendToChecked | ( | $ | a_ref_id, | |
| $ | a_obj_id | |||
| ) |
Append checked id.
public
| int | checked reference id | |
| int | checked obj_id |
Definition at line 171 of file class.ilUserSearchCache.php.
{
$this->checked[$a_ref_id] = $a_obj_id;
}
| ilUserSearchCache::appendToFailed | ( | $ | a_ref_id | ) |
Append failed id.
public
| int | ref_id of failed access |
Definition at line 146 of file class.ilUserSearchCache.php.
{
$this->failed[$a_ref_id] = $a_ref_id;
}
| ilUserSearchCache::delete | ( | ) |
Delete user entries.
public
Definition at line 231 of file class.ilUserSearchCache.php.
{
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id)." ".
"AND search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
$this->read();
return true;
}
Here is the call graph for this function:| ilUserSearchCache::getCheckedItems | ( | ) |
Get all checked items.
public
Definition at line 195 of file class.ilUserSearchCache.php.
{
return $this->checked ? $this->checked : array();
}
| ilUserSearchCache::getResultPageNumber | ( | ) |
get result page number
public
Definition at line 220 of file class.ilUserSearchCache.php.
{
return $this->page_number ? $this->page_number : 1;
}
| ilUserSearchCache::getResults | ( | ) |
Get results.
public
Definition at line 107 of file class.ilUserSearchCache.php.
{
return $this->search_result ? $this->search_result : array();
}
| ilUserSearchCache::isChecked | ( | $ | a_ref_id | ) |
Check if reference was already checked.
public
| int | ref_id |
Definition at line 183 of file class.ilUserSearchCache.php.
{
return array_key_exists($a_ref_id,$this->checked) and $this->checked[$a_ref_id];
}
| ilUserSearchCache::isFailed | ( | $ | a_ref_id | ) |
check if reference has failed access
public
| int | ref_id |
Definition at line 158 of file class.ilUserSearchCache.php.
{
return in_array($a_ref_id,$this->failed) ? true : false;
}
| ilUserSearchCache::read | ( | ) | [private] |
Read user entries.
private
Definition at line 277 of file class.ilUserSearchCache.php.
References $res.
Referenced by __construct(), delete(), and switchSearchType().
{
$this->failed = array();
$this->checked = array();
$this->search_result = array();
$this->page_number = 0;
if($this->usr_id == ANONYMOUS_USER_ID)
{
return false;
}
$query = "SELECT * FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id)." ".
"AND search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->search_result = unserialize(stripslashes($row->search_result));
if(strlen($row->checked))
{
$this->checked = unserialize(stripslashes($row->checked));
}
if(strlen($row->failed))
{
$this->failed = unserialize(stripslashes($row->failed));
}
$this->page_number = $row->page;
}
return true;
}
Here is the caller graph for this function:| ilUserSearchCache::save | ( | ) |
Save entries.
public
Definition at line 248 of file class.ilUserSearchCache.php.
References $res.
{
if($this->usr_id == ANONYMOUS_USER_ID)
{
return false;
}
$query = "DELETE FROM usr_search ".
"WHERE usr_id = ".$this->db->quote($this->usr_id)." ".
"AND search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
$query = "INSERT INTO usr_search ".
"SET usr_id = ".$this->db->quote($this->usr_id).", ".
"search_result = '".addslashes(serialize($this->search_result))."', ".
"checked = '".addslashes(serialize($this->checked))."', ".
"failed = '".addslashes(serialize($this->failed))."', ".
"page = ".$this->db->quote($this->page_number).", ".
"search_type = ".$this->db->quote($this->search_type);
$res = $this->db->query($query);
}
| ilUserSearchCache::setResultPageNumber | ( | $ | a_number | ) |
Set result page number.
public
Definition at line 206 of file class.ilUserSearchCache.php.
{
if($a_number)
{
$this->page_number = $a_number;
}
}
| ilUserSearchCache::setResults | ( | $ | a_results | ) |
Set results.
public
| array(int | => array(int,int,string)) array(ref_id => array(ref_id,obj_id,type)) |
Definition at line 119 of file class.ilUserSearchCache.php.
{
$this->search_result = $a_results;
}
| ilUserSearchCache::switchSearchType | ( | $ | a_type | ) |
switch to search type reads entries from database
public
| int | search type |
Definition at line 94 of file class.ilUserSearchCache.php.
References read().
{
$this->search_type = $a_type;
$this->read();
return true;
}
Here is the call graph for this function:ilUserSearchCache::$checked = array() [private] |
Definition at line 48 of file class.ilUserSearchCache.php.
ilUserSearchCache::$db [private] |
Definition at line 42 of file class.ilUserSearchCache.php.
ilUserSearchCache::$failed = array() [private] |
Definition at line 49 of file class.ilUserSearchCache.php.
ilUserSearchCache::$instance = null [static, private] |
Definition at line 41 of file class.ilUserSearchCache.php.
ilUserSearchCache::$page_number = 1 [private] |
Definition at line 50 of file class.ilUserSearchCache.php.
ilUserSearchCache::$search_result = array() [private] |
Definition at line 47 of file class.ilUserSearchCache.php.
ilUserSearchCache::$search_type = self::DEFAULT_SEARCH [private] |
Definition at line 45 of file class.ilUserSearchCache.php.
ilUserSearchCache::$usr_id [private] |
Definition at line 44 of file class.ilUserSearchCache.php.
| const ilUserSearchCache::ADVANCED_MD_SEARCH = 4 |
Definition at line 39 of file class.ilUserSearchCache.php.
Referenced by ilAdvancedSearchGUI::initSearchType().
| const ilUserSearchCache::ADVANCED_SEARCH = 1 |
Definition at line 38 of file class.ilUserSearchCache.php.
Referenced by ilAdvancedSearchGUI::initSearchType(), and ilAdvancedSearchGUI::initUserSearchCache().
| const ilUserSearchCache::DEFAULT_SEARCH = 0 |
Definition at line 37 of file class.ilUserSearchCache.php.
1.7.1