ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSubItemListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26abstract 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
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 {
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}
language handling
Parses result XML from lucene search highlight.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
Base class for all sub item list gui's.
static resetDetails()
As long as static::resetDetails is not possible this method is final.
ilObjectListGUI $item_list_gui
__construct(string $cmd_class)
static setShowDetails(int $obj_id)
set show details.
getSubItemIds(bool $limited=false)
static enabledDetails(int $obj_id)
As long as static::enableDetails is not possible this method is final.
init(ilObjectListGUI $item_list_gui, int $ref_id, array $subitem_ids)
ilLuceneHighlighterResultParser $highlighter
setHighlighter(?ilLuceneHighlighterResultParser $highlighter)
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26