ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilBiblLibraryTableGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilBiblLibraryTableGUI:
+ Collaboration diagram for ilBiblLibraryTableGUI:

Public Member Functions

 __construct (private readonly ilBiblAdminLibraryFacadeInterface $facade)
 
 getRenderedTable ()
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Private Member Functions

 buildTable ()
 
 getColumns ()
 
 getRecords (Range $range=null, Order $order=null)
 

Private Attributes

ilAccessHandler $access
 
ilCtrlInterface $ctrl
 
DataFactory $data_factory
 
HttpRequest $http_request
 
ilLanguage $lng
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
DataTable $table
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Constructor & Destructor Documentation

◆ __construct()

ilBiblLibraryTableGUI::__construct ( private readonly ilBiblAdminLibraryFacadeInterface  $facade)

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

References $DIC, ILIAS\Repository\access(), buildTable(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

45  {
46  global $DIC;
47 
48  $this->access = $DIC->access();
49  $this->ctrl = $DIC->ctrl();
50  $this->data_factory = new DataFactory();
51  $this->http_request = $DIC->http()->request();
52  $this->lng = $DIC->language();
53  $this->ui_factory = $DIC->ui()->factory();
54  $this->ui_renderer = $DIC->ui()->renderer();
55 
56  $this->table = $this->buildTable();
57  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ buildTable()

ilBiblLibraryTableGUI::buildTable ( )
private

Definition at line 66 of file class.ilBiblLibraryTableGUI.php.

References getColumns(), ILIAS\Repository\lng(), ILIAS\UI\Implementation\Component\Table\withOrder(), and ILIAS\UI\Implementation\Component\Table\withRange().

Referenced by __construct().

66  : DataTable
67  {
68  return $this->ui_factory->table()->data(
69  $this->lng->txt('bibl_settings_libraries'),
70  $this->getColumns(),
71  $this
72  )->withActions(
73  $this->getActions()
74  )->withRange(
75  new Range(0, 10)
76  )->withOrder(
77  new Order('bibl_library_name', Order::ASC)
78  )->withRequest($this->http_request);
79  }
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ilBiblLibraryTableGUI::getColumns ( )
private

Definition at line 82 of file class.ilBiblLibraryTableGUI.php.

References $namespace, ILIAS\Repository\access(), ilBiblLibraryGUI\CMD_DELETE, ilBiblLibraryGUI\CMD_EDIT, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by buildTable().

82  : array
83  {
84  return [
85  'bibl_library_name' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_name')),
86  'bibl_library_url' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_url')),
87  'bibl_library_img' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_img'))
88  ];
89  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecords()

ilBiblLibraryTableGUI::getRecords ( Range  $range = null,
Order  $order = null 
)
private

Definition at line 176 of file class.ilBiblLibraryTableGUI.php.

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

Referenced by getRows(), and getTotalRowCount().

176  : array
177  {
178  $records = [];
179  $libraries = $this->facade->libraryFactory()->getAll();
180  foreach ($libraries as $library) {
181  $records[] = [
182  "bibl_library_id" => $library->getId(),
183  "bibl_library_name" => $library->getName(),
184  "bibl_library_url" => $library->getUrl(),
185  "bibl_library_img" => $library->getImg(),
186  ];
187  }
188 
189  if ($order) {
190  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
191  usort($records, static fn($a, $b) => $a[$order_field] <=> $b[$order_field]);
192  if ($order_direction === 'DESC') {
193  $records = array_reverse($records);
194  }
195  }
196  if ($range) {
197  $records = array_slice($records, $range->getStart(), $range->getLength());
198  }
199 
200  return $records;
201  }
join($init, callable $fn)
Definition: Order.php:59
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRenderedTable()

ilBiblLibraryTableGUI::getRenderedTable ( )

Definition at line 60 of file class.ilBiblLibraryTableGUI.php.

60  : string
61  {
62  return $this->ui_renderer->render([$this->table]);
63  }

◆ getRows()

ilBiblLibraryTableGUI::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 154 of file class.ilBiblLibraryTableGUI.php.

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), and getRecords().

161  : Generator {
162  $records = $this->getRecords($range, $order);
163  foreach ($records as $record) {
164  $row_id = (string) $record['bibl_library_id'];
165  yield $row_builder->buildDataRow($row_id, $record);
166  }
167  }
getRecords(Range $range=null, Order $order=null)
buildDataRow(string $id, array $record)
+ Here is the call graph for this function:

◆ getTotalRowCount()

ilBiblLibraryTableGUI::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 170 of file class.ilBiblLibraryTableGUI.php.

References getRecords().

170  : ?int
171  {
172  return count($this->getRecords());
173  }
getRecords(Range $range=null, Order $order=null)
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilBiblLibraryTableGUI::$access
private

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

◆ $ctrl

ilCtrlInterface ilBiblLibraryTableGUI::$ctrl
private

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

◆ $data_factory

DataFactory ilBiblLibraryTableGUI::$data_factory
private

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

◆ $http_request

HttpRequest ilBiblLibraryTableGUI::$http_request
private

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

◆ $lng

ilLanguage ilBiblLibraryTableGUI::$lng
private

Definition at line 38 of file class.ilBiblLibraryTableGUI.php.

◆ $table

DataTable ilBiblLibraryTableGUI::$table
private

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

◆ $ui_factory

UIFactory ilBiblLibraryTableGUI::$ui_factory
private

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

◆ $ui_renderer

UIRenderer ilBiblLibraryTableGUI::$ui_renderer
private

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


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