ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

56  {
57  global $DIC;
58 
59  $tpl = $DIC['tpl'];
60  $lng = $DIC['lng'];
61  $ilCtrl = $DIC['ilCtrl'];
62 
63  $this->mode = $a_mode;
64  $this->lng = $lng;
65  $this->container = $container;
66  $this->ctrl = $ilCtrl;
67 
68  $this->initReferences();
69 
70  if (isset($_GET['details'])) {
71  include_once './Services/Object/classes/class.ilSubItemListGUI.php';
72  ilSubItemListGUI::setShowDetails((int) $_GET['details']);
73  }
74  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
static setShowDetails($a_obj_id)
set show details.
+ 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 360 of file class.ilSearchResultPresentation.php.

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

361  {
362  $sub = $this->appendSubItems($item_list_gui, $ref_id, $obj_id, $type);
363  $path = $this->appendPath($ref_id);
364  $more = $this->appendMorePathes($ref_id);
365  #$rel = $this->appendRelevance($obj_id);
366 
367  if (!strlen($sub) and
368  !strlen($path) and
369  !strlen($more) and
370  !strlen($rel)) {
371  return '';
372  }
373  $tpl = new ilTemplate('tpl.lucene_additional_information.html', true, true, 'Services/Search');
374  $tpl->setVariable('SUBITEM', $sub);
375  if (strlen($path)) {
376  $tpl->setVariable('PATH', $path);
377  }
378  if (strlen($more)) {
379  $tpl->setVariable('MORE_PATH', $more);
380  }
381  if (strlen($rel)) {
382  $tpl->setVariable('RELEVANCE', $rel);
383  }
384 
385  $item_list_gui->setAdditionalInformation($tpl->get());
386  //$item_list_gui->setAdditionalInformation("Hello");
387  }
appendMorePathes($a_ref_id)
Append more occurences link.
$path
Definition: aliased.php:25
$type
appendSubItems($item_list_gui, $ref_id, $obj_id, $a_type)
Append subitems.
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ appendMorePathes()

ilSearchResultPresentation::appendMorePathes (   $a_ref_id)
protected

Append more occurences link.

Returns

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

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

Referenced by appendAdditionalInformation().

411  {
412  if ($this->getMode() != self::MODE_LUCENE) {
413  return '';
414  }
415 
416 
417  if (!$num_refs = $this->hasMoreReferences($a_ref_id)) {
418  return '';
419  }
420  $tpl = new ilTemplate('tpl.lucene_more_references.html', true, true, 'Services/Search');
421  $this->ctrl->setParameter($this->getContainer(), 'refs', $a_ref_id);
422  $tpl->setVariable('MORE_REFS_LINK', $this->ctrl->getLinkTarget($this->getContainer(), ''));
423  $this->ctrl->clearParameters($this->getContainer());
424 
425  $tpl->setVariable('TXT_MORE_REFS', sprintf($this->lng->txt('lucene_all_occurrences'), $num_refs));
426  return $tpl->get();
427  }
special template class to simplify handling of ITX/PEAR
+ 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 394 of file class.ilSearchResultPresentation.php.

References $tpl.

Referenced by appendAdditionalInformation().

395  {
396  include_once './Services/Tree/classes/class.ilPathGUI.php';
397  $path_gui = new ilPathGUI();
398  $path_gui->enableTextOnly(false);
399  $path_gui->setUseImages(false);
400 
401  $tpl = new ilTemplate('tpl.lucene_path.html', true, true, 'Services/Search');
402  $tpl->setVariable('PATH_ITEM', $path_gui->getPath(ROOT_FOLDER_ID, $a_ref_id));
403  return $tpl->get();
404  }
Creates a path for a start and endnode.
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ appendRelevance()

ilSearchResultPresentation::appendRelevance (   $a_obj_id)
protected

Append relevance.

Returns

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

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

434  {
435  if ($this->getMode() != self::MODE_LUCENE) {
436  return '';
437  }
438 
439  if (!((int) $this->getRelevance($a_obj_id))) {
440  return '';
441  }
442 
443  include_once './Services/Search/classes/class.ilSearchSettings.php';
444  if (!ilSearchSettings::getInstance()->isRelevanceVisible()) {
445  return '';
446  }
447 
448  $tpl = new ilTemplate('tpl.lucene_relevance.html', true, true, 'Services/Search');
449 
450  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
451  $pbar = ilProgressBar::getInstance();
452  $pbar->setCurrent($this->getRelevance());
453 
454  $this->tpl->setCurrentBlock('relevance');
455  $this->tpl->setVariable('REL_PBAR', $pbar->render());
456  $this->tpl->parseCurrentBlock();
457 
458  $html = $tpl->get();
459  return $html;
460  }
static getInstance()
Factory.
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87
+ 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 466 of file class.ilSearchResultPresentation.php.

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

Referenced by appendAdditionalInformation().

467  {
468  $subitem_ids = array();
469  if ($this->getMode() == self::MODE_STANDARD) {
470  $subitem_ids = $this->getSubitemIdsByObject($obj_id);
471  $highlighter = null;
472  } elseif (is_object($this->searcher->getHighlighter())) {
473  $subitem_ids = $this->searcher->getHighlighter()->getSubitemIds($obj_id);
474  $highlighter = $this->searcher->getHighlighter();
475  }
476 
477  if (!count($subitem_ids)) {
478  return;
479  }
480 
481  // Build subitem list
482  include_once './Services/Search/classes/Lucene/class.ilLuceneSubItemListGUIFactory.php';
484  $sub_list->setHighlighter($highlighter);
485  $sub_list->init($item_list_gui, $ref_id, $subitem_ids);
486  return $sub_list->getHTML();
487  }
static getInstanceByType($a_type, $a_cmd_class)
get instance by type
$a_type
Definition: workflow.php:92
getSubitemIdsByObject($a_obj_id)
Get subitem ids for an object.
+ 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 178 of file class.ilSearchResultPresentation.php.

References $_SESSION.

Referenced by renderItemList().

179  {
180  if (isset($_SESSION['vis_references'][$a_ref_id])) {
181  return $this->all_references[$a_ref_id] ? $this->all_references[$a_ref_id] : array();
182  } else {
183  return array($a_ref_id);
184  }
185  }
$_SESSION["AccountId"]
+ Here is the caller graph for this function:

◆ getContainer()

ilSearchResultPresentation::getContainer ( )

Get container gui.

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

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 191 of file class.ilSearchResultPresentation.php.

192  {
193  return $this->thtml;
194  }

◆ getMode()

ilSearchResultPresentation::getMode ( )

Definition at line 84 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

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

References getMode().

Referenced by appendRelevance(), and renderItemList().

305  {
306  if ($this->getMode() == self::MODE_LUCENE) {
307  return $this->searcher->getResult()->getRelevance($a_obj_id);
308  }
309  return 0;
310  }
+ 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 102 of file class.ilSearchResultPresentation.php.

Referenced by parseResultReferences(), and renderItemList().

103  {
104  return $this->results ? $this->results : array();
105  }
+ Here is the caller graph for this function:

◆ getSubitemIds()

ilSearchResultPresentation::getSubitemIds ( )

Get subitem ids.

Returns

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

123  {
124  return $this->subitem_ids ? $this->subitem_ids : array();
125  }

◆ getSubitemIdsByObject()

ilSearchResultPresentation::getSubitemIdsByObject (   $a_obj_id)

Get subitem ids for an object.

Parameters
int$a_obj_id
Returns

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

Referenced by appendSubItems().

133  {
134  return (isset($this->subitem_ids[$a_obj_id]) and $this->subitem_ids[$a_obj_id]) ?
135  $this->subitem_ids[$a_obj_id] :
136  array();
137  }
+ Here is the caller graph for this function:

◆ hasMoreReferences()

ilSearchResultPresentation::hasMoreReferences (   $a_ref_id)
protected

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

References $_SESSION.

Referenced by appendMorePathes().

168  {
169  if (!isset($this->has_more_ref_ids[$a_ref_id]) or
170  !$this->has_more_ref_ids[$a_ref_id] or
171  isset($_SESSION['vis_references'][$a_ref_id])) {
172  return false;
173  }
174 
175  return $this->has_more_ref_ids[$a_ref_id];
176  }
$_SESSION["AccountId"]
+ Here is the caller graph for this function:

◆ initReferences()

ilSearchResultPresentation::initReferences ( )
protected

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

References $_SESSION.

Referenced by __construct().

490  {
491  if (isset($_REQUEST['refs'])) {
492  $_SESSION['vis_references'][(int) $_REQUEST['refs']] = (int) $_REQUEST['refs'];
493  }
494  }
$_SESSION["AccountId"]
+ Here is the caller graph for this function:

◆ lookupContent()

ilSearchResultPresentation::lookupContent (   $a_obj_id,
  $a_sub_id 
)

get content

Parameters

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

References getMode().

350  {
351  if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
352  return '';
353  }
354  return $this->searcher->getHighlighter()->getContent($a_obj_id, $a_sub_id);
355  }
+ Here is the call graph for this function:

◆ lookupDescription()

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

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

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

Referenced by renderItemList().

334  {
335  if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
336  return ilObject::_lookupDescription($a_obj_id);
337  }
338  if (strlen($title = $this->searcher->getHighlighter()->getDescription($a_obj_id, $a_sub_id))) {
339  return $title;
340  }
341  return ilObject::_lookupDescription($a_obj_id);
342  }
static _lookupDescription($a_id)
lookup object description
+ 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

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

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

Referenced by renderItemList().

318  {
319  if ($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter())) {
320  return ilObject::_lookupTitle($a_obj_id);
321  }
322  if (strlen($title = $this->searcher->getHighlighter()->getTitle($a_obj_id, $a_sub_id))) {
323  return $title;
324  }
325  return ilObject::_lookupTitle($a_obj_id);
326  }
static _lookupTitle($a_id)
lookup object title
+ 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 144 of file class.ilSearchResultPresentation.php.

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

Referenced by renderItemList().

145  {
146  global $DIC;
147 
148  $ilAccess = $DIC['ilAccess'];
149 
150  foreach ($this->getResults() as $ref_id => $obj_id) {
151  $this->all_references[$ref_id][] = $ref_id;
152  $counter = 0;
153  foreach (ilObject::_getAllReferences($obj_id) as $new_ref) {
154  if ($new_ref == $ref_id) {
155  continue;
156  }
157  if (!$ilAccess->checkAccess('read', '', $new_ref)) {
158  continue;
159  }
160  $this->all_references[$ref_id][] = $new_ref;
161  ++$counter;
162  }
163  $this->has_more_ref_ids[$ref_id] = $counter;
164  }
165  }
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
+ 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 211 of file class.ilSearchResultPresentation.php.

References renderItemList().

212  {
213  return $this->renderItemList();
214  }
+ Here is the call graph for this function:

◆ renderItemList()

ilSearchResultPresentation::renderItemList ( )
protected

Render item list.

Returns
void

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

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

Referenced by render().

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

220  {
221  $this->prev = $a_p;
222  $this->next = $a_n;
223  }

◆ setResults()

ilSearchResultPresentation::setResults (   $a_result_data)

Set result array.

Parameters
array$a_result_dataresult array

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

94  {
95  $this->results = $a_result_data;
96  }

◆ setSearcher()

ilSearchResultPresentation::setSearcher (   $a_searcher)

set searcher

Parameters

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

202  {
203  $this->searcher = $a_searcher;
204  }

◆ 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 113 of file class.ilSearchResultPresentation.php.

114  {
115  $this->subitem_ids = $a_subids;
116  }

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: