ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRepositoryObjectDetailSearch Class Reference
+ Collaboration diagram for ilRepositoryObjectDetailSearch:

Public Member Functions

 __construct (int $a_obj_id)
 
 getSettings ()
 
 getObjId ()
 
 getType ()
 
 setQueryString (string $a_query)
 
 getQueryString ()
 
 performSearch ()
 

Protected Member Functions

 performLuceneSearch ()
 
 performDBSearch ()
 

Protected Attributes

ilSearchSettings $settings
 
int $obj_id
 
string $type
 
string $query_string
 

Detailed Description

Definition at line 17 of file class.ilRepositoryObjectDetailSearch.php.

Constructor & Destructor Documentation

◆ __construct()

ilRepositoryObjectDetailSearch::__construct ( int  $a_obj_id)

Definition at line 26 of file class.ilRepositoryObjectDetailSearch.php.

References ilObject\_lookupType(), ilSearchSettings\getInstance(), getObjId(), and ILIAS\Repository\settings().

27  {
28  $this->obj_id = $a_obj_id;
29  $this->type = ilObject::_lookupType($this->getObjId());
30 
32  }
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ getObjId()

ilRepositoryObjectDetailSearch::getObjId ( )

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

References $obj_id.

Referenced by __construct(), performDBSearch(), and performLuceneSearch().

39  : int
40  {
41  return $this->obj_id;
42  }
+ Here is the caller graph for this function:

◆ getQueryString()

ilRepositoryObjectDetailSearch::getQueryString ( )

Definition at line 56 of file class.ilRepositoryObjectDetailSearch.php.

References $query_string.

Referenced by performDBSearch(), and performLuceneSearch().

56  : string
57  {
58  return $this->query_string;
59  }
+ Here is the caller graph for this function:

◆ getSettings()

ilRepositoryObjectDetailSearch::getSettings ( )

Definition at line 34 of file class.ilRepositoryObjectDetailSearch.php.

References $settings.

Referenced by performDBSearch(), and performSearch().

+ Here is the caller graph for this function:

◆ getType()

ilRepositoryObjectDetailSearch::getType ( )

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

References $type.

Referenced by performDBSearch().

44  : string
45  {
46  return $this->type;
47  }
+ Here is the caller graph for this function:

◆ performDBSearch()

ilRepositoryObjectDetailSearch::performDBSearch ( )
protected
Exceptions
Exception

Definition at line 107 of file class.ilRepositoryObjectDetailSearch.php.

References ilObjectSearchFactory\getByTypeSearchInstance(), getObjId(), getQueryString(), getSettings(), getType(), ilSearchSettings\OPERATOR_AND, ilQueryParser\QP_COMBINATION_AND, and ilQueryParser\QP_COMBINATION_OR.

Referenced by performSearch().

108  {
109  $query_parser = new ilQueryParser($this->getQueryString());
110 
111  $query_parser->setCombination(
112  ($this->getSettings()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND) ?
115  );
116  $query_parser->parse();
117 
118  if (!$query_parser->validate()) {
119  throw new Exception($query_parser->getMessage());
120  }
121  $search_result = new ilSearchResult();
122 
123  $search = ilObjectSearchFactory::getByTypeSearchInstance($this->getType(), $query_parser);
124 
125  switch ($this->getType()) {
126  case 'wiki':
127  $search->setFilter(array('wpg'));
128  break;
129  }
130 
131  $search->setIdFilter(array($this->getObjId()));
132 
133  $search_result->mergeEntries($search->performSearch());
134 
135  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
136 
137  foreach ($search_result->getEntries() as $entry) {
138  foreach ((array) $entry['child'] as $child) {
139  $detail_search_result->addResultSet(
140  array(
141  'obj_id' => $entry['obj_id'],
142  'item_id' => $child
143  )
144  );
145  }
146  }
147  return $detail_search_result;
148  }
static getByTypeSearchInstance(string $a_object_type, ilQueryParser $a_query_parser)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performLuceneSearch()

ilRepositoryObjectDetailSearch::performLuceneSearch ( )
protected
Exceptions
ilLuceneQueryParserException

Definition at line 73 of file class.ilRepositoryObjectDetailSearch.php.

References Vendor\Package\$e, ilLuceneSearcher\getInstance(), ilLoggerFactory\getLogger(), getObjId(), and getQueryString().

Referenced by performSearch().

74  {
75  try {
76  $qp = new ilLuceneQueryParser($this->getQueryString());
77  $qp->parse();
79  ilLoggerFactory::getLogger('src')->warning('Invalid query: ' . $e->getMessage());
80  throw $e;
81  }
82 
83  $searcher = ilLuceneSearcher::getInstance($qp);
84  $searcher->highlight(array($this->getObjId()));
85 
86  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
87 
88  if ($searcher->getHighlighter() instanceof ilLuceneHighlighterResultParser) {
89  foreach ($searcher->getHighlighter()->getSubItemIds($this->getObjId()) as $sub_id) {
90  $detail_search_result->addResultSet(
91  array(
92  'obj_id' => $this->getObjId(),
93  'item_id' => $sub_id,
94  'relevance' => $searcher->getHighlighter()->getRelevance($this->getObjId(), $sub_id),
95  'content' => $searcher->getHighlighter()->getContent($this->getObjId(), $sub_id)
96  )
97  );
98  }
99  }
100  return $detail_search_result;
101  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilRepositoryObjectDetailSearch::performSearch ( )

◆ setQueryString()

ilRepositoryObjectDetailSearch::setQueryString ( string  $a_query)

Definition at line 50 of file class.ilRepositoryObjectDetailSearch.php.

50  : void
51  {
52  $this->query_string = $a_query;
53  }

Field Documentation

◆ $obj_id

int ilRepositoryObjectDetailSearch::$obj_id
protected

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

Referenced by getObjId().

◆ $query_string

string ilRepositoryObjectDetailSearch::$query_string
protected

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

Referenced by getQueryString().

◆ $settings

ilSearchSettings ilRepositoryObjectDetailSearch::$settings
protected

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

Referenced by getSettings().

◆ $type

string ilRepositoryObjectDetailSearch::$type
protected

Definition at line 22 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getType().


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