ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSearchResultPresentation Class Reference

Presentation of search results using object list gui. More...

+ Collaboration diagram for ilSearchResultPresentation:

Public Member Functions

 __construct ($container=null, $a_mode=self::MODE_LUCENE)
 Constructor. More...
 
 getContainer ()
 Get container gui. More...
 
 getMode ()
 
 setResults ($a_result_data)
 Set result array. More...
 
 getResults ()
 get results More...
 
 setSubitemIds ($a_subids)
 Set subitem ids Used for like and fulltext search. More...
 
 getSubitemIds ()
 Get subitem ids. More...
 
 getSubitemIdsByObject ($a_obj_id)
 Get subitem ids for an object. More...
 
 getHTML ($a_new=false)
 Get HTML. More...
 
 setSearcher ($a_searcher)
 set searcher More...
 
 render ()
 Parse results. More...
 
 setPreviousNext ($a_p, $a_n)
 Set previous next. More...
 
 getRelevance ($a_obj_id)
 get relevance More...
 
 lookupTitle ($a_obj_id, $a_sub_id)
 
 lookupDescription ($a_obj_id, $a_sub_id)
 
 lookupContent ($a_obj_id, $a_sub_id)
 get content More...
 
 appendAdditionalInformation ($item_list_gui, $ref_id, $obj_id, $type)
 Append path, relevance information. More...
 

Data Fields

const MODE_LUCENE = 1
 
const MODE_STANDARD = 2
 

Protected Member Functions

 parseResultReferences ()
 Check if more than one reference is visible. More...
 
 hasMoreReferences ($a_ref_id)
 
 getAllReferences ($a_ref_id)
 
 renderItemList ()
 Render item list. More...
 
 appendPath ($a_ref_id)
 Append path. More...
 
 appendMorePathes ($a_ref_id)
 Append more occurences link. More...
 
 appendRelevance ($a_obj_id)
 Append relevance. More...
 
 appendSubItems ($item_list_gui, $ref_id, $obj_id, $a_type)
 Append subitems. More...
 
 initReferences ()
 

Protected Attributes

 $mode
 
 $tpl
 
 $lng
 

Private Attributes

 $results = array()
 
 $subitem_ids = array()
 
 $has_more_ref_ids = array()
 
 $all_references = null
 
 $searcher = null
 
 $container = null
 

Detailed Description

Presentation of search results using object list gui.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 33 of file class.ilSearchResultPresentation.php.

Constructor & Destructor Documentation

◆ __construct()

ilSearchResultPresentation::__construct (   $container = null,
  $a_mode = self::MODE_LUCENE 
)

Constructor.

Parameters
object$containercontainer gui object

Definition at line 55 of file class.ilSearchResultPresentation.php.

56 {
57 global $tpl,$lng,$ilCtrl;
58
59 $this->mode = $a_mode;
60 $this->lng = $lng;
61 $this->container = $container;
62 $this->ctrl = $ilCtrl;
63
64 $this->initReferences();
65
66 if (isset($_GET['details'])) {
67 include_once './Services/Object/classes/class.ilSubItemListGUI.php';
69 }
70 }
$_GET["client_id"]
static setShowDetails($a_obj_id)
set show details.
global $ilCtrl
Definition: ilias.php:18

References $_GET, $container, $ilCtrl, $lng, $tpl, initReferences(), and ilSubItemListGUI\setShowDetails().

+ Here is the call graph for this function:

Member Function Documentation

◆ appendAdditionalInformation()

ilSearchResultPresentation::appendAdditionalInformation (   $item_list_gui,
  $ref_id,
  $obj_id,
  $type 
)

Append path, relevance information.

Definition at line 349 of file class.ilSearchResultPresentation.php.

350 {
351 $sub = $this->appendSubItems($item_list_gui, $ref_id, $obj_id, $type);
352 $path = $this->appendPath($ref_id);
353 $more = $this->appendMorePathes($ref_id);
354 #$rel = $this->appendRelevance($obj_id);
355
356 if (!strlen($sub) and
357 !strlen($path) and
358 !strlen($more) and
359 !strlen($rel)) {
360 return '';
361 }
362 $tpl = new ilTemplate('tpl.lucene_additional_information.html', true, true, 'Services/Search');
363 $tpl->setVariable('SUBITEM', $sub);
364 if (strlen($path)) {
365 $tpl->setVariable('PATH', $path);
366 }
367 if (strlen($more)) {
368 $tpl->setVariable('MORE_PATH', $more);
369 }
370 if (strlen($rel)) {
371 $tpl->setVariable('RELEVANCE', $rel);
372 }
373
374 $item_list_gui->setAdditionalInformation($tpl->get());
375 //$item_list_gui->setAdditionalInformation("Hello");
376 }
appendSubItems($item_list_gui, $ref_id, $obj_id, $a_type)
Append subitems.
appendMorePathes($a_ref_id)
Append more occurences link.
special template class to simplify handling of ITX/PEAR
$type

References $path, $tpl, $type, appendMorePathes(), appendPath(), and appendSubItems().

+ Here is the call graph for this function:

◆ appendMorePathes()

ilSearchResultPresentation::appendMorePathes (   $a_ref_id)
protected

Append more occurences link.

Returns

Definition at line 399 of file class.ilSearchResultPresentation.php.

400 {
401 if ($this->getMode() != self::MODE_LUCENE) {
402 return '';
403 }
404
405
406 if (!$num_refs = $this->hasMoreReferences($a_ref_id)) {
407 return '';
408 }
409 $tpl = new ilTemplate('tpl.lucene_more_references.html', true, true, 'Services/Search');
410 $this->ctrl->setParameter($this->getContainer(), 'refs', $a_ref_id);
411 $tpl->setVariable('MORE_REFS_LINK', $this->ctrl->getLinkTarget($this->getContainer(), ''));
412 $this->ctrl->clearParameters($this->getContainer());
413
414 $tpl->setVariable('TXT_MORE_REFS', sprintf($this->lng->txt('lucene_all_occurrences'), $num_refs));
415 return $tpl->get();
416 }
sprintf('%.4f', $callTime)

References $tpl, getContainer(), getMode(), hasMoreReferences(), and sprintf.

Referenced by appendAdditionalInformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendPath()

ilSearchResultPresentation::appendPath (   $a_ref_id)
protected

Append path.

Returns

Definition at line 383 of file class.ilSearchResultPresentation.php.

384 {
385 include_once './Services/Tree/classes/class.ilPathGUI.php';
386 $path_gui = new ilPathGUI();
387 $path_gui->enableTextOnly(false);
388 $path_gui->setUseImages(false);
389
390 $tpl = new ilTemplate('tpl.lucene_path.html', true, true, 'Services/Search');
391 $tpl->setVariable('PATH_ITEM', $path_gui->getPath(ROOT_FOLDER_ID, $a_ref_id));
392 return $tpl->get();
393 }
Creates a path for a start and endnode.

References $tpl.

Referenced by appendAdditionalInformation().

+ Here is the caller graph for this function:

◆ appendRelevance()

ilSearchResultPresentation::appendRelevance (   $a_obj_id)
protected

Append relevance.

Returns

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

423 {
424 if ($this->getMode() != self::MODE_LUCENE) {
425 return '';
426 }
427
428 if (!((int) $this->getRelevance($a_obj_id))) {
429 return '';
430 }
431
432 include_once './Services/Search/classes/class.ilSearchSettings.php';
433 if (!ilSearchSettings::getInstance()->isRelevanceVisible()) {
434 return '';
435 }
436
437 $tpl = new ilTemplate('tpl.lucene_relevance.html', true, true, 'Services/Search');
438
439 include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
441 $pbar->setCurrent($this->getRelevance());
442
443 $this->tpl->setCurrentBlock('relevance');
444 $this->tpl->setVariable('REL_PBAR', $pbar->render());
445 $this->tpl->parseCurrentBlock();
446
447 $html = $tpl->get();
448 return $html;
449 }
static getInstance()
Factory.
$html
Definition: example_001.php:87

References $html, $tpl, ilSearchSettings\getInstance(), ilProgressBar\getInstance(), getMode(), and getRelevance().

+ Here is the call graph for this function:

◆ appendSubItems()

ilSearchResultPresentation::appendSubItems (   $item_list_gui,
  $ref_id,
  $obj_id,
  $a_type 
)
protected

Append subitems.

Returns

Definition at line 455 of file class.ilSearchResultPresentation.php.

456 {
457 $subitem_ids = array();
458 if ($this->getMode() == self::MODE_STANDARD) {
459 $subitem_ids = $this->getSubitemIdsByObject($obj_id);
460 $highlighter = null;
461 } elseif (is_object($this->searcher->getHighlighter())) {
462 $subitem_ids = $this->searcher->getHighlighter()->getSubitemIds($obj_id);
463 $highlighter = $this->searcher->getHighlighter();
464 }
465
466 if (!count($subitem_ids)) {
467 return;
468 }
469
470 // Build subitem list
471 include_once './Services/Search/classes/Lucene/class.ilLuceneSubItemListGUIFactory.php';
473 $sub_list->setHighlighter($highlighter);
474 $sub_list->init($item_list_gui, $ref_id, $subitem_ids);
475 return $sub_list->getHTML();
476 }
static getInstanceByType($a_type, $a_cmd_class)
get instance by type
getSubitemIdsByObject($a_obj_id)
Get subitem ids for an object.
$a_type
Definition: workflow.php:92

References $a_type, $subitem_ids, getContainer(), ilLuceneSubItemListGUIFactory\getInstanceByType(), getMode(), and getSubitemIdsByObject().

Referenced by appendAdditionalInformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllReferences()

ilSearchResultPresentation::getAllReferences (   $a_ref_id)
protected

Definition at line 172 of file class.ilSearchResultPresentation.php.

173 {
174 if (isset($_SESSION['vis_references'][$a_ref_id])) {
175 return $this->all_references[$a_ref_id] ? $this->all_references[$a_ref_id] : array();
176 } else {
177 return array($a_ref_id);
178 }
179 }
$_SESSION["AccountId"]

References $_SESSION.

Referenced by renderItemList().

+ Here is the caller graph for this function:

◆ getContainer()

ilSearchResultPresentation::getContainer ( )

Get container gui.

Definition at line 75 of file class.ilSearchResultPresentation.php.

76 {
77 return $this->container;
78 }

References $container.

Referenced by appendMorePathes(), and appendSubItems().

+ Here is the caller graph for this function:

◆ getHTML()

ilSearchResultPresentation::getHTML (   $a_new = false)

Get HTML.

Returns
string HTML

Definition at line 185 of file class.ilSearchResultPresentation.php.

186 {
187 return $this->thtml;
188 }

◆ getMode()

ilSearchResultPresentation::getMode ( )

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

References $mode.

Referenced by appendMorePathes(), appendRelevance(), appendSubItems(), getRelevance(), lookupContent(), lookupDescription(), and lookupTitle().

+ Here is the caller graph for this function:

◆ getRelevance()

ilSearchResultPresentation::getRelevance (   $a_obj_id)

get relevance

Parameters

return

Definition at line 293 of file class.ilSearchResultPresentation.php.

294 {
295 if ($this->getMode() == self::MODE_LUCENE) {
296 return $this->searcher->getResult()->getRelevance($a_obj_id);
297 }
298 return 0;
299 }

References getMode().

Referenced by appendRelevance(), and renderItemList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResults()

ilSearchResultPresentation::getResults ( )

get results

Returns
array result array

Definition at line 98 of file class.ilSearchResultPresentation.php.

99 {
100 return $this->results ? $this->results : array();
101 }

Referenced by parseResultReferences(), and renderItemList().

+ Here is the caller graph for this function:

◆ getSubitemIds()

ilSearchResultPresentation::getSubitemIds ( )

Get subitem ids.

Returns

Definition at line 118 of file class.ilSearchResultPresentation.php.

119 {
120 return $this->subitem_ids ? $this->subitem_ids : array();
121 }

◆ getSubitemIdsByObject()

ilSearchResultPresentation::getSubitemIdsByObject (   $a_obj_id)

Get subitem ids for an object.

Parameters
int$a_obj_id
Returns

Definition at line 128 of file class.ilSearchResultPresentation.php.

129 {
130 return (isset($this->subitem_ids[$a_obj_id]) and $this->subitem_ids[$a_obj_id]) ?
131 $this->subitem_ids[$a_obj_id] :
132 array();
133 }

Referenced by appendSubItems().

+ Here is the caller graph for this function:

◆ hasMoreReferences()

ilSearchResultPresentation::hasMoreReferences (   $a_ref_id)
protected

Definition at line 161 of file class.ilSearchResultPresentation.php.

162 {
163 if (!isset($this->has_more_ref_ids[$a_ref_id]) or
164 !$this->has_more_ref_ids[$a_ref_id] or
165 isset($_SESSION['vis_references'][$a_ref_id])) {
166 return false;
167 }
168
169 return $this->has_more_ref_ids[$a_ref_id];
170 }

References $_SESSION.

Referenced by appendMorePathes().

+ Here is the caller graph for this function:

◆ initReferences()

ilSearchResultPresentation::initReferences ( )
protected

Definition at line 478 of file class.ilSearchResultPresentation.php.

479 {
480 if (isset($_REQUEST['refs'])) {
481 $_SESSION['vis_references'][(int) $_REQUEST['refs']] = (int) $_REQUEST['refs'];
482 }
483 }

References $_SESSION.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ lookupContent()

ilSearchResultPresentation::lookupContent (   $a_obj_id,
  $a_sub_id 
)

get content

Parameters

return

Definition at line 338 of file class.ilSearchResultPresentation.php.

339 {
340 if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
341 return '';
342 }
343 return $this->searcher->getHighlighter()->getContent($a_obj_id, $a_sub_id);
344 }

References getMode().

+ Here is the call graph for this function:

◆ lookupDescription()

ilSearchResultPresentation::lookupDescription (   $a_obj_id,
  $a_sub_id 
)
Parameters

return

Definition at line 322 of file class.ilSearchResultPresentation.php.

323 {
324 if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
325 return ilObject::_lookupDescription($a_obj_id);
326 }
327 if (strlen($title = $this->searcher->getHighlighter()->getDescription($a_obj_id, $a_sub_id))) {
328 return $title;
329 }
330 return ilObject::_lookupDescription($a_obj_id);
331 }
static _lookupDescription($a_id)
lookup object description

References $title, ilObject\_lookupDescription(), and getMode().

Referenced by renderItemList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupTitle()

ilSearchResultPresentation::lookupTitle (   $a_obj_id,
  $a_sub_id 
)
Parameters

return

Definition at line 306 of file class.ilSearchResultPresentation.php.

307 {
308 if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
309 return ilObject::_lookupTitle($a_obj_id);
310 }
311 if (strlen($title = $this->searcher->getHighlighter()->getTitle($a_obj_id, $a_sub_id))) {
312 return $title;
313 }
314 return ilObject::_lookupTitle($a_obj_id);
315 }
static _lookupTitle($a_id)
lookup object title

References $title, ilObject\_lookupTitle(), and getMode().

Referenced by renderItemList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseResultReferences()

ilSearchResultPresentation::parseResultReferences ( )
protected

Check if more than one reference is visible.

Definition at line 140 of file class.ilSearchResultPresentation.php.

141 {
142 global $ilAccess;
143
144 foreach ($this->getResults() as $ref_id => $obj_id) {
145 $this->all_references[$ref_id][] = $ref_id;
146 $counter = 0;
147 foreach (ilObject::_getAllReferences($obj_id) as $new_ref) {
148 if ($new_ref == $ref_id) {
149 continue;
150 }
151 if (!$ilAccess->checkAccess('read', '', $new_ref)) {
152 continue;
153 }
154 $this->all_references[$ref_id][] = $new_ref;
155 ++$counter;
156 }
157 $this->has_more_ref_ids[$ref_id] = $counter;
158 }
159 }
static _getAllReferences($a_id)
get all reference ids of object
$counter

References $counter, ilObject\_getAllReferences(), and getResults().

Referenced by renderItemList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilSearchResultPresentation::render ( )

Parse results.

Parameters
void
Returns
string html

Definition at line 205 of file class.ilSearchResultPresentation.php.

206 {
207 return $this->renderItemList();
208 }

References renderItemList().

+ Here is the call graph for this function:

◆ renderItemList()

ilSearchResultPresentation::renderItemList ( )
protected

Render item list.

Returns
void

Definition at line 224 of file class.ilSearchResultPresentation.php.

225 {
226 global $tree,$ilBench, $lng;
227
228 $this->html = '';
229
230 $ilBench->start('Lucene', '2000_pr');
231 $this->parseResultReferences();
232 $ilBench->stop('Lucene', '2000_pr');
233
234 $lng->loadLanguageModule("cntr"); // #16834
235
236 include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
238
239 $set = array();
240 foreach ($this->getResults() as $c_ref_id => $obj_id) {
241 $ilBench->start('Lucene', '2100_res');
242 foreach ($this->getAllReferences($c_ref_id) as $ref_id) {
243 $ilBench->start('Lucene', '2120_tree');
244 if (!$tree->isInTree($ref_id)) {
245 continue;
246 }
247 $ilBench->stop('Lucene', '2120_tree');
248
249 $obj_type = ilObject::_lookupType($obj_id);
250
251 $set[] = array(
252 "ref_id" => $ref_id,
253 "obj_id" => $obj_id,
254 "title" => $this->lookupTitle($obj_id, 0),
255 "title_sort" => ilObject::_lookupTitle($obj_id),
256 "description" => $this->lookupDescription($obj_id, 0),
257 "type" => $obj_type,
258 "relevance" => $this->getRelevance($obj_id),
259 "s_relevance" => sprintf("%03d", $this->getRelevance($obj_id))
260 );
261
262 $preloader->addItem($obj_id, $obj_type, $ref_id);
263 }
264 $ilBench->stop('Lucene', '2100_res');
265 }
266
267 if (!count($set)) {
268 return false;
269 }
270
271 $preloader->preload();
272 unset($preloader);
273
274 $ilBench->start('Lucene', '2900_tb');
275 include_once("./Services/Search/classes/class.ilSearchResultTableGUI.php");
276 $result_table = new ilSearchResultTableGUI($this->container, "showSavedResults", $this);
277 $result_table->setCustomPreviousNext($this->prev, $this->next);
278
279 $result_table->setData($set);
280 $this->thtml = $result_table->getHTML();
281 $ilBench->stop('Lucene', '2900_tb');
282
283 return true;
284 }
html()
Preloader for object list GUIs.
static _lookupType($a_id, $a_reference=false)
lookup object type
parseResultReferences()
Check if more than one reference is visible.
TableGUI class for search results.
global $ilBench
Definition: ilias.php:18

References $ilBench, $lng, ilObject\_lookupTitle(), ilObject\_lookupType(), ilObjectListGUI\CONTEXT_SEARCH, getAllReferences(), getRelevance(), getResults(), html(), lookupDescription(), lookupTitle(), parseResultReferences(), and sprintf.

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPreviousNext()

ilSearchResultPresentation::setPreviousNext (   $a_p,
  $a_n 
)

Set previous next.

Definition at line 213 of file class.ilSearchResultPresentation.php.

214 {
215 $this->prev = $a_p;
216 $this->next = $a_n;
217 }

◆ setResults()

ilSearchResultPresentation::setResults (   $a_result_data)

Set result array.

Parameters
array$a_result_dataresult array

Definition at line 89 of file class.ilSearchResultPresentation.php.

90 {
91 $this->results = $a_result_data;
92 }

◆ setSearcher()

ilSearchResultPresentation::setSearcher (   $a_searcher)

set searcher

Parameters

return

Definition at line 195 of file class.ilSearchResultPresentation.php.

196 {
197 $this->searcher = $a_searcher;
198 }

◆ setSubitemIds()

ilSearchResultPresentation::setSubitemIds (   $a_subids)

Set subitem ids Used for like and fulltext search.

Parameters
array$a_subidsarray ($obj_id => array(page1_id,page2_id);
Returns

Definition at line 109 of file class.ilSearchResultPresentation.php.

110 {
111 $this->subitem_ids = $a_subids;
112 }

Field Documentation

◆ $all_references

ilSearchResultPresentation::$all_references = null
private

Definition at line 46 of file class.ilSearchResultPresentation.php.

◆ $container

ilSearchResultPresentation::$container = null
private

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

Referenced by __construct(), and getContainer().

◆ $has_more_ref_ids

ilSearchResultPresentation::$has_more_ref_ids = array()
private

Definition at line 45 of file class.ilSearchResultPresentation.php.

◆ $lng

ilSearchResultPresentation::$lng
protected

Definition at line 41 of file class.ilSearchResultPresentation.php.

Referenced by __construct(), and renderItemList().

◆ $mode

ilSearchResultPresentation::$mode
protected

Definition at line 38 of file class.ilSearchResultPresentation.php.

Referenced by getMode().

◆ $results

ilSearchResultPresentation::$results = array()
private

Definition at line 43 of file class.ilSearchResultPresentation.php.

◆ $searcher

ilSearchResultPresentation::$searcher = null
private

Definition at line 47 of file class.ilSearchResultPresentation.php.

◆ $subitem_ids

ilSearchResultPresentation::$subitem_ids = array()
private

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

Referenced by appendSubItems().

◆ $tpl

ilSearchResultPresentation::$tpl
protected

◆ MODE_LUCENE

const ilSearchResultPresentation::MODE_LUCENE = 1

Definition at line 35 of file class.ilSearchResultPresentation.php.

◆ MODE_STANDARD


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