ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBiblEntryTableGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
33 protected $filter_objects = array();
37 protected $applied_filter = array();
41 protected $facade;
45 protected $parent_obj;
46
47
55 {
56 $this->facade = $facade;
57 $this->setId('tbl_bibl_overview_' . $facade->iliasRefId());
58 $this->setPrefix('tbl_bibl_overview_' . $facade->iliasRefId());
59 $this->setFormName('tbl_bibl_overview_' . $facade->iliasRefId());
60 parent::__construct($a_parent_obj);
61 $this->parent_obj = $a_parent_obj;
62
63 //Number of records
64 $this->setEnableNumInfo(true);
65 $this->setShowRowsSelector(true);
66
67 $this->setEnableHeader(false);
68 $this->setFormAction($this->ctrl()->getFormAction($a_parent_obj));
69 $this->setRowTemplate('tpl.bibliographic_record_table_row.html', 'Modules/Bibliographic');
70 // enable sorting by alphabet -- therefore an unvisible column 'content' is added to the table, and the array-key 'content' is also delivered in setData
71 $this->addColumn($this->lng()->txt('a'), 'content', 'auto');
72 $this->initFilter();
73 $this->setOrderField('content');
74 $this->setExternalSorting(true);
75 $this->initData();
76 $this->setDefaultOrderField('content');
77 }
78
79
80 public function initFilter()
81 {
82 $available_fields_for_object = $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId());
83
84 foreach ($available_fields_for_object as $available_field) {
85 $filter = $this->facade->filterFactory()->findByFieldId($available_field->getId());
86 if (!empty($filter)) {
87 $filter_presentation = new ilBiblFieldFilterPresentationGUI($filter, $this->facade);
88 $field = $filter_presentation->getFilterItem();
89 $this->addAndReadFilterItem($field);
90 $this->filter_objects[$field->getPostVar()] = $filter;
91 }
92 }
93 }
94
95
99 protected function addAndReadFilterItem(ilTableFilterItem $field)
100 {
101 $this->addFilterItem($field);
102 $field->readFromSession();
103 if ($field instanceof ilCheckboxInputGUI) {
104 $this->applied_filter[$field->getPostVar()] = $field->getChecked();
105 ;
106 } else {
107 $this->applied_filter[$field->getPostVar()] = $field->getValue();
108 }
109 }
110
111
115 public function fillRow($a_set)
116 {
118 $presentation_gui = $a_set['overview_gui'];
119 $this->tpl->setVariable(
120 'SINGLE_ENTRY',
122 $presentation_gui->getHtml()
123 )
124 );
125 //Detail-Link
126 $this->ctrl->setParameter($this->parent_obj, ilObjBibliographicGUI::P_ENTRY_ID, $a_set['entry_id']);
127 $this->tpl->setVariable('DETAIL_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'showDetails'));
128 // generate/render links to libraries
129 $libraries = $this->facade->libraryFactory()->getAll();
130 $arr_library_link = array();
131 foreach ($libraries as $library) {
132 if ($library->getShowInList()) {
133 $presentation = new ilBiblLibraryPresentationGUI($library, $this->facade);
134 $arr_library_link[] = $presentation->getButton($this->facade, $presentation_gui->getEntry());
135 }
136 }
137 if (count($arr_library_link)) {
138 $this->tpl->setVariable('LIBRARY_LINK', implode('<br/>', $arr_library_link));
139 }
140 }
141
142
143 protected function initData()
144 {
149 foreach ($this->applied_filter as $field_name => $field_value) {
150 if (!$field_value || (is_array($field_value) && count($field_value) == 0)) {
151 continue;
152 }
153 $filter = $this->filter_objects[$field_name];
154 $filter_info = new ilBiblTableQueryFilter();
155 $filter_info->setFieldName($field_name);
156 switch ($filter->getFilterType()) {
158 $filter_info->setFieldValue($field_value);
159 $filter_info->setOperator("IN");
160 break;
162 $filter_info->setFieldValue($field_value);
163 $filter_info->setOperator("=");
164 break;
166 $filter_info->setFieldValue("%{$field_value}%");
167 $filter_info->setOperator("LIKE");
168 break;
169 }
170
171 $query->addFilter($filter_info);
172 }
173
174 $entries = [];
175 $object_id = $this->facade->iliasObjId();
176 foreach (
177 $this->facade->entryFactory()
178 ->filterEntryIdsForTableAsArray($object_id, $query) as $entry
179 ) {
181 $bibl_entry = $this->facade->entryFactory()->findByIdAndTypeString($entry['entry_id'], $entry['entry_type']);
182 $overview_gui = new ilBiblEntryTablePresentationGUI($bibl_entry, $this->facade);
183 $entry['content'] = strip_tags($overview_gui->getHtml());
184 $entry['overview_gui'] = $overview_gui;
185 $entries[] = $entry;
186 }
187
188 usort($entries, function ($a, $b) {
189 return $a['content'] > $b['content'];
190 });
191
192 $this->setData($entries);
193 }
194}
An exception for terminatinating execution or to throw for unit testing.
static prepareLatex($string)
This feature has to be discussed by JF first.
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...
Class ilBiblFactoryFacade.
Class ilBiblFieldFilterPresentationGUI.
Class ilBiblLibraryPresentationGUI.
Class ilBiblTableQueryInfo.
Class ilBiblTableQueryInfo.
This class represents a checkbox property in a property form.
Class ilObjBibliographicGUI.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
fillRow($a_set)
Standard Version of Fill Row.
getFormAction()
Get Form action parameter.
setData($a_data)
set table data @access public
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setOrderField($a_order_field)
set order column
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
Interface for property form input GUI classes that can be used in table filters.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$query