ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\AdministrativeNotification\DataRetrieval Class Reference
+ Inheritance diagram for ILIAS\AdministrativeNotification\DataRetrieval:
+ Collaboration diagram for ILIAS\AdministrativeNotification\DataRetrieval:

Public Member Functions

 __construct (protected bool $has_write_access,)
 
 getRows (I\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Protected Member Functions

 getRecords (Order $order)
 
 formatDate (DateTimeImmutable $timestamp)
 
 getLanguagesTextForNotification (array $record)
 

Private Attributes

ilLanguage $lng
 

Detailed Description

Definition at line 34 of file DataRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AdministrativeNotification\DataRetrieval::__construct ( protected bool  $has_write_access)

Definition at line 38 of file DataRetrieval.php.

40 {
41 global $DIC;
42 $this->lng = $DIC['lng'];
43 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ formatDate()

ILIAS\AdministrativeNotification\DataRetrieval::formatDate ( DateTimeImmutable  $timestamp)
protected

Definition at line 100 of file DataRetrieval.php.

100 : string
101 {
103 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

References $timestamp, ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ getLanguagesTextForNotification()

ILIAS\AdministrativeNotification\DataRetrieval::getLanguagesTextForNotification ( array  $record)
protected

Definition at line 105 of file DataRetrieval.php.

105 : string
106 {
107 $has_language_limitation = $record['has_language_limitation'];
108 $limited_to_languages = $record['limited_to_languages'];
109 // text is all by default
110 $languages_text = $this->lng->txt("all");
111 if ($has_language_limitation) {
112 // text is none in case the notification has a language limitation but no languages are specified
113 $languages_text = $this->lng->txt("none");
114 if (!empty($limited_to_languages)) {
115 $this->lng->loadLanguageModule("meta");
116 // text is comma separated list of languages if the notification has a language limitation
117 // and the languages have been specified
118 $languages_text = implode(
119 ', ',
120 array_map(
121 fn(string $lng_code): string => $this->lng->txt("meta_l_" . $lng_code),
122 $limited_to_languages
123 )
124 );
125 }
126 }
127 return $languages_text;
128 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\AdministrativeNotification\DataRetrieval::getRecords ( Order  $order)
protected

Definition at line 66 of file DataRetrieval.php.

66 : array
67 {
68 $records = ilADNNotification::getArray();
69
70 // populate with additional data
71 array_walk($records, function (array &$record): void {
72 $record['languages'] = $this->getLanguagesTextForNotification($record);
73 $record['type'] = $this->lng->txt("msg_type_" . $record['type']);
74 $record['event_start'] = $this->formatDate($record['event_start']);
75 $record['event_end'] = $this->formatDate($record['event_end']);
76 $record['display_start'] = $this->formatDate($record['display_start']);
77 $record['display_end'] = $this->formatDate($record['display_end']);
78
79 $record['type_during_event'] = $record['permanent'] ? '' : $this->lng->txt("msg_type_" . $record['type_during_event']);
80 });
81
82 // sort
83 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value): array => [$key, $value]);
84 usort($records, fn($a, $b): int => $a[$order_field] <=> $b[$order_field]);
85 if ($order_direction === 'DESC') {
86 return array_reverse($records);
87 }
88
89 return $records;
90 }
static getArray(?string $key=null, string|array|null $values=null)
formatDate(DateTimeImmutable $timestamp)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ActiveRecord\getArray(), ILIAS\Data\Order\join(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\AdministrativeNotification\DataRetrieval::getRows ( I\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 45 of file DataRetrieval.php.

53 : \Generator {
54 $records = $this->getRecords($order);
55 foreach ($records as $record) {
56 $row_id = (string) $record['id'];
57
58 yield $row_builder->buildDataRow($row_id, $record)
59 ->withDisabledAction(Table::ACTION_DUPLICATE, !$this->has_write_access)
60 ->withDisabledAction(Table::ACTION_EDIT, !$this->has_write_access)
61 ->withDisabledAction(Table::ACTION_DELETE, !$this->has_write_access)
62 ->withDisabledAction(Table::ACTION_RESET, !$this->has_write_access);
63 }
64 }

References ILIAS\AdministrativeNotification\Table\ACTION_DELETE, ILIAS\AdministrativeNotification\Table\ACTION_DUPLICATE, ILIAS\AdministrativeNotification\Table\ACTION_EDIT, and ILIAS\AdministrativeNotification\Table\ACTION_RESET.

◆ getTotalRowCount()

ILIAS\AdministrativeNotification\DataRetrieval::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $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 92 of file DataRetrieval.php.

96 : ?int {
97 return count(ilADNNotification::getArray());
98 }

Field Documentation

◆ $lng

ilLanguage ILIAS\AdministrativeNotification\DataRetrieval::$lng
private

Definition at line 36 of file DataRetrieval.php.


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