ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSubItemListGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 abstract class ilSubItemListGUI
27 {
28  protected static int $MAX_SUBITEMS = 5;
29  protected static array $details = [];
30 
32  protected ilLanguage $lng;
33 
34  protected string $cmd_class = '';
35 
36  protected ?ilTemplate $tpl = null;
38  protected array $subitem_ids = [];
40  protected int $ref_id = 0;
41  protected int $obj_id = 0;
42  protected string $type = '';
43 
44  public function __construct(string $cmd_class)
45  {
46  global $DIC;
47 
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50 
51  $this->cmd_class = $cmd_class;
52  self::$MAX_SUBITEMS = ilSearchSettings::getInstance()->getMaxSubitems();
53  }
54 
60  final public static function setShowDetails(int $obj_id): void
61  {
62  $_SESSION['lucene_search']['details'][$obj_id] = true;
63  }
64 
68  final public static function resetDetails(): void
69  {
70  $_SESSION['lucene_search']['details'] = [];
71  }
72 
76  final public static function enabledDetails(int $obj_id): bool
77  {
78  return isset($_SESSION['lucene_search']['details'][$obj_id]) && $_SESSION['lucene_search']['details'][$obj_id];
79  }
80 
81  public function getCmdClass(): string
82  {
83  return $this->cmd_class;
84  }
85 
86  public function setHighlighter(?ilLuceneHighlighterResultParser $highlighter): void
87  {
88  $this->highlighter = $highlighter;
89  }
90 
92  {
93  return $this->highlighter;
94  }
95 
96  public function getRefId(): int
97  {
98  return $this->ref_id;
99  }
100 
101  public function getObjId(): int
102  {
103  return $this->obj_id;
104  }
105 
106  public function getType(): string
107  {
108  return $this->type;
109  }
110 
111  public function getSubItemIds(bool $limited = false): array
112  {
113  if ($limited && !self::enabledDetails($this->getObjId())) {
114  return array_slice($this->subitem_ids, 0, self::$MAX_SUBITEMS);
115  }
116 
117  return $this->subitem_ids;
118  }
119 
120  public function getItemListGUI(): ?ilObjectListGUI
121  {
122  return $this->item_list_gui;
123  }
124 
125  public function init(ilObjectListGUI $item_list_gui, int $ref_id, array $subitem_ids): void
126  {
127  $this->tpl = new ilTemplate('tpl.subitem_list.html', true, true, 'components/ILIAS/ILIASObject');
128  $this->item_list_gui = $item_list_gui;
129  $this->ref_id = $ref_id;
130  $this->obj_id = ilObject::_lookupObjId($this->getRefId());
131  $this->type = ilObject::_lookupType($this->getObjId());
132  $this->subitem_ids = $subitem_ids;
133  }
134 
135  protected function showDetailsLink(): void
136  {
137  if (count($this->getSubItemIds()) <= self::$MAX_SUBITEMS) {
138  return;
139  }
140  if (self::enabledDetails($this->getObjId())) {
141  return;
142  }
143 
144  $additional = count($this->getSubItemIds()) - self::$MAX_SUBITEMS;
145 
146  $this->ctrl->setParameterByClass($this->getCmdClass(), 'details', $this->getObjId());
147  $link = $this->ctrl->getLinkTargetByClass($this->getCmdClass(), '');
148  $this->ctrl->clearParametersByClass($this->getCmdClass());
149 
150  $this->tpl->setCurrentBlock('choose_details');
151  $this->tpl->setVariable('LUC_DETAILS_LINK', $link);
152  $this->tpl->setVariable('LUC_NUM_HITS', sprintf($this->lng->txt('lucene_more_hits_link'), $additional));
153  $this->tpl->parseCurrentBlock();
154  }
155 
156  abstract public function getHTML(): string;
157 }
getSubItemIds(bool $limited=false)
Parses result XML from lucene search highlight.
Base class for all sub item list gui&#39;s.
static setShowDetails(int $obj_id)
set show details.
static enabledDetails(int $obj_id)
As long as static::enableDetails is not possible this method is final.
static resetDetails()
As long as static::resetDetails is not possible this method is final.
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setHighlighter(?ilLuceneHighlighterResultParser $highlighter)
global $DIC
Definition: shib_login.php:22
init(ilObjectListGUI $item_list_gui, int $ref_id, array $subitem_ids)
static _lookupType(int $id, bool $reference=false)
ilObjectListGUI $item_list_gui
ilLuceneHighlighterResultParser $highlighter
__construct(string $cmd_class)