ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 
38  public function __construct(
39  protected ilObjBibliographicGUI $a_parent_obj,
40  protected ilBiblFactoryFacade $facade,
41  protected \ILIAS\DI\UIServices $ui
42  ) {
43  $this->setId('tbl_bibl_overview_' . $facade->iliasRefId());
44  $this->setPrefix('tbl_bibl_overview_' . $facade->iliasRefId());
45  $this->setFormName('tbl_bibl_overview_' . $facade->iliasRefId());
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(
115  $library,
116  $this->facade,
117  $this->ctrl,
118  $this->lng,
119  $this->ui
120  );
121  $arr_library_link[] = $presentation->getButton($this->facade, $presentation_gui->getEntry());
122  }
123  }
124  if ($arr_library_link !== []) {
125  $this->tpl->setVariable('LIBRARY_LINK', implode('<br/>', $arr_library_link));
126  }
127  }
128 
129 
130  protected function initData(): void
131  {
132  $query = new ilBiblTableQueryInfo();
136  foreach ($this->applied_filter as $field_name => $field_value) {
137  if (!$field_value || (is_array($field_value) && count($field_value) == 0)) {
138  continue;
139  }
140  $filter = $this->filter_objects[$field_name];
141  $filter_info = new ilBiblTableQueryFilter();
142  $filter_info->setFieldName($field_name);
143  switch ($filter->getFilterType()) {
145  $filter_info->setFieldValue($field_value);
146  $filter_info->setOperator("IN");
147  break;
149  $filter_info->setFieldValue($field_value);
150  $filter_info->setOperator("=");
151  break;
153  $filter_info->setFieldValue("%{$field_value}%");
154  $filter_info->setOperator("LIKE");
155  break;
156  }
157 
158  $query->addFilter($filter_info);
159  }
160 
161  $entries = [];
162  $object_id = $this->facade->iliasObjId();
163  foreach (
164  $this->facade->entryFactory()
165  ->filterEntryIdsForTableAsArray($object_id, $query) as $entry
166  ) {
168  $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString($entry['entry_id'], $entry['entry_type']);
169  $overview_gui = new ilBiblEntryTablePresentationGUI($bibl_entry, $this->facade);
170  $entry['content'] = strip_tags($overview_gui->getHtml());
171  $entry['overview_gui'] = $overview_gui;
172  $entries[] = $entry;
173  }
174 
175  usort($entries, function ($a, $b) {
176  return strcmp($a['content'], $b['content']);
177  });
178 
179  $this->setData($entries);
180  }
181 }
setData(array $a_data)
Class ilObjBibliographicGUI.
ILIAS DI UIServices $ui
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
Class ChatMainBarProvider .
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...
setFormName(string $a_name="")
addAndReadFilterItem(ilTableFilterItem $field)
setId(string $a_val)
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(protected ilObjBibliographicGUI $a_parent_obj, protected ilBiblFactoryFacade $facade, protected \ILIAS\DI\UIServices $ui)
ilBiblEntryTableGUI constructor.
__construct(VocabulariesInterface $vocabularies)
fillRow(array $a_set)
Standard Version of Fill Row.
setDefaultOrderField(string $a_defaultorderfield)
Class HTTPServicesTest.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setOrderField(string $a_order_field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setEnableNumInfo(bool $a_val)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
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)
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...
setEnableHeader(bool $a_enableheader)
setPrefix(string $a_prefix)