ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilShopSearchResult Class Reference

searchResult stores all result of a search query. More...

+ Inheritance diagram for ilShopSearchResult:
+ Collaboration diagram for ilShopSearchResult:

Public Member Functions

 ilShopSearchResult ($a_search_type)
 setSearchType ($_search_type)
 getSearchType ()
 filter ($a_root_node, $check_and)
 Filter search result.
 __initSearchSettingsObject ()
 getResultsForPresentation ()
 getTopics ()
 setTopics ($a_topics=array())
 setResultPageNumber ($a_result_page_number)
 getResultPageNumber ()
 addPresentationResult ($a_presentation_result=array())
 getPresentationResults ()
 addEntry ($a_ref_id, $a_type, $found, $a_child_id=0)
 add search result entry Entries are stored with 'obj_id'.
 __updateEntryChilds ($a_ref_id, $a_childs)
 Update childs for a specific entry.
 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
 getUniqueResults ()
 Get unique results.
- Public Member Functions inherited from ilSearchResult
 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.
 numEntries ()
 Check number of entries public.
 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 ()
 getResultIds ()
 get result ids
 getResultsByObjId ()
 getSubitemIds ()
 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
 __updateResultChilds ($a_ref_id, $a_childs)
 Update childs for a specific result.
 preventOverwritingMaxhits ($a_flag=null)
 If you call this function and pass "true" the maxhits setting will not be overwritten in __initSearchSettingsObject()
 addObserver (&$a_class, $a_method)
 The observer is used to call functions for filtering result.
 callListeners ($a_ref_id, &$a_data)

Protected Member Functions

 assignEntries ($a_entries)
 initUserSearchCache ()
 Init user search cache.

Protected Attributes

 $result_page_number = 0
 $topics = array()
 $presentation_results = array()
 $search_type = ''
- Protected Attributes inherited from ilSearchResult
 $search_cache = null
 $offset = 0
 $preventOverwritingMaxhits = false

Additional Inherited Members

- Data Fields inherited from ilSearchResult
 $permission = 'visible'
 $user_id
 $entries = array()
 $results = array()
 $observers = array()
 $ilias
 $ilAccess
 $limit_reached = false
 $result

Detailed Description

searchResult stores all result of a search query.

Offers methods like mergeResults. To merge result sets of different queries.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id:$

Definition at line 16 of file class.ilShopSearchResult.php.

Member Function Documentation

ilShopSearchResult::__initSearchSettingsObject ( )

Reimplemented from ilSearchResult.

Definition at line 144 of file class.ilShopSearchResult.php.

References ilPaymentSettings\_getInstance(), and ilSearchResult\setMaxHits().

Referenced by filter().

{
include_once 'Services/Payment/classes/class.ilPaymentSettings.php';
$maxhits = ilPaymentSettings::_getInstance()->get('max_hits');
$this->setMaxHits(($maxhits > 0 ? $maxhits : 20));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilShopSearchResult::__updateEntryChilds (   $a_obj_id,
  $a_childs 
)

Update childs for a specific entry.

Parameters
integerobject object_id
arrayarray of child ids. E.g 'pg', 'st' private

Reimplemented from ilSearchResult.

Definition at line 396 of file class.ilShopSearchResult.php.

Referenced by diffEntriesFromResult(), and mergeEntries().

{
if($this->entries[$a_ref_id] and is_array($a_childs))
{
foreach($a_childs as $child_id)
{
if($child_id)
{
$this->entries[$a_ref_id]['child'][$child_id] = $child_id;
}
}
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilShopSearchResult::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.

Parameters
integerobject object_id
stringobj_type 'lm' or 'crs' ...
arrayvalue position of query parser words in query string
integerchild id e.g id of page or chapter public

Reimplemented from ilSearchResult.

Definition at line 355 of file class.ilShopSearchResult.php.

Referenced by diffEntriesFromResult(), and mergeEntries().

{
global $ilObjDataCache;
$a_obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
// Create new entry if it not exists
if(!$this->entries[$a_ref_id])
{
$this->entries[$a_ref_id]['ref_id'] = $a_ref_id;
$this->entries[$a_ref_id]['obj_id'] = $a_obj_id;
$this->entries[$a_ref_id]['type'] = $a_type;
$this->entries[$a_ref_id]['found'] = $found;
if($a_child_id and $a_child_id != $a_ref_id)
{
$this->entries[$a_ref_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_ref_id]['child'][$a_child_id] = $a_child_id;
}
// UPDATE FOUND
$counter = 0;
foreach($found as $position)
{
if($position)
{
$this->entries[$a_ref_id]['found'][$counter] = $position;
}
$counter++;
}
}
return true;
}

+ Here is the caller graph for this function:

ilShopSearchResult::addPresentationResult (   $a_presentation_result = array())

Definition at line 339 of file class.ilShopSearchResult.php.

Referenced by getResultsForPresentation().

{
$this->presentation_results[] = $a_presentation_result;
}

+ Here is the caller graph for this function:

ilShopSearchResult::assignEntries (   $a_entries)
protected

Definition at line 44 of file class.ilShopSearchResult.php.

Referenced by filter().

{
$ordered_entries = array();
$num_entries = count($a_entries);
foreach($this->topics as $oTopic)
{
foreach($a_entries as $aEntry)
{
if($oTopic->getId() == $aEntry['topic_id'])
{
$ordered_entries[$aEntry['ref_id']] = $aEntry;
}
}
}
if(count($ordered_entries) < $num_entries)
{
foreach($a_entries as $aEntry)
{
if(0 == $aEntry['topic_id'])
{
$ordered_entries[$aEntry['ref_id']] = $aEntry;
}
}
}
return is_array($ordered_entries) ? $ordered_entries : array();
}

+ Here is the caller graph for this function:

ilShopSearchResult::diffEntriesFromResult ( $result_obj)

diff entries of this instance and another result object Used for search in results

Parameters
objectresult_obj public

Reimplemented from ilSearchResult.

Definition at line 422 of file class.ilShopSearchResult.php.

References $ref_id, __updateEntryChilds(), addEntry(), and ilSearchResult\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[$ref_id]))
{
$this->addEntry($new_entries[$ref_id]['ref_id'],
$new_entries[$ref_id]['type'],
$new_entries[$ref_id]['found']);
$this->__updateEntryChilds($new_entries[$ref_id]['ref_id'],
$new_entries[$ref_id]['child']);
}
}
}

+ Here is the call graph for this function:

ilShopSearchResult::filter (   $a_root_node,
  $check_and 
)

Filter search result.

Do RBAC checks.

Allows paging of results for referenced objects

public

Parameters
inta_root_node node id
boolcheck_and and boolean search
Returns
bool success status

Reimplemented from ilSearchResult.

Definition at line 85 of file class.ilShopSearchResult.php.

References $ref_id, __initSearchSettingsObject(), ilSearchResult\__updateResultChilds(), ilPaymentObject\_lookupTopicId(), ilObject\_lookupType(), ilSearchResult\addResult(), assignEntries(), ilSearchResult\callListeners(), ilSearchResult\getEntries(), and ilSearchResult\getRequiredPermission().

{
global $tree;
// get ref_ids and check access
$tmp_entries = array();
foreach($this->getEntries() as $ref_id => $entry)
{
// boolean and failed continue
if($check_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')
{
continue;
}
// Check access
if($this->ilAccess->checkAccessOfUser($this->getUserId(),
'',
{
if($a_root_node == ROOT_FOLDER_ID || $tree->isGrandChild($a_root_node, $ref_id))
{
if($this->callListeners($ref_id, $entry))
{
$entry['ref_id'] = $ref_id;
$entry['type'] = $type;
$tmp_entries[$ref_id] = $entry;
}
}
}
}
$this->results = array();
$tmp_entries = $this->assignEntries($tmp_entries);
foreach($tmp_entries as $entry)
{
if($this->callListeners($entry['ref_id'], $entry))
{
$this->addResult($entry['ref_id'], $entry['obj_id'], $entry['type']);
$this->search_cache->appendToChecked($entry['ref_id'], $entry['obj_id']);
$this->__updateResultChilds($entry['ref_id'], $entry['child']);
}
}
$this->search_cache->setResults($this->results);
return false;
}

+ Here is the call graph for this function:

ilShopSearchResult::getPresentationResults ( )

Definition at line 343 of file class.ilShopSearchResult.php.

{
return is_array($this->presentation_results) ? $this->presentation_results : array();
}
ilShopSearchResult::getResultPageNumber ( )

Definition at line 334 of file class.ilShopSearchResult.php.

References $result_page_number.

Referenced by getResultsForPresentation().

+ Here is the caller graph for this function:

ilShopSearchResult::getResultsForPresentation ( )

Reimplemented from ilSearchResult.

Definition at line 151 of file class.ilShopSearchResult.php.

References $_GET, $lng, $presentation_results, ilSearchResult\$result, ilSearchResult\$results, ilPaymentObject\_checkExcSubtype(), ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilPaymentObject\_lookupTopicId(), addPresentationResult(), ilSearchResult\getMaxHits(), getResultPageNumber(), ilSearchResult\getResults(), and getTopics().

{
global $lng, $tree;
$results = array();
$offset_counter = 0;
$counter = 0;
$objects_with_topics = array();
$objects_with_no_topcis = array();
$objects_of_subtree = array();
foreach($this->getResults() as $result)
{
if($this->getMaxHits() * ($this->getResultPageNumber() - 1) > $offset_counter)
{
++$offset_counter;
continue;
}
++$counter;
if($counter >= $this->getMaxHits())
{
break;
}
}
if($_GET['tree_ref_id'])
{
foreach($results as $result)
{
$tree_ref_id = $_GET['tree_ref_id'];
$parent_id = $tree->getParentId($result['ref_id']);
if($tree_ref_id == $parent_id)
{
$objects_of_subtree[$result['ref_id']] = $result;
}
foreach($objects_of_subtree 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_results[0][$type][] = array('ref_id' => $result['ref_id'],
'title' => $title,
'description' => $description,
'type' => $result['type'],
'obj_id' => $result['obj_id'],
'child' => $result['child']);
$this->addPresentationResult($presentation_results[0][$type][count($presentation_results[0][$type]) - 1]);
}
}
}
else
{
foreach($this->getTopics() as $oTopic)
{
foreach($results as $result)
{
$topic_id = ilPaymentObject::_lookupTopicId($result['ref_id']);
// $parent_id = $tree->getParentId($result['ref_id']);
if(!(int)$topic_id && !array_key_exists($result['ref_id'], $objects_with_no_topcis))
{
$objects_with_no_topcis[$result['ref_id']] = $result;
continue;
}
if((int)$topic_id != $oTopic->getId())
{
continue;
}
if(!array_key_exists($result['ref_id'], $objects_with_topics))
{
$objects_with_topics[$result['ref_id']] = $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']);
$subtype = '';
if($result['type'] == 'exc')
{
$check_sub = ilPaymentObject::_checkExcSubtype($result['ref_id']);
$subtype = ' ('.$lng->txt($check_sub[0]).')';
}
$presentation_results[$oTopic->getId()][$type][] = array('ref_id' => $result['ref_id'],
'title' => $title.' '.$subtype,
'description' => $description,
'type' => $result['type'],
'obj_id' => $result['obj_id'],
'topic_id' => $topic_id,
'child' => $result['child']);
$this->addPresentationResult($presentation_results[$oTopic->getId()][$type][count($presentation_results[$oTopic->getId()][$type]) - 1]);
}
}
foreach($results as $result)
{
if(!array_key_exists($result['ref_id'], $objects_with_topics) &&
!array_key_exists($result['ref_id'], $objects_with_no_topcis))
{
$objects_with_no_topcis[$result['ref_id']] = $result;
}
}
foreach($objects_with_no_topcis 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_results[0][$type][] = array('ref_id' => $result['ref_id'],
'title' => $title,
'description' => $description,
'type' => $result['type'],
'obj_id' => $result['obj_id'],
'child' => $result['child']);
$this->addPresentationResult($presentation_results[0][$type][count($presentation_results[0][$type]) - 1]);
}
}
}

+ Here is the call graph for this function:

ilShopSearchResult::getSearchType ( )

Definition at line 39 of file class.ilShopSearchResult.php.

References $search_type.

{
}
ilShopSearchResult::getTopics ( )

Definition at line 321 of file class.ilShopSearchResult.php.

Referenced by getResultsForPresentation().

{
return is_array($this->topics) ? $this->topics : array();
}

+ Here is the caller graph for this function:

ilShopSearchResult::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

Reimplemented from ilSearchResult.

Definition at line 441 of file class.ilShopSearchResult.php.

References ilSearchResult\$results.

{
}
ilShopSearchResult::ilShopSearchResult (   $a_search_type)

Definition at line 23 of file class.ilShopSearchResult.php.

References $ilUser.

{
global $ilUser;
$this->search_type = $a_search_type;
parent::__construct($ilUser->getId());
}
ilShopSearchResult::initUserSearchCache ( )
protected

Init user search cache.

private

Reimplemented from ilSearchResult.

Definition at line 348 of file class.ilShopSearchResult.php.

{
$this->search_cache->switchSearchType($this->search_type);
}
ilShopSearchResult::mergeEntries ( $result_obj)

merge entries of this instance and another result object

Parameters
objectresult_obj public

Reimplemented from ilSearchResult.

Definition at line 412 of file class.ilShopSearchResult.php.

References __updateEntryChilds(), and addEntry().

{
foreach($result_obj->getEntries() as $entry)
{
$this->addEntry($entry['ref_id'],$entry['type'],$entry['found']);
$this->__updateEntryChilds($entry['ref_id'],$entry['child']);
}
return true;
}

+ Here is the call graph for this function:

ilShopSearchResult::setResultPageNumber (   $a_result_page_number)

Definition at line 330 of file class.ilShopSearchResult.php.

{
$this->result_page_number = (int)$a_result_page_number > 0 ? $a_result_page_number : 1;
}
ilShopSearchResult::setSearchType (   $_search_type)

Definition at line 32 of file class.ilShopSearchResult.php.

{
$this->search_type = $_search_type;
return $this;
}
ilShopSearchResult::setTopics (   $a_topics = array())

Definition at line 325 of file class.ilShopSearchResult.php.

{
$this->topics = $a_topics;
}

Field Documentation

ilShopSearchResult::$presentation_results = array()
protected

Definition at line 20 of file class.ilShopSearchResult.php.

Referenced by getResultsForPresentation().

ilShopSearchResult::$result_page_number = 0
protected

Definition at line 18 of file class.ilShopSearchResult.php.

Referenced by getResultPageNumber().

ilShopSearchResult::$search_type = ''
protected

Definition at line 21 of file class.ilShopSearchResult.php.

Referenced by getSearchType().

ilShopSearchResult::$topics = array()
protected

Definition at line 19 of file class.ilShopSearchResult.php.


The documentation for this class was generated from the following file: