ILIAS  release_8 Revision v8.24
class.ilBiblEntryTableGUI.php
Go to the documentation of this file.
1<?php
2
28{
32 protected array $filter_objects = array();
33 protected array $applied_filter = array();
34 protected \ilBiblFactoryFacade $facade;
35
40 {
41 $this->facade = $facade;
42 $this->setId('tbl_bibl_overview_' . $facade->iliasRefId());
43 $this->setPrefix('tbl_bibl_overview_' . $facade->iliasRefId());
44 $this->setFormName('tbl_bibl_overview_' . $facade->iliasRefId());
46 $this->parent_obj = $a_parent_obj;
47
48 //Number of records
49 $this->setEnableNumInfo(true);
50 $this->setShowRowsSelector(true);
51
52 $this->setEnableHeader(false);
53 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
54 $this->setRowTemplate('tpl.bibliographic_record_table_row.html', 'Modules/Bibliographic');
55 // enable sorting by alphabet -- therefore an unvisible column 'content' is added to the table, and the array-key 'content' is also delivered in setData
56 $this->addColumn($this->lng->txt('a'), 'content', 'auto');
57 $this->initFilter();
58 $this->setOrderField('content');
59 $this->setExternalSorting(true);
60 $this->initData();
61 $this->setDefaultOrderField('content');
62 }
63
64
65 public function initFilter(): void
66 {
67 $available_field_ids_for_object = array_map(function (ilBiblField $field) {
68 return $field->getId();
69 }, $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
70
71 foreach ($this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId()) as $item) {
72 if (in_array($item->getFieldId(), $available_field_ids_for_object)) {
73 $filter_presentation = new ilBiblFieldFilterPresentationGUI($item, $this->facade);
74 $field = $filter_presentation->getFilterItem();
75 $this->addAndReadFilterItem($field);
76 $this->filter_objects[$field->getPostVar()] = $item;
77 }
78 }
79 }
80
81
85 protected function addAndReadFilterItem(ilTableFilterItem $field): void
86 {
87 $this->addFilterItem($field);
88 $field->readFromSession();
89 if ($field instanceof ilCheckboxInputGUI) {
90 $this->applied_filter[$field->getPostVar()] = $field->getChecked();
91 ;
92 } else {
93 $this->applied_filter[$field->getPostVar()] = $field->getValue();
94 }
95 }
96
97
98 public function fillRow(array $a_set): void
99 {
101 $presentation_gui = $a_set['overview_gui'];
102 $this->tpl->setVariable(
103 'SINGLE_ENTRY',
104 $presentation_gui->getHtml()
105 );
106 //Detail-Link
107 $this->ctrl->setParameter($this->parent_obj, ilObjBibliographicGUI::P_ENTRY_ID, $a_set['entry_id']);
108 $this->tpl->setVariable('DETAIL_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'showDetails'));
109 // generate/render links to libraries
110 $libraries = $this->facade->libraryFactory()->getAll();
111 $arr_library_link = array();
112 foreach ($libraries as $library) {
113 if ($library->getShowInList()) {
114 $presentation = new ilBiblLibraryPresentationGUI($library, $this->facade);
115 $arr_library_link[] = $presentation->getButton($this->facade, $presentation_gui->getEntry());
116 }
117 }
118 if ($arr_library_link !== []) {
119 $this->tpl->setVariable('LIBRARY_LINK', implode('<br/>', $arr_library_link));
120 }
121 }
122
123
124 protected function initData(): void
125 {
130 foreach ($this->applied_filter as $field_name => $field_value) {
131 if (!$field_value || (is_array($field_value) && count($field_value) == 0)) {
132 continue;
133 }
134 $filter = $this->filter_objects[$field_name];
135 $filter_info = new ilBiblTableQueryFilter();
136 $filter_info->setFieldName($field_name);
137 switch ($filter->getFilterType()) {
139 $filter_info->setFieldValue($field_value);
140 $filter_info->setOperator("IN");
141 break;
143 $filter_info->setFieldValue($field_value);
144 $filter_info->setOperator("=");
145 break;
147 $filter_info->setFieldValue("%{$field_value}%");
148 $filter_info->setOperator("LIKE");
149 break;
150 }
151
152 $query->addFilter($filter_info);
153 }
154
155 $entries = [];
156 $object_id = $this->facade->iliasObjId();
157 foreach (
158 $this->facade->entryFactory()
159 ->filterEntryIdsForTableAsArray($object_id, $query) as $entry
160 ) {
162 $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString($entry['entry_id'], $entry['entry_type']);
163 $overview_gui = new ilBiblEntryTablePresentationGUI($bibl_entry, $this->facade);
164 $entry['content'] = strip_tags($overview_gui->getHtml());
165 $entry['overview_gui'] = $overview_gui;
166 $entries[] = $entry;
167 }
168
169 usort($entries, function ($a, $b) {
170 return strcmp($a['content'], $b['content']);
171 });
172
173 $this->setData($entries);
174 }
175}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addAndReadFilterItem(ilTableFilterItem $field)
__construct(ilObjBibliographicGUI $a_parent_obj, ilBiblFactoryFacade $facade)
ilBiblEntryTableGUI constructor.
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...
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...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
Class ilObjBibliographicGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setOrderField(string $a_order_field)
setEnableNumInfo(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
fillRow(array $a_set)
Standard Version of Fill Row.
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$query