ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilRepositoryObjectDetailSearch Class Reference
+ Collaboration diagram for ilRepositoryObjectDetailSearch:

Public Member Functions

 __construct ($a_obj_id)
 constructor More...
 
 getSettings ()
 Get settings. More...
 
 getObjId ()
 get obj id More...
 
 getType ()
 
 setQueryString ($a_query)
 
 getQueryString ()
 get query string More...
 
 performSearch ()
 Perform search. More...
 

Protected Member Functions

 performLuceneSearch ()
 Perform lucene search. More...
 
 performDBSearch ()
 Perform DB search. More...
 

Protected Attributes

 $settings = null
 
 $obj_id
 
 $type
 
 $query_string
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilRepositoryObjectDetailSearch::__construct (   $a_obj_id)

constructor

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

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

29  {
30  $this->obj_id = $a_obj_id;
31  $this->type = ilObject::_lookupType($this->getObjId());
32 
34  }
static _lookupType($a_id, $a_reference=false)
lookup object type
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ getObjId()

ilRepositoryObjectDetailSearch::getObjId ( )

get obj id

Returns
type

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

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getQueryString()

ilRepositoryObjectDetailSearch::getQueryString ( )

get query string

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

References $query_string.

Referenced by performDBSearch(), and performLuceneSearch().

+ Here is the caller graph for this function:

◆ getSettings()

ilRepositoryObjectDetailSearch::getSettings ( )

Get settings.

Returns
ilSearchSettings

Definition at line 40 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 54 of file class.ilRepositoryObjectDetailSearch.php.

References $type.

Referenced by performDBSearch().

+ Here is the caller graph for this function:

◆ performDBSearch()

ilRepositoryObjectDetailSearch::performDBSearch ( )
protected

Perform DB search.

Returns
ilRepositoryObjectDetailSearchResult

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

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

Referenced by performSearch().

140  {
141  // query parser
142  include_once 'Services/Search/classes/class.ilQueryParser.php';
143 
144  $query_parser = new ilQueryParser($this->getQueryString());
145 
146  $query_parser->setCombination(
147  ($this->getSettings()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND) ?
150  );
151  $query_parser->parse();
152 
153  if(!$query_parser->validate())
154  {
155  throw new Exception($query_parser->getMessage());
156  }
157  include_once 'Services/Search/classes/class.ilSearchResult.php';
158  $search_result = new ilSearchResult();
159 
160  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
161  $search = ilObjectSearchFactory::getByTypeSearchInstance($this->getType(), $query_parser);
162 
163  switch($this->getType())
164  {
165  case 'wiki':
166  $search->setFilter(array('wpg'));
167  break;
168  }
169 
170  $search->setIdFilter(array($this->getObjId()));
171 
172  $search_result->mergeEntries($search->performSearch());
173 
174  include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearchResult.php';
175  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
176 
177  foreach($search_result->getEntries() as $entry)
178  {
179  foreach((array) $entry['child'] as $child)
180  {
181  $detail_search_result->addResultSet(
182  array(
183  'obj_id' => $entry['obj_id'],
184  'item_id' => $child
185  )
186  );
187  }
188  }
189  return $detail_search_result;
190  }
const QP_COMBINATION_OR
Create styles array
The data for the language used.
static getByTypeSearchInstance($a_object_type, $a_query_parser)
const QP_COMBINATION_AND
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performLuceneSearch()

ilRepositoryObjectDetailSearch::performLuceneSearch ( )
protected

Perform lucene search.

Exceptions
ilLuceneQueryParserException

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

References array, ilLuceneSearcher\getInstance(), ilLoggerFactory\getLogger(), getObjId(), and getQueryString().

Referenced by performSearch().

97  {
98  include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
99  try
100  {
101  $qp = new ilLuceneQueryParser($this->getQueryString());
102  $qp->parse();
103  }
104  catch (ilLuceneQueryParserException $e)
105  {
106  ilLoggerFactory::getLogger('src')->warning('Invalid query: ' . $e->getMessage());
107  throw $e;
108  }
109 
110  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
111  $searcher = ilLuceneSearcher::getInstance($qp);
112  $searcher->highlight(array($this->getObjId()));
113 
114  include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearchResult.php';
115  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
116 
117  if($searcher->getHighlighter() instanceof ilLuceneHighlighterResultParser)
118  {
119  foreach($searcher->getHighlighter()->getSubItemIds($this->getObjId()) as $sub_id)
120  {
121  $detail_search_result->addResultSet(
122  array(
123  'obj_id' => $this->getObjId(),
124  'item_id' => $sub_id,
125  'relevance' => $searcher->getHighlighter()->getRelevance($this->getObjId(),$sub_id),
126  'content' => $searcher->getHighlighter()->getContent($this->getObjId(),$sub_id)
127  )
128  );
129  }
130  }
131  return $detail_search_result;
132  }
Parses result XML from lucene search highlight.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
Create styles array
The data for the language used.
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilRepositoryObjectDetailSearch::performSearch ( )

Perform search.

Returns
ilRepositoryObjectDetailSearchResult
Exceptions
ilLuceneQueryParserException

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

References getSettings(), performDBSearch(), and performLuceneSearch().

81  {
82  if($this->getSettings()->enabledLucene())
83  {
84  return $this->performLuceneSearch();
85  }
86  else
87  {
88  return $this->performDBSearch();
89  }
90  }
+ Here is the call graph for this function:

◆ setQueryString()

ilRepositoryObjectDetailSearch::setQueryString (   $a_query)

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

61  {
62  $this->query_string = $a_query;
63  }

Field Documentation

◆ $obj_id

ilRepositoryObjectDetailSearch::$obj_id
protected

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

Referenced by getObjId().

◆ $query_string

ilRepositoryObjectDetailSearch::$query_string
protected

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

Referenced by getQueryString().

◆ $settings

ilRepositoryObjectDetailSearch::$settings = null
protected

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

Referenced by getSettings().

◆ $type

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: