ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCTaskTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23
29{
30 private int $group_id = 0;
31
33 private UIRenderer $renderer;
34 private UIFactory $uiFactory;
35
36 public function __construct(int $a_group_id, object $a_parent_obj, string $a_parent_cmd = '')
37 {
38 global $DIC;
39 $this->group_id = $a_group_id;
40 $this->setId('sc_groups');
41 $this->access = $DIC->access();
42 parent::__construct($a_parent_obj, $a_parent_cmd);
43
44 $this->renderer = $DIC->ui()->renderer();
45 $this->uiFactory = $DIC->ui()->factory();
46 }
47
48 public function getGroupId(): int
49 {
50 return $this->group_id;
51 }
52
53 public function init(): void
54 {
55 $this->lng->loadLanguageModule('sysc');
56 $this->addColumn($this->lng->txt('title'), 'title', '60%');
57 $this->addColumn($this->lng->txt('last_update'), 'last_update_sort', '20%');
58 $this->addColumn($this->lng->txt('status'), 'status', '10%');
59 $this->addColumn($this->lng->txt('actions'), '', '10%');
60
61 $this->setTitle($this->lng->txt('sysc_task_overview'));
62
63 $this->setRowTemplate('tpl.syscheck_tasks_row.html', 'components/ILIAS/SystemCheck');
64 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
65 }
66
70 protected function fillRow(array $a_set): void
71 {
72 $this->tpl->setVariable('VAL_TITLE', (string) ($a_set['title'] ?? ''));
73 $this->tpl->setVariable('VAL_DESC', (string) ($a_set['description'] ?? ''));
74
75 $status = (int) ($a_set['status'] ?? 0);
76 $text = ilSCUtils::taskStatus2Text($status);
77 switch ($status) {
79 $this->tpl->setVariable('VAL_STATUS_SUCCESS', $text);
80 break;
81
83 $this->tpl->setCurrentBlock('warning');
84 $this->tpl->setVariable('VAL_STATUS_WARNING', $text);
85 $this->tpl->parseCurrentBlock();
86 break;
87
88 default:
89 $this->tpl->setVariable('VAL_STATUS_STANDARD', $text);
90 break;
91 }
92
93 $this->tpl->setVariable('VAL_LAST_UPDATE', (string) ($a_set['last_update'] ?? ''));
94
95 // Actions
96 if ($this->access->checkAccess('write', '', $this->parent_obj->getObject()->getRefId())) {
97 $id = (int) ($a_set['id'] ?? 0);
98
99 $dropDownItems = array();
100
102
103 $this->ctrl->setParameterByClass(get_class($task_handler), 'task_id', $id);
104 foreach ($task_handler->getActions() as $actions) {
105 $dropDownItems[] = $this->uiFactory->button()->shy(
106 (string) ($actions['txt'] ?? ''),
107 $this->ctrl->getLinkTargetByClass(get_class($task_handler), (string) ($actions['command'] ?? ''))
108 );
109 }
110 $dropDown = $this->uiFactory->dropdown()->standard($dropDownItems)
111 ->withLabel($this->lng->txt('actions'));
112 $this->tpl->setVariable('ACTIONS', $this->renderer->render($dropDown));
113 }
114 }
115
116 public function parse(): void
117 {
118 $data = array();
119
120 foreach (ilSCTasks::getInstanceByGroupId($this->getGroupId())->getTasks() as $task) {
121 $task_handler = ilSCComponentTaskFactory::getComponentTask($task->getId());
122
123 if (!$task->isActive()) {
124 continue;
125 }
126
127 $item = array();
128 $item['id'] = $task->getId();
129 $item['title'] = $task_handler->getTitle();
130 $item['description'] = $task_handler->getDescription();
131 $item['last_update'] = ilDatePresentation::formatDate($task->getLastUpdate());
132 $item['last_update_sort'] = $task->getLastUpdate()->get(IL_CAL_UNIX);
133 $item['status'] = $task->getStatus();
134
135 $data[] = $item;
136 }
137
138 $this->setData($data);
139 }
140}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
const IL_CAL_UNIX
Class ilAccessHandler Checks access for ILIAS objects.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Table GUI for system check task overview.
__construct(int $a_group_id, object $a_parent_obj, string $a_parent_cmd='')
const STATUS_COMPLETED
const STATUS_FAILED
static getInstanceByGroupId(int $a_group_id)
static taskStatus2Text(int $a_status)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26