ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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, $ilCtrl, $lng, $tpl, initReferences(), and ilSubItemListGUI\setShowDetails().

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  {
68  include_once './Services/Object/classes/class.ilSubItemListGUI.php';
69  ilSubItemListGUI::setShowDetails((int) $_GET['details']);
70  }
71  }
$_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 368 of file class.ilSearchResultPresentation.php.

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

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

◆ appendMorePathes()

ilSearchResultPresentation::appendMorePathes (   $a_ref_id)
protected

Append more occurences link.

Returns

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

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

Referenced by appendAdditionalInformation().

420  {
421  if($this->getMode() != self::MODE_LUCENE)
422  {
423  return '';
424  }
425 
426 
427  if(!$num_refs = $this->hasMoreReferences($a_ref_id))
428  {
429  return '';
430  }
431  $tpl = new ilTemplate('tpl.lucene_more_references.html',true,true,'Services/Search');
432  $this->ctrl->setParameter($this->getContainer(),'refs',$a_ref_id);
433  $tpl->setVariable('MORE_REFS_LINK',$this->ctrl->getLinkTarget($this->getContainer(),''));
434  $this->ctrl->clearParameters($this->getContainer());
435 
436  $tpl->setVariable('TXT_MORE_REFS',sprintf($this->lng->txt('lucene_all_occurrences'),$num_refs));
437  return $tpl->get();
438  }
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 403 of file class.ilSearchResultPresentation.php.

References $tpl.

Referenced by appendAdditionalInformation().

404  {
405  include_once './Services/Tree/classes/class.ilPathGUI.php';
406  $path_gui = new ilPathGUI();
407  $path_gui->enableTextOnly(false);
408  $path_gui->setUseImages(false);
409 
410  $tpl = new ilTemplate('tpl.lucene_path.html',true,true,'Services/Search');
411  $tpl->setVariable('PATH_ITEM',$path_gui->getPath(ROOT_FOLDER_ID,$a_ref_id));
412  return $tpl->get();
413  }
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 444 of file class.ilSearchResultPresentation.php.

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

445  {
446  if($this->getMode() != self::MODE_LUCENE)
447  {
448  return '';
449  }
450 
451  if(!((int) $this->getRelevance($a_obj_id)))
452  {
453  return '';
454  }
455 
456  include_once './Services/Search/classes/class.ilSearchSettings.php';
457  if(!ilSearchSettings::getInstance()->isRelevanceVisible())
458  {
459  return '';
460  }
461 
462  $tpl = new ilTemplate('tpl.lucene_relevance.html',true,true,'Services/Search');
463 
464  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
465  $pbar = ilProgressBar::getInstance();
466  $pbar->setCurrent($this->getRelevance());
467 
468  $this->tpl->setCurrentBlock('relevance');
469  $this->tpl->setVariable('REL_PBAR', $pbar->render());
470  $this->tpl->parseCurrentBlock();
471 
472  $html = $tpl->get();
473  return $html;
474  }
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 480 of file class.ilSearchResultPresentation.php.

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

Referenced by appendAdditionalInformation().

481  {
482  $subitem_ids = array();
483  if($this->getMode() == self::MODE_STANDARD)
484  {
485  $subitem_ids = $this->getSubitemIdsByObject($obj_id);
486  $highlighter = null;
487  }
488  elseif(is_object($this->searcher->getHighlighter()))
489  {
490  $subitem_ids = $this->searcher->getHighlighter()->getSubitemIds($obj_id);
491  $highlighter = $this->searcher->getHighlighter();
492  }
493 
494  if(!count($subitem_ids))
495  {
496  return;
497  }
498 
499  // Build subitem list
500  include_once './Services/Search/classes/Lucene/class.ilLuceneSubItemListGUIFactory.php';
502  $sub_list->setHighlighter($highlighter);
503  $sub_list->init($item_list_gui,$ref_id,$subitem_ids);
504  return $sub_list->getHTML();
505 
506  }
static getInstanceByType($a_type, $a_cmd_class)
get instance by type
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
$ref_id
Definition: sahs_server.php:39
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, and array.

Referenced by renderItemList().

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

◆ getContainer()

ilSearchResultPresentation::getContainer ( )

Get container gui.

Definition at line 76 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 194 of file class.ilSearchResultPresentation.php.

195  {
196  return $this->thtml;
197  }

◆ getMode()

ilSearchResultPresentation::getMode ( )

Definition at line 81 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 306 of file class.ilSearchResultPresentation.php.

References getMode().

Referenced by appendRelevance(), and renderItemList().

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

References array.

Referenced by parseResultReferences(), and renderItemList().

100  {
101  return $this->results ? $this->results : array();
102  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getSubitemIds()

ilSearchResultPresentation::getSubitemIds ( )

Get subitem ids.

Returns

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

References array.

120  {
121  return $this->subitem_ids ? $this->subitem_ids : array();
122  }
Create styles array
The data for the language used.

◆ getSubitemIdsByObject()

ilSearchResultPresentation::getSubitemIdsByObject (   $a_obj_id)

Get subitem ids for an object.

Parameters
int$a_obj_id
Returns

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

References array.

Referenced by appendSubItems().

130  {
131  return (isset($this->subitem_ids[$a_obj_id]) and $this->subitem_ids[$a_obj_id]) ?
132  $this->subitem_ids[$a_obj_id] :
133  array();
134  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ hasMoreReferences()

ilSearchResultPresentation::hasMoreReferences (   $a_ref_id)
protected

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

References $_SESSION.

Referenced by appendMorePathes().

167  {
168  if(!isset($this->has_more_ref_ids[$a_ref_id]) or
169  !$this->has_more_ref_ids[$a_ref_id] or
170  isset($_SESSION['vis_references'][$a_ref_id]))
171  {
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 508 of file class.ilSearchResultPresentation.php.

References $_SESSION.

Referenced by __construct().

509  {
510  if(isset($_REQUEST['refs']))
511  {
512  $_SESSION['vis_references'][(int) $_REQUEST['refs']] = (int) $_REQUEST['refs'];
513  }
514  }
$_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 356 of file class.ilSearchResultPresentation.php.

References getMode().

357  {
358  if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
359  {
360  return '';
361  }
362  return $this->searcher->getHighlighter()->getContent($a_obj_id,$a_sub_id);
363  }
+ Here is the call graph for this function:

◆ lookupDescription()

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

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

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

Referenced by renderItemList().

339  {
340  if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
341  {
342  return ilObject::_lookupDescription($a_obj_id);
343  }
344  if(strlen($title = $this->searcher->getHighlighter()->getDescription($a_obj_id,$a_sub_id)))
345  {
346  return $title;
347  }
348  return ilObject::_lookupDescription($a_obj_id);
349  }
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 320 of file class.ilSearchResultPresentation.php.

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

Referenced by renderItemList().

321  {
322  if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
323  {
324  return ilObject::_lookupTitle($a_obj_id);
325  }
326  if(strlen($title = $this->searcher->getHighlighter()->getTitle($a_obj_id,$a_sub_id)))
327  {
328  return $title;
329  }
330  return ilObject::_lookupTitle($a_obj_id);
331  }
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 141 of file class.ilSearchResultPresentation.php.

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

Referenced by renderItemList().

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

References renderItemList().

215  {
216  return $this->renderItemList();
217  }
+ Here is the call graph for this function:

◆ renderItemList()

ilSearchResultPresentation::renderItemList ( )
protected

Render item list.

Returns
void

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

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

Referenced by render().

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

223  {
224  $this->prev = $a_p;
225  $this->next = $a_n;
226  }

◆ setResults()

ilSearchResultPresentation::setResults (   $a_result_data)

Set result array.

Parameters
array$a_result_dataresult array

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

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

◆ setSearcher()

ilSearchResultPresentation::setSearcher (   $a_searcher)

set searcher

Parameters

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

205  {
206  $this->searcher = $a_searcher;
207  }

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

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

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: