ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBiblLibraryTableGUI Class Reference
+ 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...
 
 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

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

Constructor & Destructor Documentation

◆ __construct()

ilBiblLibraryTableGUI::__construct ( private readonly ilBiblAdminLibraryFacadeInterface  $facade)

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

44 {
45 global $DIC;
46
47 $this->access = $DIC->access();
48 $this->ctrl = $DIC->ctrl();
49 $this->data_factory = new DataFactory();
50 $this->http_request = $DIC->http()->request();
51 $this->lng = $DIC->language();
52 $this->ui_factory = $DIC->ui()->factory();
53 $this->ui_renderer = $DIC->ui()->renderer();
54
55 $this->table = $this->buildTable();
56 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildTable()

ilBiblLibraryTableGUI::buildTable ( )
private

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

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

References ILIAS\Repository\lng().

Referenced by __construct().

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

◆ getColumns()

ilBiblLibraryTableGUI::getColumns ( )
private

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

81 : array
82 {
83 return [
84 'bibl_library_name' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_name')),
85 'bibl_library_url' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_url')),
86 'bibl_library_img' => $this->ui_factory->table()->column()->text($this->lng->txt('bibl_library_img'))
87 ];
88 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

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

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

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

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

+ Here is the call graph for this function:

◆ getRenderedTable()

ilBiblLibraryTableGUI::getRenderedTable ( )

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

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

◆ 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 153 of file class.ilBiblLibraryTableGUI.php.

160 : Generator {
161 $records = $this->getRecords($range, $order);
162 foreach ($records as $record) {
163 $row_id = (string) $record['bibl_library_id'];
164 yield $row_builder->buildDataRow($row_id, $record);
165 }
166 }
getRecords(?Range $range=null, ?Order $order=null)
buildDataRow(string $id, array $record)

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow().

+ 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 169 of file class.ilBiblLibraryTableGUI.php.

169 : ?int
170 {
171 return count($this->getRecords());
172 }

Field Documentation

◆ $access

ilAccessHandler ilBiblLibraryTableGUI::$access
private

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

◆ $ctrl

ilCtrlInterface ilBiblLibraryTableGUI::$ctrl
private

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

◆ $data_factory

DataFactory ilBiblLibraryTableGUI::$data_factory
private

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

◆ $http_request

HttpRequest ilBiblLibraryTableGUI::$http_request
private

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

◆ $lng

ilLanguage ilBiblLibraryTableGUI::$lng
private

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

◆ $table

DataTable ilBiblLibraryTableGUI::$table
private

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

◆ $ui_factory

UIFactory ilBiblLibraryTableGUI::$ui_factory
private

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

◆ $ui_renderer

UIRenderer ilBiblLibraryTableGUI::$ui_renderer
private

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


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