ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Course\Table\TimingsView\DataRetrieval Class Reference
+ Inheritance diagram for ILIAS\Course\Table\TimingsView\DataRetrieval:
+ Collaboration diagram for ILIAS\Course\Table\TimingsView\DataRetrieval:

Public Member Functions

 __construct (protected readonly UIServices $ui, protected readonly ilObjUser $user, protected readonly int $user_id, protected readonly int $parent_object_ref_id,)
 
 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...
 
 getUsername ()
 
 getDateFormat ()
 
 getUsername ()
 
 getDateFormat ()
 
 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

 initRows ()
 

Protected Attributes

const string KEY_SUGGESTION = 'suggestion'
 
const string KEY_PLANNED = 'planned'
 
const string KEY_ROW_ID = 'row_id'
 
const string KEY_TITLE_LINK = 'title_link'
 
const string KEY_TITLE = 'title'
 
const string OBJECT_GROUP_TYPE = 'obgr'
 
array $rows
 
string $username
 

Detailed Description

Definition at line 39 of file DataRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Course\Table\TimingsView\DataRetrieval::__construct ( protected readonly UIServices  $ui,
protected readonly ilObjUser  $user,
protected readonly int  $user_id,
protected readonly int  $parent_object_ref_id 
)

Definition at line 50 of file DataRetrieval.php.

References ILIAS\Course\Table\TimingsView\DataRetrieval\initRows().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDateFormat()

ILIAS\Course\Table\TimingsView\DataRetrieval::getDateFormat ( )
final

Implements ILIAS\Course\I\Table\TimingsView\DataRetrievalInterface.

Definition at line 178 of file DataRetrieval.php.

178 : DateFormat
179 {
180 return $this->user->getDateFormat();
181 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Course\Table\TimingsView\DataRetrieval::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
final

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 124 of file DataRetrieval.php.

132 : Generator {
133 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
134 $comparator = match ($column_name) {
135 HandlerInterface::TABLE_COL_TITLE => fn(array $a, array $b) => strcmp($a[self::KEY_TITLE], $b[self::KEY_TITLE]),
137 default => fn(array $a, array $b) => 0
138 };
140 uasort($rows, $comparator);
141 if ($direction === "DESC") {
142 $rows = array_reverse($rows, true);
143 }
144 $rows = array_slice($rows, $range->getStart(), $range->getLength(), true);
145 foreach ($rows as $row) {
146 yield $row_builder->buildDataRow(
147 $row[self::KEY_ROW_ID] . '',
148 [
149 HandlerInterface::TABLE_COL_TITLE => $this->ui->factory()->link()->standard(
150 $row[self::KEY_TITLE],
151 $row[self::KEY_TITLE_LINK]
152 )
153 ->withDisabled(strcmp($row[self::KEY_TITLE_LINK], '') === 0),
154 HandlerInterface::TABLE_COL_SUGGESTION => $row[self::KEY_SUGGESTION],
155 HandlerInterface::TABLE_COL_TIMINGS_PLANNED => $row[self::KEY_PLANNED],
156 ]
157 );
158 }
159 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\Course\Table\TimingsView\DataRetrieval\KEY_PLANNED, ILIAS\Course\I\Table\TimingsView\HandlerInterface\TABLE_COL_SUGGESTION, ILIAS\Course\I\Table\TimingsView\HandlerInterface\TABLE_COL_TIMINGS_PLANNED, and ILIAS\Course\I\Table\TimingsView\HandlerInterface\TABLE_COL_TITLE.

◆ getTotalRowCount()

ILIAS\Course\Table\TimingsView\DataRetrieval::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)
final

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 161 of file DataRetrieval.php.

165 : ?int {
166 return count($this->rows);
167 }

◆ getUsername()

ILIAS\Course\Table\TimingsView\DataRetrieval::getUsername ( )
final

Implements ILIAS\Course\I\Table\TimingsView\DataRetrievalInterface.

Definition at line 169 of file DataRetrieval.php.

169 : string
170 {
171 if (!isset($this->username)) {
172 $name = ilObjUser::_lookupName($this->user_id);
173 $this->username = $name['lastname'] . ', ' . $name['firstname'];
174 }
175 return $this->username;
176 }
static _lookupName(int $a_user_id)

References ilObjUser\_lookupName().

+ Here is the call graph for this function:

◆ initRows()

ILIAS\Course\Table\TimingsView\DataRetrieval::initRows ( )
finalprotected

Definition at line 59 of file DataRetrieval.php.

59 : void
60 {
61 if (isset($this->rows)) {
62 return;
63 }
64 $this->rows = [];
65 $items = ilObjectActivation::getItems($this->parent_object_ref_id, false);
66 foreach ($items as $item) {
67 // hide objects without timings
68 if ($item['timing_type'] != ilObjectActivation::TIMINGS_PRESETTING) {
69 continue;
70 }
71 // no object groups
72 if ($item['type'] == self::OBJECT_GROUP_TYPE) {
73 continue;
74 }
75 # Title
77 $title = (
78 count($sess_values) > 0 &&
79 $item['type'] == 'sess' &&
80 !strlen($item['title'])
81 )
83 $sess_values['start'],
84 $sess_values['end'],
85 (bool) $sess_values['fullday']
86 )
87 : $item['title'];
88
89 # Title Link
90 $title_link = (in_array($item['type'], ['fold', 'grp', 'sess']))
91 ? ilLink::_getLink($item['ref_id'], $item['type'])
92 : '';
93
94 # Suggested Timing
95 $suggested = [
96 DateTimeImmutable::createFromTimestamp($item['suggestion_start']),
97 DateTimeImmutable::createFromTimestamp($item['suggestion_end']),
98 ];
99
100 # Planned Timing
101 $timing_user = new ilTimingUser($item['child'], $this->user_id);
102
103 $planned = (
104 ((int) $item['timing_type']) === ilObjectActivation::TIMINGS_PRESETTING &&
105 !is_null($timing_user->getStart()->get(IL_CAL_UNIX)) &&
106 !is_null($timing_user->getEnd()->get(IL_CAL_UNIX))
107 )
108 ? [
109 DateTimeImmutable::createFromTimestamp($timing_user->getStart()->get(IL_CAL_UNIX)),
110 DateTimeImmutable::createFromTimestamp($timing_user->getEnd()->get(IL_CAL_UNIX))
111 ]
112 : $suggested;
113
114 $this->rows[] = [
115 self::KEY_ROW_ID => $item['ref_id'],
116 self::KEY_TITLE => $title,
117 self::KEY_TITLE_LINK => $title_link,
118 self::KEY_PLANNED => $planned,
119 self::KEY_SUGGESTION => $suggested,
120 ];
121 }
122 }
const IL_CAL_UNIX
static getItems(int $parent_id, bool $with_list_data=true)
Get sub item data.
static _lookupObjId(int $ref_id)
static _lookupAppointment(int $a_obj_id)
static _appointmentToString(int $start, int $end, bool $fulltime)
TableGUI class for timings administration.

References ilSessionAppointment\_appointmentToString(), ilSessionAppointment\_lookupAppointment(), ilObject\_lookupObjId(), ilObjectActivation\getItems(), IL_CAL_UNIX, ILIAS\Repository\int(), and ilObjectActivation\TIMINGS_PRESETTING.

Referenced by ILIAS\Course\Table\TimingsView\DataRetrieval\__construct().

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

Field Documentation

◆ $rows

array ILIAS\Course\Table\TimingsView\DataRetrieval::$rows
protected

Definition at line 47 of file DataRetrieval.php.

◆ $username

string ILIAS\Course\Table\TimingsView\DataRetrieval::$username
protected

Definition at line 48 of file DataRetrieval.php.

◆ KEY_PLANNED

const string ILIAS\Course\Table\TimingsView\DataRetrieval::KEY_PLANNED = 'planned'
protected

◆ KEY_ROW_ID

const string ILIAS\Course\Table\TimingsView\DataRetrieval::KEY_ROW_ID = 'row_id'
protected

Definition at line 43 of file DataRetrieval.php.

◆ KEY_SUGGESTION

const string ILIAS\Course\Table\TimingsView\DataRetrieval::KEY_SUGGESTION = 'suggestion'
protected

Definition at line 41 of file DataRetrieval.php.

◆ KEY_TITLE

const string ILIAS\Course\Table\TimingsView\DataRetrieval::KEY_TITLE = 'title'
protected

Definition at line 45 of file DataRetrieval.php.

◆ KEY_TITLE_LINK

const string ILIAS\Course\Table\TimingsView\DataRetrieval::KEY_TITLE_LINK = 'title_link'
protected

Definition at line 44 of file DataRetrieval.php.

◆ OBJECT_GROUP_TYPE

const string ILIAS\Course\Table\TimingsView\DataRetrieval::OBJECT_GROUP_TYPE = 'obgr'
protected

Definition at line 46 of file DataRetrieval.php.


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