ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 

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.

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

40  {
41  global $DIC;
42  $this->lng = $DIC['lng'];
43  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ formatDate()

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

Definition at line 98 of file DataRetrieval.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

Referenced by ILIAS\AdministrativeNotification\DataRetrieval\getRecords().

98  : string
99  {
100  return ilDatePresentation::formatDate(new ilDateTime($timestamp->getTimestamp(), IL_CAL_UNIX));
101  }
const IL_CAL_UNIX
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLanguagesTextForNotification()

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

Definition at line 103 of file DataRetrieval.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\AdministrativeNotification\DataRetrieval\getRecords().

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

◆ getRecords()

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

Definition at line 65 of file DataRetrieval.php.

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

Referenced by ILIAS\AdministrativeNotification\DataRetrieval\getRows().

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

◆ getRows()

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

Definition at line 45 of file DataRetrieval.php.

References ILIAS\AdministrativeNotification\Table\ACTION_DELETE, ILIAS\AdministrativeNotification\Table\ACTION_DUPLICATE, ILIAS\AdministrativeNotification\Table\ACTION_EDIT, ILIAS\AdministrativeNotification\Table\ACTION_RESET, and ILIAS\AdministrativeNotification\DataRetrieval\getRecords().

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

◆ getTotalRowCount()

ILIAS\AdministrativeNotification\DataRetrieval::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 91 of file DataRetrieval.php.

References ActiveRecord\getArray().

94  : ?int {
95  return count(ilADNNotification::getArray());
96  }
static getArray(?string $key=null, string|array|null $values=null)
+ Here is the call graph for this function:

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: