ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 55 of file class.ilBiblEntryTableGUI.php.

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

56  {
57  global $DIC;
58  $this->ctrl = $DIC->ctrl();
59  $this->http = $DIC->http();
60  $this->lng = $DIC->language();
61  $this->ui_factory = $DIC->ui()->factory();
62  $this->ui_renderer = $DIC->ui()->renderer();
63  $this->ui_service = $DIC->uiService();
64  $this->refinery = $DIC->refinery();
65  $this->ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_PAGE);
66  $this->ctrl->saveParameterByClass(ilObjBibliographicGUI::class, self::P_SORTATION);
67 
68  $this->filter = $this->buildFilter();
69  $this->table = $this->buildTable();
70  }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildFilter()

ilBiblEntryTableGUI::buildFilter ( )
protected

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

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

Referenced by __construct().

82  {
83  $filter_objects = $this->facade->filterFactory()->getAllForObjectId($this->facade->iliasObjId());
84  if (empty($filter_objects)) {
85  return null;
86  }
87 
88  $available_field_ids_for_object = array_map(static fn(ilBiblField $field): ?int => $field->getId(), $this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
89 
90  $filter_inputs = [];
91  $filter_active_states = [];
92  foreach ($filter_objects as $filter_object) {
93  if (in_array($filter_object->getFieldId(), $available_field_ids_for_object, true)) {
94  $filter_presentation = new ilBiblFieldFilterPresentationGUI($filter_object, $this->facade);
95  $field = $this->facade->fieldFactory()->findById($filter_object->getFieldId());
96  $post_var = $field->getIdentifier();
97  $filter_input = $filter_presentation->getFilterInput();
98  $filter_inputs[$post_var] = $filter_input;
99  $filter_active_states[] = true;
100  $this->filter_objects[$post_var] = $filter_object;
101  }
102  }
103 
104  return $this->ui_service->filter()->standard(
105  'bibl_entry_filter',
106  $this->ctrl->getLinkTargetByClass(
107  ilObjBibliographicGUI::class,
109  "",
110  true
111  ),
112  $filter_inputs,
113  $filter_active_states,
114  true,
115  true
116  );
117  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBiblFieldFilterPresentationGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTable()

ilBiblEntryTableGUI::buildTable ( )
protected

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

References ilObjBibliographicGUI\CMD_SHOW_CONTENT, ILIAS\Repository\ctrl(), determinePage(), ILIAS\Repository\filter(), ilBiblFieldFilterInterface\FILTER_TYPE_MULTI_SELECT_INPUT, ilBiblFieldFilterInterface\FILTER_TYPE_SELECT_INPUT, ilBiblFieldFilterInterface\FILTER_TYPE_TEXT_INPUT, getRecordsOfCurrentPage(), getSortationsMapping(), getSortedRecords(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, renderLibraryButtons(), and ILIAS\UI\Implementation\Component\Table\PresentationRow\withHeadline().

Referenced by __construct().

139  {
140  $records = $this->getData();
141  $sorted_records = $this->getSortedRecords($records);
142  $this->current_page = $this->determinePage();
143  $records_current_page = $this->getRecordsOfCurrentPage($sorted_records);
144  $view_controls = [];
145  $sortations = [];
146  foreach (array_keys($this->getSortationsMapping()) as $sort_id) {
147  $sortations[$sort_id] = $this->lng->txt('sorting_' . $sort_id);
148  }
149  $view_controls[] = $this->ui_factory->viewControl()->sortation($sortations)
150  ->withTargetURL(
151  $this->ctrl->getLinkTargetByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::CMD_SHOW_CONTENT),
152  self::P_SORTATION
153  )->withLabel($this->lng->txt('sorting_' . $this->determineSortation()));
154  $view_controls[] = $this->ui_factory->viewControl()->pagination()
155  ->withTargetURL($this->http->request()->getRequestTarget(), self::P_PAGE)
156  ->withTotalEntries(count($records))
157  ->withPageSize($this->entries_per_page)
158  ->withCurrentPage($this->current_page);
159 
160  return $this->ui_factory->table()->presentation(
161  "",
162  $view_controls,
163  function (
164  PresentationRow $row,
165  array $record,
167  ): PresentationRow {
168  // Create row with fields and actions
169  $record['author'] = empty($record['author']) ? null : $record['author'];
170  $record['title'] = empty($record['title']) ? null : $record['title'];
171  $record['year'] = empty($record['year']) ? null : $record['year'];
172 
173  $author = $record['autor'] = $record['author'] ?? $record['AU'] ?? '';
174  $title = ($record['title'] ??= $record['TI'] ?? '');
175  $year = ($record['year'] ??= $record['PY'] ?? '');
176  $entry_id = $record['entry_id'];
177 
178  unset($record['author'], $record['title'], $record['AU'], $record['TI'], $record['entry_id']);
179  $translated_record = $this->getRecordWithTranslatedKeys($record);
180 
181  return $row
182  ->withHeadline($title)
183  ->withSubheadline($author)
184  ->withImportantFields([$year])
185  ->withFurtherFields($this->renderLibraryButtons($entry_id))
186  ->withContent($ui_factory->listing()->descriptive($translated_record));
187  }
188  )->withData($records_current_page);
189  }
readonly UIFactory $ui_factory
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
getRecordsOfCurrentPage(array $records)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determinePage()

ilBiblEntryTableGUI::determinePage ( )
private

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

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

Referenced by buildTable().

291  : int
292  {
293  return $this->http->wrapper()->query()->has(self::P_PAGE)
294  ? $this->http->wrapper()->query()->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
295  : 0;
296  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineSortation()

ilBiblEntryTableGUI::determineSortation ( )
private

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

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

Referenced by getSortedRecords().

298  : int
299  {
300  return $this->http->wrapper()->query()->has(self::P_SORTATION)
301  ? $this->http->wrapper()->query()->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->int())
302  : array_keys($this->getSortationsMapping())[0] ?? self::SORTATION_BY_TITLE_ASC;
303  }
static http()
Fetches the global http state from ILIAS.
+ 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 267 of file class.ilBiblEntryTableGUI.php.

References $entries_per_page, null, and ActiveRecord\where().

Referenced by buildTable().

267  : array
268  {
269  $offset = array_search($this->current_page * $this->entries_per_page, array_keys($records), true);
270  $length = $this->entries_per_page;
271  return array_slice($records, $offset, $length);
272  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRenderedTableAndExistingFilters()

ilBiblEntryTableGUI::getRenderedTableAndExistingFilters ( )

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

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

72  : string
73  {
74  if ($this->filter !== null) {
76  }
78  return $this->ui_renderer->render($components);
79  }
$components
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

◆ getSortationsMapping()

ilBiblEntryTableGUI::getSortationsMapping ( )

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

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

305  : array
306  {
307  return [
308  self::SORTATION_BY_TITLE_ASC => 'title ASC',
309  self::SORTATION_BY_TITLE_DESC => 'title DESC',
310  self::SORTATION_BY_AUTHOR_ASC => 'author ASC',
311  self::SORTATION_BY_AUTHOR_DESC => 'author DESC',
312  self::SORTATION_BY_YEAR_ASC => 'year ASC',
313  self::SORTATION_BY_YEAR_DESC => 'year DESC'
314  ];
315  }
+ Here is the caller graph for this function:

◆ getSortedRecords()

ilBiblEntryTableGUI::getSortedRecords ( array  $records)
protected

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

References determineSortation(), and getSortationsMapping().

Referenced by buildTable().

254  : array
255  {
256  $sortation = $this->determineSortation();
257  $sortation_mapping = $this->getSortationsMapping();
258  $sortation_string = $sortation_mapping[$sortation];
259  $sortation_parts = explode(' ', (string) $sortation_string);
260  $sortation_field = array_column($records, $sortation_parts[0]);
261  $sortation_direction = ($sortation_parts[1] === 'ASC') ? SORT_ASC : SORT_DESC;
262  array_multisort($sortation_field, $sortation_direction, $records);
263  return $records;
264  }
+ 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 119 of file class.ilBiblEntryTableGUI.php.

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

Referenced by buildTable().

119  : array
120  {
121  $entry = $this->facade->entryFactory()->findByIdAndTypeString($entry_id, $this->facade->type()->getStringRepresentation());
122 
123  $settings = $this->facade->libraryFactory()->getAll();
124  if ($settings === []) {
125  return [];
126  }
127 
128  $buttons = [];
129 
130  foreach ($settings as $set) {
131  $presentation = new ilBiblLibraryPresentationGUI($set, $this->facade, $this->ctrl, $this->lng, $this->ui);
132  $buttons[$set->getName()] = $presentation->getButton($this->facade, $entry);
133  }
134 
135  return $buttons;
136  }
Class ilBiblLibraryPresentationGUI.
+ 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 44 of file class.ilBiblEntryTableGUI.php.

◆ $current_page

int ilBiblEntryTableGUI::$current_page = 0
private

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

◆ $entries_per_page

int ilBiblEntryTableGUI::$entries_per_page = 10
private

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

Referenced by getRecordsOfCurrentPage().

◆ $filter

StandardFilter ilBiblEntryTableGUI::$filter
private

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

Referenced by getRenderedTableAndExistingFilters().

◆ $filter_objects

array ilBiblEntryTableGUI::$filter_objects = []
protected

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

◆ $http

readonly HttpServices ilBiblEntryTableGUI::$http
private

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

◆ $lng

readonly ilLanguage ilBiblEntryTableGUI::$lng
private

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

◆ $refinery

readonly Factory ilBiblEntryTableGUI::$refinery
private

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

◆ $table

PresentationTable ilBiblEntryTableGUI::$table
private

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

Referenced by getRenderedTableAndExistingFilters().

◆ $ui_factory

readonly UIFactory ilBiblEntryTableGUI::$ui_factory
private

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

◆ $ui_renderer

readonly Renderer ilBiblEntryTableGUI::$ui_renderer
private

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

◆ $ui_service

readonly ilUIService ilBiblEntryTableGUI::$ui_service
private

Definition at line 48 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.

◆ 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: