58 $this->
ctrl = $DIC->ctrl();
59 $this->
http = $DIC->http();
60 $this->
lng = $DIC->language();
61 $this->ui_factory = $DIC->ui()->factory();
62 $this->ui_renderer = $DIC->ui()->renderer();
63 $this->ui_service = $DIC->uiService();
65 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_PAGE);
66 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_SORTATION);
83 $filter_objects = $this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId());
84 if (empty($filter_objects)) {
88 $available_field_ids_for_object =
array_map(
static fn(
ilBiblField $field): ?
int => $field->
getId(), $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
91 $filter_active_states = [];
92 foreach ($filter_objects as $filter_object) {
93 if (in_array($filter_object->getFieldId(), $available_field_ids_for_object,
true)) {
95 $field = $this->facade->fieldFactory()->findById($filter_object->getFieldId());
97 $filter_input = $filter_presentation->getFilterInput();
98 $filter_inputs[$post_var] = $filter_input;
99 $filter_active_states[] =
true;
100 $this->filter_objects[$post_var] = $filter_object;
104 return $this->ui_service->filter()->standard(
106 $this->
ctrl->getLinkTargetByClass(
107 ilObjBibliographicGUI::class,
113 $filter_active_states,
121 $entry = $this->facade->entryFactory()->findByIdAndTypeString($entry_id, $this->facade->type()->getStringRepresentation());
123 $settings = $this->facade->libraryFactory()->getAll();
124 if ($settings === []) {
130 foreach ($settings as $set) {
132 $buttons[$set->getName()] = $presentation->getButton($this->facade, $entry);
140 $records = $this->getData();
147 $sortations[$sort_id] = $this->
lng->txt(
'sorting_' . $sort_id);
149 $view_controls[] = $this->ui_factory->viewControl()->sortation($sortations)
153 )->withLabel($this->
lng->txt(
'sorting_' . $this->determineSortation()));
154 $view_controls[] = $this->ui_factory->viewControl()->pagination()
155 ->withTargetURL($this->
http->request()->getRequestTarget(), self::P_PAGE)
156 ->withTotalEntries(count($records))
157 ->withPageSize($this->entries_per_page)
158 ->withCurrentPage($this->current_page);
160 return $this->ui_factory->table()->presentation(
169 $record[
'author'] = empty($record[
'author']) ?
null : $record[
'author'];
170 $record[
'title'] = empty($record[
'title']) ?
null : $record[
'title'];
171 $record[
'year'] = empty($record[
'year']) ?
null : $record[
'year'];
173 $author = $record[
'autor'] = $record[
'author'] ?? $record[
'AU'] ??
'';
174 $title = ($record[
'title'] ??= $record[
'TI'] ??
'');
175 $year = ($record[
'year'] ??= $record[
'PY'] ??
'');
176 $entry_id = $record[
'entry_id'];
178 unset($record[
'author'], $record[
'title'], $record[
'AU'], $record[
'TI'], $record[
'entry_id']);
179 $translated_record = $this->getRecordWithTranslatedKeys($record);
183 ->withSubheadline($author)
184 ->withImportantFields([$year])
186 ->withContent($ui_factory->listing()->descriptive($translated_record));
188 )->withData($records_current_page);
192 protected function getData(): array
196 $filter_data = ($this->
filter !==
null) ? ($this->ui_service->filter()->getData($this->
filter) ?? []) : [];
197 foreach ($filter_data as $field_name => $field_value) {
198 if (empty($field_value)) {
201 if (is_array($field_value) && $field_value === []) {
204 $filter = $this->filter_objects[$field_name];
206 $filter_info->setFieldName($field_name);
207 switch ($filter->getFilterType()) {
209 $filter_info->setFieldValue($field_value);
210 $filter_info->setOperator(
"IN");
213 $filter_info->setFieldValue($field_value);
214 $filter_info->setOperator(
"=");
217 $filter_info->setFieldValue(
"%$field_value%");
218 $filter_info->setOperator(
"LIKE");
222 $query->addFilter($filter_info);
226 $object_id = $this->facade->iliasObjId();
227 $entries = $this->facade->entryFactory()->filterEntryIdsForTableAsArray($object_id, $query);
229 foreach ($entries as $entry) {
231 $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString($entry[
'entry_id'], $entry[
'entry_type']);
232 $entry_attributes = $this->facade->attributeFactory()->getAttributesForEntry($bibl_entry);
233 $sorted_attributes = $this->facade->attributeFactory()->sortAttributes($entry_attributes);
235 $entry_data[
'entry_id'] = $entry[
'entry_id'];
236 foreach ($sorted_attributes as $sorted_attribute) {
237 $entry_data[$sorted_attribute->getName()] = $sorted_attribute->getValue();
239 if (!array_key_exists(
'author', $entry_data)) {
240 $entry_data[
'author'] =
'';
242 if (!array_key_exists(
'title', $entry_data)) {
243 $entry_data[
'title'] =
'';
245 if (!array_key_exists(
'year', $entry_data)) {
246 $entry_data[
'year'] =
'';
248 $bibl_data[] = $entry_data;
258 $sortation_string = $sortation_mapping[$sortation];
259 $sortation_parts = explode(
' ', (
string) $sortation_string);
260 $sortation_field = array_column($records, $sortation_parts[0]);
261 $sortation_direction = ($sortation_parts[1] ===
'ASC') ? SORT_ASC : SORT_DESC;
262 array_multisort($sortation_field, $sortation_direction, $records);
269 $offset = array_search($this->current_page * $this->entries_per_page, array_keys($records),
true);
271 return array_slice($records, $offset, $length);
275 protected function getRecordWithTranslatedKeys(array $record): array
277 $translated_record = [];
278 foreach ($record as $key => $value) {
281 $translated_key = $key;
282 if ($field !==
null) {
283 $translated_key = $this->facade->translationFactory()->translate($field);
285 $translated_record[$translated_key] = $value;
287 return $translated_record;
293 return $this->
http->wrapper()->query()->has(self::P_PAGE)
294 ? $this->
http->wrapper()->query()->retrieve(self::P_PAGE, $this->
refinery->kindlyTo()->int())
300 return $this->
http->wrapper()->query()->has(self::P_SORTATION)
301 ? $this->
http->wrapper()->query()->retrieve(self::P_SORTATION, $this->
refinery->kindlyTo()->int())
308 self::SORTATION_BY_TITLE_ASC =>
'title ASC',
309 self::SORTATION_BY_TITLE_DESC =>
'title DESC',
310 self::SORTATION_BY_AUTHOR_ASC =>
'author ASC',
311 self::SORTATION_BY_AUTHOR_DESC =>
'author DESC',
312 self::SORTATION_BY_YEAR_ASC =>
'year ASC',
313 self::SORTATION_BY_YEAR_DESC =>
'year DESC' const FILTER_TYPE_TEXT_INPUT
readonly UIFactory $ui_factory
readonly ilCtrlInterface $ctrl
Class ilObjBibliographicGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly HttpServices $http
readonly ilUIService $ui_service
__construct(protected ilObjBibliographicGUI $a_parent_obj, protected ilBiblFactoryFacade $facade, protected UIServices $ui)
Class ilBiblFieldFilterPresentationGUI.
const SORTATION_BY_YEAR_ASC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const FILTER_TYPE_MULTI_SELECT_INPUT
const SORTATION_BY_AUTHOR_DESC
static where($where, $operator=null)
readonly Factory $refinery
getSortedRecords(array $records)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides fluid interface to RBAC services.
static http()
Fetches the global http state from ILIAS.
renderLibraryButtons(int $entry_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly Renderer $ui_renderer
getRecordsOfCurrentPage(array $records)
getRenderedTableAndExistingFilters()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SORTATION_BY_TITLE_DESC
const SORTATION_BY_YEAR_DESC
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
const SORTATION_BY_AUTHOR_ASC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const FILTER_TYPE_SELECT_INPUT
const SORTATION_BY_TITLE_ASC
Class ilBiblLibraryPresentationGUI.