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