ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\AdministrativeNotification\DataRetrieval Class Reference
+ Inheritance diagram for ILIAS\AdministrativeNotification\DataRetrieval:
+ Collaboration diagram for ILIAS\AdministrativeNotification\DataRetrieval:

Public Member Functions

 __construct ()
 
 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 32 of file DataRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AdministrativeNotification\DataRetrieval::__construct ( )

Definition at line 36 of file DataRetrieval.php.

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

37  {
38  global $DIC;
39  $this->lng = $DIC['lng'];
40  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ formatDate()

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

Definition at line 91 of file DataRetrieval.php.

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

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

91  : string
92  {
94  }
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 96 of file DataRetrieval.php.

References ILIAS\Repository\lng().

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

96  : string
97  {
98  $has_language_limitation = $record['has_language_limitation'];
99  $limited_to_languages = $record['limited_to_languages'];
100  // text is all by default
101  $languages_text = $this->lng->txt("all");
102  if ($has_language_limitation) {
103  // text is none in case the notification has a language limitation but no languages are specified
104  $languages_text = $this->lng->txt("none");
105  if (!empty($limited_to_languages)) {
106  $this->lng->loadLanguageModule("meta");
107  // text is comma separated list of languages if the notification has a language limitation
108  // and the languages have been specified
109  $languages_text = implode(
110  ', ',
111  array_map(
112  fn(string $lng_code): string => $this->lng->txt("meta_l_" . $lng_code),
113  $limited_to_languages
114  )
115  );
116  }
117  }
118  return $languages_text;
119  }
+ 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 58 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().

58  : array
59  {
60  $records = ilADNNotification::getArray();
61 
62  // populate with additional data
63  array_walk($records, function (array &$record): void {
64  $record['languages'] = $this->getLanguagesTextForNotification($record);
65  $record['type'] = $this->lng->txt("msg_type_" . $record['type']);
66  $record['event_start'] = $this->formatDate($record['event_start']);
67  $record['event_end'] = $this->formatDate($record['event_end']);
68  $record['display_start'] = $this->formatDate($record['display_start']);
69  $record['display_end'] = $this->formatDate($record['display_end']);
70 
71  $record['type_during_event'] = $record['permanent'] ? '' : $this->lng->txt("msg_type_" . $record['type_during_event']);
72  });
73 
74  // sort
75  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value): array => [$key, $value]);
76  usort($records, fn($a, $b): int => $a[$order_field] <=> $b[$order_field]);
77  if ($order_direction === 'DESC') {
78  return array_reverse($records);
79  }
80 
81  return $records;
82  }
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 42 of file DataRetrieval.php.

References ILIAS\AdministrativeNotification\DataRetrieval\getRecords().

49  : \Generator {
50  $records = $this->getRecords($order);
51  foreach ($records as $idx => $record) {
52  $row_id = (string) $record['id'];
53 
54  yield $row_builder->buildDataRow($row_id, $record);
55  }
56  }
+ Here is the call graph for this function:

◆ getTotalRowCount()

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

Definition at line 84 of file DataRetrieval.php.

References ActiveRecord\getArray().

87  : ?int {
88  return count(ilADNNotification::getArray());
89  }
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 34 of file DataRetrieval.php.


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