19declare(strict_types=1);
44 protected UIFactory $ui_factory,
54 $item_group = $this->ui_factory->item()->group(
'', $items);
70 return $this->ui_factory->panel()->listing()->standard(
71 $this->
lng->txt(
"search_results"),
73 )->withViewControls($view_controls);
84 return $this->ui_factory->viewControl()->pagination()
85 ->withTargetURL((string) $action, $page_param->value)
86 ->withCurrentPage($current_page - 1)
87 ->withPageSize($page_size)
88 ->withTotalEntries($page_size * $max_pages);
94 Param $sortation_param
95 ): SortationViewControl {
97 Sortation::RELEVANCE_DESC->value => $this->
lng->txt(
'search_sort_relevance'),
98 Sortation::TITLE_ASC->value => $this->
lng->txt(
'search_sort_title_asc'),
99 Sortation::TITLE_DESC->value => $this->
lng->txt(
'search_sort_title_desc'),
101 Sortation::CREATION_DATE_ASC->value => $this->
lng->txt(
'search_sort_creation_date_asc')
104 return $this->ui_factory->viewControl()
105 ->sortation(
$options, $sortation->value)
106 ->withLabelPrefix($this->
lng->txt(
'search_sort_by'))
107 ->withTargetURL((
string) $action, $sortation_param->value);
111 string $object_title,
113 bool $show_too_many_items_warning,
120 if ($show_too_many_items_warning) {
121 $items[] = $this->ui_factory->item()->shy($this->
lng->txt(
'search_results_too_many_subitems'));
125 $this->
lng->txt(
'search_detailed_results_title'),
126 $this->sanitizer->sanitize($object_title)
130 foreach (array_chunk($items, $items_per_page) as $chunk_of_items) {
131 $card = $this->ui_factory->card()->standard($title)->withSections($chunk_of_items);
132 $pages[] = $this->ui_factory->modal()->lightboxCardPage($card);
134 return $this->ui_factory->modal()->lightbox($pages);
138 string $type_icon_path,
139 string $type_icon_label,
145 DateTimeImmutable $created_on,
147 ?
Signal $subitem_show_signal
149 $item_title = $this->sanitizer->sanitizeAndSetUpPlaceholders($title);
150 if ($link !==
null) {
151 $item_title = $this->ui_factory->link()->standard($item_title, (
string) $link);
154 $type_icon = $this->ui_factory->symbol()->icon()->custom(
156 $this->sanitizer->sanitize($type_icon_label)
160 $this->
lng->txt(
'path') => $this->sanitizer->sanitize(
$path),
161 $this->
lng->txt(
'create_date') => $this->formatDate($created_on)
163 if ($copyright !==
'') {
164 $properties[$this->
lng->txt(
'search_copyright')] = $this->sanitizer->sanitize($copyright);
166 if ($description !==
'') {
167 if (mb_strlen($description) >= self::MAX_DESCRIPTION_LENGTH) {
168 $description = mb_substr($description, 0, self::MAX_DESCRIPTION_LENGTH) .
'...';
170 $properties[$this->
lng->txt(
'description')] = $this->sanitizer->sanitizeAndSetUpPlaceholders($description);
173 $item = $this->ui_factory->item()->standard($item_title)
174 ->withLeadIcon($type_icon);
175 if ($subitem_show_signal !==
null) {
176 $button = $this->ui_factory->button()->standard(
177 $this->
lng->txt(
'search_results_show_subitems'),
180 $item = $item->withMainAction($button);
182 return $item->
withDescription($this->sanitizer->sanitizeAndSetUpPlaceholders($content))
183 ->withProperties($properties);
186 protected function formatDate(DateTimeImmutable $date): string
198 bool $open_link_in_new_viewport,
203 $item_title = $this->sanitizer->sanitizeAndSetUpPlaceholders($title);
204 if ($link !==
null) {
205 $item_title = $this->ui_factory->link()->standard($item_title, (
string) $link)
206 ->withOpenInNewViewport($open_link_in_new_viewport);
208 $properties = [$this->
lng->txt(
'type') => $this->sanitizer->sanitize($type)];
209 if ($copyright !==
'') {
210 $properties[$this->
lng->txt(
'search_copyright')] = $this->sanitizer->sanitize($copyright);
212 return $this->ui_factory->item()->standard($item_title)
213 ->
withDescription($this->sanitizer->sanitizeAndSetUpPlaceholders($content))
214 ->withProperties($properties);
Builds a Color from either hex- or rgb values.
The scope of this class is split ilias-conform URI's into components.
const int MAX_DESCRIPTION_LENGTH
getItemForSubitem(string $title, ?URI $link, bool $open_link_in_new_viewport, string $content, string $type, string $copyright)
formatDate(DateTimeImmutable $date)
getPaginationViewControl(int $current_page, int $max_pages, int $page_size, URI $action, Param $page_param)
getItemForObject(string $type_icon_path, string $type_icon_label, string $title, ?URI $link, string $description, string $content, string $path, DateTimeImmutable $created_on, string $copyright, ?Signal $subitem_show_signal)
__construct(protected UIFactory $ui_factory, protected ilLanguage $lng, protected Sanitizer $sanitizer)
getPanel(ViewControlInfos $view_control_infos, Item ... $items)
getSortationViewControl(Sortation $sortation, URI $action, Param $sortation_param)
getModalForSubitems(string $object_title, int $items_per_page, bool $show_too_many_items_warning, Item ... $items)
Class for date presentation.
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
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.
withDescription(string $description)
Create a new item with an attached description.
This describes commonalities between the different modals.
This describes a Sortation Control.
if(!file_exists('../ilias.ini.php'))