19declare(strict_types=1);
48 protected ObjectPropertiesAggregator $obj_properties,
49 protected SubitemPropertiesAggregator $subitem_properties,
50 protected SubitemPropertiesFactory $subitem_properties_factory,
51 protected CopyrightHelper $copyright_helper,
67 $items_with_sort_data = [];
70 $title = $this->obj_properties->lookupTitle($obj_id);
71 $creation_date = $this->obj_properties->lookupCreationDate($obj_id);
72 $type = $this->obj_properties->lookupType($obj_id);
75 $too_many_subitems =
false;
77 $subitem_ids = $subitem_ids_by_obj_id[$obj_id] ?? [];
79 $subitem_ids = array_slice($subitem_ids, 0, self::MAX_SUBITEMS);
81 $subitem_modal = $this->component_factory->getModalForSubitems(
83 self::MAX_SUBITEMS_PER_PAGE,
87 if ($subitem_modal !==
null) {
88 $subitem_modals[] = $subitem_modal;
91 $item = $this->component_factory->getItemForObject(
92 $this->obj_properties->buildIconPath($obj_id, $type),
93 $this->obj_properties->makeTypePresentable($type),
95 $this->obj_properties->buildLink(
$ref_id, $type),
96 $this->obj_properties->lookupDescription($obj_id),
98 $this->obj_properties->buildRepositoryPath(
$ref_id),
100 $this->copyright_helper->readPresentableCopyright($obj_id, 0, $type),
101 $subitem_modal?->getShowSignal()
103 $items_with_sort_data[] = [
106 'creation_date' => $creation_date,
114 $this->component_factory->getPanel(
130 array ...$raw_sub_ids
133 foreach ($raw_sub_ids as $raw_sub_id) {
134 $sub_ids[] = $this->subitem_properties_factory->getID(
135 (
string) $raw_sub_id[
'id'],
136 (
string) $raw_sub_id[
'type']
139 $subitem_properties = $this->subitem_properties->getSubitemProperties(
$ref_id, $type, ...$sub_ids);
140 foreach ($subitem_properties as $properties) {
141 yield $this->component_factory->getItemForSubitem(
142 $properties->title(),
144 $properties->openLinkInNewViewport(),
146 $properties->presentableSubitemType(),
147 $this->copyright_helper->readPresentableCopyright($obj_id, (
int) $properties->id()->id(), $properties->id()->type())
161 $subitem_modals = [];
163 $items_with_sort_data = [];
165 $creation_date = $this->obj_properties->lookupCreationDate($obj_id);
166 $type = $this->obj_properties->lookupType($obj_id);
167 $title_no_highlights = $this->obj_properties->lookupTitle($obj_id);
170 $too_many_subitems =
false;
171 if ($this->
access->canSeeSubitemsOfObject($ref_id)) {
173 $too_many_subitems = count($subitem_ids) > self::MAX_SUBITEMS;
174 $subitem_ids = array_slice($subitem_ids, 0, self::MAX_SUBITEMS);
176 $subitem_modal = $this->component_factory->getModalForSubitems(
177 $title_no_highlights,
178 self::MAX_SUBITEMS_PER_PAGE,
180 ...$this->getItemsForSubitemsFromLuceneSearch($highlighter, $obj_id,
$ref_id, $type, ...$subitem_ids),
182 if ($subitem_modal !==
null) {
183 $subitem_modals[] = $subitem_modal;
186 $item = $this->component_factory->getItemForObject(
187 $this->obj_properties->buildIconPath($obj_id, $type),
188 $this->obj_properties->makeTypePresentable($type),
189 $highlighter->
getTitle($obj_id, 0,
'') ?: $title_no_highlights,
190 $this->obj_properties->buildLink(
$ref_id, $type),
191 $highlighter->
getDescription($obj_id, 0,
'') ?: $this->obj_properties->lookupDescription($obj_id),
193 $this->obj_properties->buildRepositoryPath(
$ref_id),
195 $this->copyright_helper->readPresentableCopyright($obj_id, 0, $type),
196 $subitem_modal?->getShowSignal()
198 $items_with_sort_data[] = [
199 'relevance' => $highlighter->
getRelevance($obj_id, 0,
''),
200 'title' => $title_no_highlights,
201 'creation_date' => $creation_date,
206 $items = $this->sortObjectItems($view_control_infos->
sortation(), ...$items_with_sort_data);
209 $this->component_factory->getPanel(
226 array ...$raw_sub_ids
229 foreach ($raw_sub_ids as $raw_sub_id) {
230 $sub_ids[] = $this->subitem_properties_factory->getID(
231 (
string) $raw_sub_id[
'id'],
232 (
string) $raw_sub_id[
'type']
235 $subitem_properties = $this->subitem_properties->getSubitemProperties(
$ref_id, $type, ...$sub_ids);
236 foreach ($subitem_properties as $properties) {
237 $subitem_id = (
int) $properties->id()->id();
238 $subitem_type = $properties->id()->type();
239 yield $this->component_factory->getItemForSubitem(
240 $highlighter->
getTitle($obj_id, $subitem_id, $subitem_type) ?: $properties->title(),
242 $properties->openLinkInNewViewport(),
243 $highlighter->
getContent($obj_id, $subitem_id, $subitem_type),
244 $properties->presentableSubitemType(),
245 $this->copyright_helper->readPresentableCopyright($obj_id, (
int) $properties->id()->id(), $properties->id()->type())
256 $sort_callable = match ($sortation) {
257 Sortation::RELEVANCE_DESC => fn(
$a,
$b) =>
$b[
'relevance'] <=>
$a[
'relevance'],
258 Sortation::TITLE_ASC => fn(
$a,
$b) => [
$a[
'title'],
$a[
'relevance']] <=> [
$b[
'title'],
$b[
'relevance']],
259 Sortation::TITLE_DESC => fn(
$a,
$b) => [
$b[
'title'],
$b[
'relevance']] <=> [
$a[
'title'],
$a[
'relevance']],
260 Sortation::CREATION_DATE_ASC => fn(
$a,
$b) => [
$a[
'creation_date'],
$a[
'relevance']] <=> [
$b[
'creation_date'],
$b[
'relevance']],
264 usort($items_with_sort_data, $sort_callable);
266 foreach ($items_with_sort_data as $item) {
276 URI $pagination_action,
277 Param $page_param_name,
278 URI $sortation_action,
279 Param $sortation_param_name
289 $sortation_param_name
295 return $this->sanitizer->replacePlaceholders($html);
The scope of this class is split ilias-conform URI's into components.
getItemsForSubitemsFromDirectSearch(int $ref_id, int $obj_id, string $type, array ... $raw_sub_ids)
getLuceneSearchResultAsPanel(ilLuceneSearchResultFilter $result, ilLuceneHighlighterResultParser $highlighter, ViewControlInfos $view_control_infos)
sortObjectItems(Sortation $sortation, array ... $items_with_sort_data)
getItemsForSubitemsFromLuceneSearch(ilLuceneHighlighterResultParser $highlighter, int $obj_id, int $ref_id, string $type, array ... $raw_sub_ids)
replacePlaceholders(string $html)
const int MAX_SUBITEMS_PER_PAGE
__construct(protected ComponentFactory $component_factory, protected ObjectPropertiesAggregator $obj_properties, protected SubitemPropertiesAggregator $subitem_properties, protected SubitemPropertiesFactory $subitem_properties_factory, protected CopyrightHelper $copyright_helper, protected AccessChecker $access, protected Sanitizer $sanitizer)
getDirectSearchResultAsPanel(ilSearchResult $result, ViewControlInfos $view_control_infos)
getViewControlInfos(Sortation $sortation, int $current_page, int $max_pages, int $page_size, URI $pagination_action, Param $page_param_name, URI $sortation_action, Param $sortation_param_name)
Parses result XML from lucene search highlight.
getTitle(int $obj_id, int $sub_id, string $sub_type)
getSubItemIds(int $obj_id)
getDescription(int $obj_id, int $sub_id, string $sub_type)
getContent(int $obj_id, int $sub_id, string $sub_type)
getRelevance(int $obj_id, int $sub_id, string $sub_type)
Validate Lucene search results Do access checks, create ref_ids from obj_ids...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getResultsForPresentation()
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Common interface to all items.
This describes commonalities between the different modals.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples