60 $this->
ctrl = $DIC->ctrl();
61 $this->
http = $DIC->http();
62 $this->
lng = $DIC->language();
63 $this->ui_factory = $DIC->ui()->factory();
64 $this->ui_renderer = $DIC->ui()->renderer();
65 $this->ui_service = $DIC->uiService();
67 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_PAGE);
68 $this->
ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_SORTATION);
85 $filter_objects = $this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId());
86 if (empty($filter_objects)) {
90 $available_field_ids_for_object =
array_map(
92 $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId())
96 $filter_active_states = [];
97 foreach ($filter_objects as $filter_object) {
98 if (in_array($filter_object->getFieldId(), $available_field_ids_for_object,
true)) {
100 $field = $this->facade->fieldFactory()->findById($filter_object->getFieldId());
102 $filter_input = $filter_presentation->getFilterInput();
103 $filter_inputs[$post_var] = $filter_input;
104 $filter_active_states[] =
true;
105 $this->filter_objects[$post_var] = $filter_object;
109 return $this->ui_service->filter()->standard(
111 $this->
ctrl->getLinkTargetByClass(
112 ilObjBibliographicGUI::class,
118 $filter_active_states,
126 $entry = $this->facade->entryFactory()->findByIdAndTypeString(
128 $this->facade->type()->getStringRepresentation()
131 $settings = $this->facade->libraryFactory()->getAll();
132 if ($settings === []) {
138 foreach ($settings as $set) {
140 $buttons[$set->getName()] = $presentation->getButton($this->facade, $entry);
148 $records = $this->getData();
155 $sortations[$sort_id] = $this->
lng->txt(
'sorting_' . $sort_id);
157 if ($sortations !== []) {
158 $view_controls[] = $this->ui_factory->viewControl()->sortation($sortations, array_key_first($sortations))
160 $this->
ctrl->getLinkTargetByClass(
161 ilObjBibliographicGUI::class,
168 $view_controls[] = $this->ui_factory->viewControl()->pagination()
169 ->withTargetURL($this->
http->request()->getRequestTarget(), self::P_PAGE)
170 ->withTotalEntries(count($records))
171 ->withPageSize($this->entries_per_page)
172 ->withCurrentPage($this->current_page);
174 return $this->ui_factory->table()->presentation(
183 $record[
'author'] = empty($record[
'author']) ?
null : $record[
'author'];
184 $record[
'title'] = empty($record[
'title']) ?
null : $record[
'title'];
185 $record[
'year'] = empty($record[
'year']) ?
null : $record[
'year'];
187 $author = $record[
'autor'] = $record[
'author'] ?? $record[
'AU'] ??
'';
188 $title = ($record[
'title'] ??= $record[
'TI'] ??
'');
189 $year = ($record[
'year'] ??= $record[
'PY'] ??
'');
190 $entry_id = $record[
'entry_id'];
192 unset($record[
'author'], $record[
'title'], $record[
'AU'], $record[
'TI'], $record[
'entry_id']);
194 $translated_record = $this->getRecordWithTranslatedKeys($record);
196 $this->
ctrl->setParameterByClass(ilObjBibliographicGUI::class,
'entry_id', $entry_id);
201 $this->ui_factory->button()->shy(
202 $this->
lng->txt(
'detail_view'),
203 $this->
ctrl->getLinkTargetByClass(
204 ilObjBibliographicGUI::class,
209 ->withSubheadline($author)
210 ->withImportantFields([$year])
212 ->withContent($ui_factory->listing()->descriptive($translated_record));
214 )->withData($records_current_page);
217 protected function getData(): array
221 $filter_data = ($this->
filter !==
null) ? ($this->ui_service->filter()->getData($this->
filter) ?? []) : [];
222 foreach ($filter_data as $field_name => $field_value) {
223 if (empty($field_value)) {
226 if (is_array($field_value) && $field_value === []) {
229 $filter = $this->filter_objects[$field_name];
231 $filter_info->setFieldName($field_name);
232 switch ($filter->getFilterType()) {
234 $filter_info->setFieldValue($field_value);
235 $filter_info->setOperator(
"IN");
238 $filter_info->setFieldValue($field_value);
239 $filter_info->setOperator(
"=");
242 $filter_info->setFieldValue(
"%$field_value%");
243 $filter_info->setOperator(
"LIKE");
247 $query->addFilter($filter_info);
251 $object_id = $this->facade->iliasObjId();
252 $entries = $this->facade->entryFactory()->filterEntryIdsForTableAsArray($object_id, $query);
254 foreach ($entries as $entry) {
256 $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString(
260 $entry_attributes = $this->facade->attributeFactory()->getAttributesForEntry($bibl_entry);
261 $sorted_attributes = $this->facade->attributeFactory()->sortAttributes($entry_attributes);
263 $entry_data[
'entry_id'] = $entry[
'entry_id'];
264 foreach ($sorted_attributes as $sorted_attribute) {
265 $entry_data[$sorted_attribute->getName()] = $sorted_attribute->getValue();
267 $entry_data[
'author'] ??= $entry_data[
'AU'] ?? $entry_data[
'A1'] ?? $entry_data[
'A2'] ??
'';
268 $entry_data[
'title'] ??= $entry_data[
'T1'] ?? $entry_data[
'T2'] ??
'';
269 $entry_data[
'year'] ??= $entry_data[
'PY'] ?? $entry_data[
'Y1'] ??
'';
270 $bibl_data[] = $entry_data;
280 $sortation_string = $sortation_mapping[$sortation];
281 $sortation_parts = explode(
' ', (
string) $sortation_string);
282 $sortation_field = array_column($records, $sortation_parts[0]);
283 $sortation_direction = ($sortation_parts[1] ===
'ASC') ? SORT_ASC : SORT_DESC;
284 array_multisort($sortation_field, $sortation_direction, $records);
290 $offset = array_search($this->current_page * $this->entries_per_page, array_keys($records),
true);
292 return array_slice($records, $offset, $length);
295 protected function getRecordWithTranslatedKeys(array $record): array
297 $record = $this->facade->attributeFactory()->sortAttributesArray($record);
299 $translated_record = [];
300 foreach ($record as $key => $value) {
303 $translated_key = $key;
304 if ($field !==
null) {
305 $translated_key = $this->facade->translationFactory()->translate($field);
307 $translated_record[$translated_key] = $value;
309 return $translated_record;
314 return $this->
http->wrapper()->query()->has(self::P_PAGE)
315 ? $this->
http->wrapper()->query()->retrieve(self::P_PAGE, $this->
refinery->kindlyTo()->int())
321 return $this->
http->wrapper()->query()->has(self::P_SORTATION)
322 ? $this->
http->wrapper()->query()->retrieve(self::P_SORTATION, $this->
refinery->kindlyTo()->int())
329 self::SORTATION_BY_TITLE_ASC =>
'title ASC',
330 self::SORTATION_BY_TITLE_DESC =>
'title DESC',
331 self::SORTATION_BY_AUTHOR_ASC =>
'author ASC',
332 self::SORTATION_BY_AUTHOR_DESC =>
'author DESC',
333 self::SORTATION_BY_YEAR_ASC =>
'year ASC',
334 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.