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

Public Member Functions

 __construct (protected readonly int $group_id)
 
 getSCTasks ()
 
 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...
 
 getAllActions ()
 
 getSCTasks ()
 
 getAllActions ()
 
 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

 getInactiveActions (ilSCTask $task)
 

Protected Attributes

array $sc_tasks
 
array $actions
 

Detailed Description

Definition at line 36 of file DataRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\SystemCheck\Table\Task\DataRetrieval::__construct ( protected readonly int  $group_id)

Definition at line 43 of file DataRetrieval.php.

45 {
46 }

Member Function Documentation

◆ getAllActions()

ILIAS\SystemCheck\Table\Task\DataRetrieval::getAllActions ( )
final
Returns
array<string, string>

Implements ILIAS\SystemCheck\I\Table\Task\DataRetrievalInterface.

Definition at line 135 of file DataRetrieval.php.

135 : array
136 {
137 if (isset($this->actions)) {
138 return $this->actions;
139 }
140 $this->actions = [];
141 foreach ($this->getSCTasks() as $task) {
142 $task_gui = ilSCComponentTaskFactory::getComponentTask($task->getId());
143 foreach ($task_gui->getActions() as $action) {
144 $this->actions[$action['command']] = $action['txt'];
145 }
146 }
147 return $this->actions;
148 }

References ilSCComponentTaskFactory\getComponentTask().

+ Here is the call graph for this function:

◆ getInactiveActions()

ILIAS\SystemCheck\Table\Task\DataRetrieval::getInactiveActions ( ilSCTask  $task)
finalprotected

Definition at line 150 of file DataRetrieval.php.

152 : array {
153 $active_actions = [];
155 foreach ($task_gui->getActions() as $action) {
156 $active_actions[$action['command']] = $action['txt'];
157 }
158 return array_diff(array_keys($this->getAllActions()), array_keys($active_actions));
159 }

◆ getRows()

ILIAS\SystemCheck\Table\Task\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 67 of file DataRetrieval.php.

75 : Generator {
76 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
77 $titles = $descriptions = $last_updates = $status = [];
78 foreach ($this->getSCTasks() as $task) {
79 $task_handler = ilSCComponentTaskFactory::getComponentTask($task->getId());
80 $titles[$task->getId()] = $task_handler->getTitle();
81 $descriptions[$task->getId()] = $task_handler->getDescription();
82 $last_updates[$task->getId()] = $task->getLastUpdate();
83 $status[$task->getId()] = $task->getStatus();
84 }
85 $comparator = match ($column_name) {
86 Handler::TABLE_COL_TITLE => function (ilSCTask $f1, ilSCTask $f2) use ($titles) {
87 return strcasecmp($titles[$f1->getId()], $titles[$f2->getId()]);
88 },
89 Handler::TABLE_COL_DESCRIPTION => function (ilSCTask $f1, ilSCTask $f2) use ($descriptions) {
90 return strcasecmp($descriptions[$f1->getId()], $descriptions[$f2->getId()]);
91 },
92 Handler::TABLE_COL_LAST_UPDATE => function (ilSCTask $f1, ilSCTask $f2) use ($last_updates) {
93 if (ilDateTime::_equals($last_updates[$f1->getId()], $last_updates[$f2->getId()])) {
94 return 0;
95 }
96 return ilDateTime::_before($last_updates[$f1->getId()], $last_updates[$f2->getId()]) ? -1 : 1;
97 },
98 Handler::TABLE_COL_STATUS => function (ilSCTask $f1, ilSCTask $f2) use ($status) {
99 return $status[$f1->getId()] - $status[$f2->getId()];
100 },
101 default => fn(ilSCTask $f1, ilSCTask $f2) => 0
102 };
103 $sc_tasks = $this->getSCTasks();
104 uasort($sc_tasks, $comparator);
105 if ($direction === "DESC") {
106 $sc_tasks = array_reverse($sc_tasks, true);
107 }
108 $sc_tasks = array_slice($sc_tasks, $range->getStart(), $range->getLength(), true);
109 foreach ($sc_tasks as $sc_task) {
110 $data_row = $row_builder->buildDataRow(
111 (string) $sc_task->getId(),
112 [
113 Handler::TABLE_COL_TITLE => $titles[$sc_task->getId()],
114 Handler::TABLE_COL_DESCRIPTION => $descriptions[$sc_task->getId()],
115 Handler::TABLE_COL_LAST_UPDATE => ilDatePresentation::formatDate($last_updates[$sc_task->getId()]),
116 Handler::TABLE_COL_STATUS => ilSCUtils::taskStatus2Text($status[$sc_task->getId()])
117 ]
118 );
119 foreach ($this->getInactiveActions($sc_task) as $action_name) {
120 $data_row = $data_row->withDisabledAction($action_name);
121 }
122 yield $data_row;
123 }
124 }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _equals(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
Check if two date are equal.
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Defines a system check task.
static taskStatus2Text(int $a_status)

References ilSCComponentTaskFactory\getComponentTask().

+ Here is the call graph for this function:

◆ getSCTasks()

ILIAS\SystemCheck\Table\Task\DataRetrieval::getSCTasks ( )
final
Returns
ilSCTask[]

Implements ILIAS\SystemCheck\I\Table\Task\DataRetrievalInterface.

Definition at line 51 of file DataRetrieval.php.

51 : array
52 {
53 if (isset($this->sc_tasks)) {
54 return $this->sc_tasks;
55 }
56
57 $this->sc_tasks = [];
58 foreach (ilSCTasks::getInstanceByGroupId($this->group_id)->getTasks() as $task) {
59 if (!$task->isActive()) {
60 continue;
61 }
62 $this->sc_tasks[$task->getId()] = $task;
63 }
64 return $this->sc_tasks;
65 }
static getInstanceByGroupId(int $a_group_id)

References ILIAS\SystemCheck\Table\Task\DataRetrieval\$sc_tasks, and ilSCTasks\getInstanceByGroupId().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\SystemCheck\Table\Task\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 126 of file DataRetrieval.php.

130 : ?int {
131 return count($this->getSCTasks());
132 }

Field Documentation

◆ $actions

array ILIAS\SystemCheck\Table\Task\DataRetrieval::$actions
protected

Definition at line 41 of file DataRetrieval.php.

◆ $sc_tasks

array ILIAS\SystemCheck\Table\Task\DataRetrieval::$sc_tasks
protected

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