ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBiblEntryTableGUI Class Reference
+ Collaboration diagram for ilBiblEntryTableGUI:

Public Member Functions

 __construct (protected ilObjBibliographicGUI $a_parent_obj, protected ilBiblFactoryFacade $facade, protected UIServices $ui)
 
 getRenderedTableAndExistingFilters ()
 
 getSortationsMapping ()
 

Data Fields

const P_PAGE = 'page'
 
const P_SORTATION = 'sortation'
 
const SORTATION_BY_TITLE_ASC = 1
 
const SORTATION_BY_TITLE_DESC = 2
 
const SORTATION_BY_AUTHOR_ASC = 3
 
const SORTATION_BY_AUTHOR_DESC = 4
 
const SORTATION_BY_YEAR_ASC = 5
 
const SORTATION_BY_YEAR_DESC = 6
 

Protected Member Functions

 buildFilter ()
 
 buildTable ()
 
 getSortedRecords (array $records)
 
 getRecordsOfCurrentPage (array $records)
 

Protected Attributes

array $filter_objects = []
 

Private Member Functions

 renderLibraryButtons (int $entry_id)
 
 determinePage ()
 
 determineSortation ()
 

Private Attributes

readonly HttpServices $http
 
readonly ilLanguage $lng
 
readonly UIFactory $ui_factory
 
readonly Renderer $ui_renderer
 
readonly ilCtrlInterface $ctrl
 
readonly Factory $refinery
 
int $current_page = 0
 
int $entries_per_page = 10
 
readonly ilUIService $ui_service
 
StandardFilter $filter
 
PresentationTable $table
 

Detailed Description

Definition at line 28 of file class.ilBiblEntryTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilBiblEntryTableGUI::__construct ( protected ilObjBibliographicGUI  $a_parent_obj,
protected ilBiblFactoryFacade  $facade,
protected UIServices  $ui 
)

Definition at line 54 of file class.ilBiblEntryTableGUI.php.

58 {
59 global $DIC;
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();
66 $this->refinery = $DIC->refinery();
67 $this->ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_PAGE);
68 $this->ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_SORTATION);
69
70 $this->filter = $this->buildFilter();
71 $this->table = $this->buildTable();
72 }
static http()
Fetches the global http state from ILIAS.
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $DIC
Definition: shib_login.php:26

References $DIC, buildFilter(), buildTable(), ILIAS\Repository\ctrl(), ILIAS\Repository\filter(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildFilter()

ilBiblEntryTableGUI::buildFilter ( )
protected

Definition at line 83 of file class.ilBiblEntryTableGUI.php.

83 : ?StandardFilter
84 {
85 $filter_objects = $this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId());
86 if (empty($filter_objects)) {
87 return null;
88 }
89
90 $available_field_ids_for_object = array_map(
91 static fn(ilBiblField $field): ?int => $field->getId(),
92 $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId())
93 );
94
95 $filter_inputs = [];
96 $filter_active_states = [];
97 foreach ($filter_objects as $filter_object) {
98 if (in_array($filter_object->getFieldId(), $available_field_ids_for_object, true)) {
99 $filter_presentation = new ilBiblFieldFilterPresentationGUI($filter_object, $this->facade);
100 $field = $this->facade->fieldFactory()->findById($filter_object->getFieldId());
101 $post_var = $field->getIdentifier();
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;
106 }
107 }
108
109 return $this->ui_service->filter()->standard(
110 'bibl_entry_filter',
111 $this->ctrl->getLinkTargetByClass(
112 ilObjBibliographicGUI::class,
114 "",
115 true
116 ),
117 $filter_inputs,
118 $filter_active_states,
119 true,
120 true
121 );
122 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $filter_objects, ilObjBibliographicGUI\CMD_SHOW_CONTENT, ILIAS\Repository\ctrl(), ilBiblField\getId(), and ilBiblField\getIdentifier().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTable()

ilBiblEntryTableGUI::buildTable ( )
protected

Definition at line 146 of file class.ilBiblEntryTableGUI.php.

146 : PresentationTable
147 {
148 $records = $this->getData();
149 $sorted_records = $this->getSortedRecords($records);
150 $this->current_page = $this->determinePage();
151 $records_current_page = $this->getRecordsOfCurrentPage($sorted_records);
152 $view_controls = [];
153 $sortations = [];
154 foreach (array_keys($this->getSortationsMapping()) as $sort_id) {
155 $sortations[$sort_id] = $this->lng->txt('sorting_' . $sort_id);
156 }
157 if ($sortations !== []) {
158 $view_controls[] = $this->ui_factory->viewControl()->sortation($sortations, array_key_first($sortations))
159 ->withTargetURL(
160 $this->ctrl->getLinkTargetByClass(
161 ilObjBibliographicGUI::class,
163 ),
164 self::P_SORTATION
165 );
166 }
167
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);
173
174 return $this->ui_factory->table()->presentation(
175 "",
176 $view_controls,
177 function (
178 PresentationRow $row,
179 array $record,
180 UIFactory $ui_factory
181 ): PresentationRow {
182 // Create row with fields and actions
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'];
186
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'];
191
192 unset($record['author'], $record['title'], $record['AU'], $record['TI'], $record['entry_id']);
193
194 $translated_record = $this->getRecordWithTranslatedKeys($record);
195
196 $this->ctrl->setParameterByClass(ilObjBibliographicGUI::class, 'entry_id', $entry_id);
197
198 return $row
199 ->withHeadline($title)
200 ->withAction(
201 $this->ui_factory->button()->shy(
202 $this->lng->txt('detail_view'),
203 $this->ctrl->getLinkTargetByClass(
204 ilObjBibliographicGUI::class,
205 'showDetails'
206 )
207 )
208 )
209 ->withSubheadline($author)
210 ->withImportantFields([$year])
211 ->withFurtherFields($this->renderLibraryButtons($entry_id))
212 ->withContent($ui_factory->listing()->descriptive($translated_record));
213 }
214 )->withData($records_current_page);
215 }
getRecordsOfCurrentPage(array $records)
readonly UIFactory $ui_factory

References $ui_factory, ilObjBibliographicGUI\CMD_SHOW_CONTENT, ILIAS\Repository\ctrl(), determinePage(), getRecordsOfCurrentPage(), getSortationsMapping(), getSortedRecords(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), renderLibraryButtons(), and ILIAS\UI\Implementation\Component\Table\PresentationRow\withHeadline().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determinePage()

ilBiblEntryTableGUI::determinePage ( )
private

Definition at line 312 of file class.ilBiblEntryTableGUI.php.

312 : int
313 {
314 return $this->http->wrapper()->query()->has(self::P_PAGE)
315 ? $this->http->wrapper()->query()->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
316 : 0;
317 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by buildTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineSortation()

ilBiblEntryTableGUI::determineSortation ( )
private

Definition at line 319 of file class.ilBiblEntryTableGUI.php.

319 : int
320 {
321 return $this->http->wrapper()->query()->has(self::P_SORTATION)
322 ? $this->http->wrapper()->query()->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->int())
323 : array_keys($this->getSortationsMapping())[0] ?? self::SORTATION_BY_TITLE_ASC;
324 }

References getSortationsMapping(), ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and SORTATION_BY_TITLE_ASC.

Referenced by getSortedRecords().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecordsOfCurrentPage()

ilBiblEntryTableGUI::getRecordsOfCurrentPage ( array  $records)
protected

Definition at line 288 of file class.ilBiblEntryTableGUI.php.

288 : array
289 {
290 $offset = array_search($this->current_page * $this->entries_per_page, array_keys($records), true);
291 $length = $this->entries_per_page;
292 return array_slice($records, $offset, $length);
293 }

References $entries_per_page.

Referenced by buildTable().

+ Here is the caller graph for this function:

◆ getRenderedTableAndExistingFilters()

ilBiblEntryTableGUI::getRenderedTableAndExistingFilters ( )

Definition at line 74 of file class.ilBiblEntryTableGUI.php.

74 : string
75 {
76 if ($this->filter !== null) {
78 }
80 return $this->ui_renderer->render($components);
81 }
$components

References $components, $filter, $table, and ILIAS\Repository\filter().

+ Here is the call graph for this function:

◆ getSortationsMapping()

ilBiblEntryTableGUI::getSortationsMapping ( )

Definition at line 326 of file class.ilBiblEntryTableGUI.php.

326 : array
327 {
328 return [
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'
335 ];
336 }

Referenced by buildTable(), determineSortation(), and getSortedRecords().

+ Here is the caller graph for this function:

◆ getSortedRecords()

ilBiblEntryTableGUI::getSortedRecords ( array  $records)
protected

Definition at line 276 of file class.ilBiblEntryTableGUI.php.

276 : array
277 {
278 $sortation = $this->determineSortation();
279 $sortation_mapping = $this->getSortationsMapping();
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);
285 return $records;
286 }

References determineSortation(), and getSortationsMapping().

Referenced by buildTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderLibraryButtons()

ilBiblEntryTableGUI::renderLibraryButtons ( int  $entry_id)
private

Definition at line 124 of file class.ilBiblEntryTableGUI.php.

124 : array
125 {
126 $entry = $this->facade->entryFactory()->findByIdAndTypeString(
127 $entry_id,
128 $this->facade->type()->getStringRepresentation()
129 );
130
131 $settings = $this->facade->libraryFactory()->getAll();
132 if ($settings === []) {
133 return [];
134 }
135
136 $buttons = [];
137
138 foreach ($settings as $set) {
139 $presentation = new ilBiblLibraryPresentationGUI($set, $this->facade, $this->ctrl, $this->lng, $this->ui);
140 $buttons[$set->getName()] = $presentation->getButton($this->facade, $entry);
141 }
142
143 return $buttons;
144 }
Class ilBiblLibraryPresentationGUI.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by buildTable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

readonly ilCtrlInterface ilBiblEntryTableGUI::$ctrl
private

Definition at line 43 of file class.ilBiblEntryTableGUI.php.

◆ $current_page

int ilBiblEntryTableGUI::$current_page = 0
private

Definition at line 45 of file class.ilBiblEntryTableGUI.php.

◆ $entries_per_page

int ilBiblEntryTableGUI::$entries_per_page = 10
private

Definition at line 46 of file class.ilBiblEntryTableGUI.php.

Referenced by getRecordsOfCurrentPage().

◆ $filter

StandardFilter ilBiblEntryTableGUI::$filter
private

Definition at line 48 of file class.ilBiblEntryTableGUI.php.

Referenced by getRenderedTableAndExistingFilters().

◆ $filter_objects

array ilBiblEntryTableGUI::$filter_objects = []
protected

Definition at line 52 of file class.ilBiblEntryTableGUI.php.

Referenced by buildFilter().

◆ $http

readonly HttpServices ilBiblEntryTableGUI::$http
private

Definition at line 39 of file class.ilBiblEntryTableGUI.php.

◆ $lng

readonly ilLanguage ilBiblEntryTableGUI::$lng
private

Definition at line 40 of file class.ilBiblEntryTableGUI.php.

◆ $refinery

readonly Factory ilBiblEntryTableGUI::$refinery
private

Definition at line 44 of file class.ilBiblEntryTableGUI.php.

◆ $table

PresentationTable ilBiblEntryTableGUI::$table
private

Definition at line 49 of file class.ilBiblEntryTableGUI.php.

Referenced by getRenderedTableAndExistingFilters().

◆ $ui_factory

readonly UIFactory ilBiblEntryTableGUI::$ui_factory
private

Definition at line 41 of file class.ilBiblEntryTableGUI.php.

Referenced by buildTable().

◆ $ui_renderer

readonly Renderer ilBiblEntryTableGUI::$ui_renderer
private

Definition at line 42 of file class.ilBiblEntryTableGUI.php.

◆ $ui_service

readonly ilUIService ilBiblEntryTableGUI::$ui_service
private

Definition at line 47 of file class.ilBiblEntryTableGUI.php.

◆ P_PAGE

const ilBiblEntryTableGUI::P_PAGE = 'page'

Definition at line 30 of file class.ilBiblEntryTableGUI.php.

◆ P_SORTATION

const ilBiblEntryTableGUI::P_SORTATION = 'sortation'

Definition at line 31 of file class.ilBiblEntryTableGUI.php.

◆ SORTATION_BY_AUTHOR_ASC

const ilBiblEntryTableGUI::SORTATION_BY_AUTHOR_ASC = 3

Definition at line 34 of file class.ilBiblEntryTableGUI.php.

◆ SORTATION_BY_AUTHOR_DESC

const ilBiblEntryTableGUI::SORTATION_BY_AUTHOR_DESC = 4

Definition at line 35 of file class.ilBiblEntryTableGUI.php.

◆ SORTATION_BY_TITLE_ASC

const ilBiblEntryTableGUI::SORTATION_BY_TITLE_ASC = 1

Definition at line 32 of file class.ilBiblEntryTableGUI.php.

Referenced by determineSortation().

◆ SORTATION_BY_TITLE_DESC

const ilBiblEntryTableGUI::SORTATION_BY_TITLE_DESC = 2

Definition at line 33 of file class.ilBiblEntryTableGUI.php.

◆ SORTATION_BY_YEAR_ASC

const ilBiblEntryTableGUI::SORTATION_BY_YEAR_ASC = 5

Definition at line 36 of file class.ilBiblEntryTableGUI.php.

◆ SORTATION_BY_YEAR_DESC

const ilBiblEntryTableGUI::SORTATION_BY_YEAR_DESC = 6

Definition at line 37 of file class.ilBiblEntryTableGUI.php.


The documentation for this class was generated from the following file: