39 private readonly HttpServices
$http;
61 $this->
ctrl = $DIC->ctrl();
62 $this->
http = $DIC->http();
63 $this->
lng = $DIC->language();
64 $this->ui_factory =
$DIC->ui()->factory();
65 $this->ui_renderer =
$DIC->ui()->renderer();
66 $this->ui_service =
$DIC->uiService();
68 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_PAGE);
69 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_SORTATION);
73 $this->string_transform =
$DIC->refinery()->string();
78 if ($this->
filter !==
null) {
87 $filter_objects = $this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId());
92 $available_field_ids_for_object = array_map(
94 $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId())
98 $filter_active_states = [];
100 if (in_array($filter_object->getFieldId(), $available_field_ids_for_object,
true)) {
102 $field = $this->facade->fieldFactory()->findById($filter_object->getFieldId());
104 $filter_input = $filter_presentation->getFilterInput();
105 $filter_inputs[$post_var] = $filter_input;
106 $filter_active_states[] =
true;
107 $this->filter_objects[$post_var] = $filter_object;
111 return $this->ui_service->filter()->standard(
113 $this->
ctrl->getLinkTargetByClass(
114 ilObjBibliographicGUI::class,
120 $filter_active_states,
128 $entry = $this->facade->entryFactory()->findByIdAndTypeString(
130 $this->facade->type()->getStringRepresentation()
133 $settings = $this->facade->libraryFactory()->getAll();
142 $buttons[$set->getName()] = $presentation->getButton($this->facade, $entry);
150 $records = $this->getData();
157 $sortations[$sort_id] = $this->
lng->txt(
'sorting_' . $sort_id);
159 if ($sortations !== []) {
160 $view_controls[] = $this->ui_factory->viewControl()->sortation($sortations, array_key_first($sortations))
162 $this->
ctrl->getLinkTargetByClass(
163 ilObjBibliographicGUI::class,
170 $view_controls[] = $this->ui_factory->viewControl()->pagination()
171 ->withTargetURL($this->
http->request()->getRequestTarget(), self::P_PAGE)
172 ->withTotalEntries(count($records))
173 ->withPageSize($this->entries_per_page)
174 ->withCurrentPage($this->current_page);
176 return $this->ui_factory->table()->presentation(
185 $record[
'author'] = empty($record[
'author']) ? null : $record[
'author'];
186 $record[
'title'] = empty($record[
'title']) ? null : $record[
'title'];
187 $record[
'year'] = empty($record[
'year']) ? null : $record[
'year'];
189 $author = $record[
'autor'] = $record[
'author'] ?? $record[
'AU'] ??
'';
190 $title = ($record[
'title'] ??= $record[
'TI'] ??
'');
191 $year = ($record[
'year'] ??= $record[
'PY'] ??
'');
192 $entry_id = $record[
'entry_id'];
194 unset($record[
'author'], $record[
'title'], $record[
'AU'], $record[
'TI'], $record[
'entry_id']);
196 $translated_record = $this->getRecordWithTranslatedKeys($record);
197 $clickable_translated_record = array_map(
198 fn($value) => $this->string_transform->makeClickable()->transform($value),
202 $this->
ctrl->setParameterByClass(ilObjBibliographicGUI::class,
'entry_id', $entry_id);
207 $this->ui_factory->button()->shy(
208 $this->lng->txt(
'detail_view'),
209 $this->ctrl->getLinkTargetByClass(
210 ilObjBibliographicGUI::class,
215 ->withSubheadline($author)
216 ->withImportantFields([$year])
218 ->withContent(
$ui_factory->listing()->descriptive($clickable_translated_record));
220 )->withData($records_current_page);
223 protected function getData(): array
227 $filter_data = ($this->
filter !==
null) ? ($this->ui_service->filter()->getData($this->
filter) ?? []) : [];
228 foreach ($filter_data as $field_name => $field_value) {
229 if (empty($field_value)) {
232 if (is_array($field_value) && $field_value === []) {
235 $filter = $this->filter_objects[$field_name];
237 $filter_info->setFieldName($field_name);
238 switch (
$filter->getFilterType()) {
240 $filter_info->setFieldValue($field_value);
241 $filter_info->setOperator(
"IN");
244 $filter_info->setFieldValue($field_value);
245 $filter_info->setOperator(
"=");
248 $filter_info->setFieldValue(
"%$field_value%");
249 $filter_info->setOperator(
"LIKE");
253 $query->addFilter($filter_info);
257 $object_id = $this->facade->iliasObjId();
258 $entries = $this->facade->entryFactory()->filterEntryIdsForTableAsArray($object_id, $query);
260 foreach ($entries as $entry) {
262 $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString(
266 $entry_attributes = $this->facade->attributeFactory()->getAttributesForEntry($bibl_entry);
267 $sorted_attributes = $this->facade->attributeFactory()->sortAttributes($entry_attributes);
269 $entry_data[
'entry_id'] = $entry[
'entry_id'];
270 foreach ($sorted_attributes as $sorted_attribute) {
271 $entry_data[$sorted_attribute->getName()] = $sorted_attribute->getValue();
273 $entry_data[
'author'] ??= $entry_data[
'AU'] ?? $entry_data[
'A1'] ?? $entry_data[
'A2'] ??
'';
274 $entry_data[
'title'] ??= $entry_data[
'T1'] ?? $entry_data[
'T2'] ??
'';
275 $entry_data[
'year'] ??= $entry_data[
'PY'] ?? $entry_data[
'Y1'] ??
'';
276 $bibl_data[] = $entry_data;
286 $sortation_string = $sortation_mapping[$sortation];
287 $sortation_parts = explode(
' ', (
string) $sortation_string);
288 $sortation_field = array_column($records, $sortation_parts[0]);
289 $sortation_direction = ($sortation_parts[1] ===
'ASC') ? SORT_ASC : SORT_DESC;
290 array_multisort($sortation_field, $sortation_direction, $records);
296 $offset = array_search($this->current_page * $this->entries_per_page, array_keys($records),
true);
298 return array_slice($records, $offset, $length);
301 protected function getRecordWithTranslatedKeys(array $record): array
303 $record = $this->facade->attributeFactory()->sortAttributesArray($record);
305 $translated_record = [];
306 foreach ($record as $key => $value) {
309 $translated_key = $key;
310 if ($field !==
null) {
311 $translated_key = $this->facade->translationFactory()->translate($field);
313 $translated_record[$translated_key] = $value;
315 return $translated_record;
320 return $this->
http->wrapper()->query()->has(self::P_PAGE)
321 ? $this->
http->wrapper()->query()->retrieve(self::P_PAGE, $this->
refinery->kindlyTo()->int())
327 return $this->
http->wrapper()->query()->has(self::P_SORTATION)
328 ? $this->
http->wrapper()->query()->retrieve(self::P_SORTATION, $this->
refinery->kindlyTo()->int())
335 self::SORTATION_BY_TITLE_ASC =>
'title ASC',
336 self::SORTATION_BY_TITLE_DESC =>
'title DESC',
337 self::SORTATION_BY_AUTHOR_ASC =>
'author ASC',
338 self::SORTATION_BY_AUTHOR_DESC =>
'author DESC',
339 self::SORTATION_BY_YEAR_ASC =>
'year ASC',
340 self::SORTATION_BY_YEAR_DESC =>
'year DESC'
static where($where, $operator=null)
Provides fluid interface to RBAC services.
Builds a Color from either hex- or rgb values.
readonly ilUIService $ui_service
const SORTATION_BY_AUTHOR_DESC
readonly Renderer $ui_renderer
readonly Factory $refinery
__construct(protected ilObjBibliographicGUI $a_parent_obj, protected ilBiblFactoryFacade $facade, protected UIServices $ui)
renderLibraryButtons(int $entry_id)
const SORTATION_BY_TITLE_DESC
const SORTATION_BY_TITLE_ASC
getSortedRecords(array $records)
const SORTATION_BY_YEAR_DESC
readonly HttpServices $http
const SORTATION_BY_YEAR_ASC
const SORTATION_BY_AUTHOR_ASC
getRecordsOfCurrentPage(array $records)
ILIAS Refinery String Group $string_transform
readonly UIFactory $ui_factory
getRenderedTableAndExistingFilters()
readonly ilCtrlInterface $ctrl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBiblFieldFilterPresentationGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBiblLibraryPresentationGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjBibliographicGUI.
This describes a Presentation Table.
An entity that renders components to a string output.
const FILTER_TYPE_MULTI_SELECT_INPUT
const FILTER_TYPE_SELECT_INPUT
const FILTER_TYPE_TEXT_INPUT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)