ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSCGroupTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
22 
28 {
31 
32  public function __construct(object $a_parent_obj, string $a_parent_cmd = '')
33  {
34  $this->setId('sc_groups');
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36 
37  global $DIC;
38  $this->renderer = $DIC->ui()->renderer();
39  $this->uiFactory = $DIC->ui()->factory();
40  }
41 
42  public function init(): void
43  {
44  $this->lng->loadLanguageModule('sysc');
45  $this->addColumn($this->lng->txt('title'), 'title', '60%');
46  $this->addColumn($this->lng->txt('last_update'), 'last_update_sort', '20%');
47  $this->addColumn($this->lng->txt('sysc_completed_num'), 'completed', '10%');
48  $this->addColumn($this->lng->txt('sysc_failed_num'), 'failed', '10%');
49  $this->addColumn($this->lng->txt('actions'), '', '10%');
50 
51  $this->setTitle($this->lng->txt('sysc_overview'));
52 
53  $this->setRowTemplate('tpl.syscheck_groups_row.html', 'Services/SystemCheck');
54  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
55  }
56 
57  protected function fillRow(array $a_set): void
58  {
59  $this->tpl->setVariable('VAL_TITLE', (string) ($a_set['title'] ?? ''));
60 
61  $id = (int) ($a_set['id'] ?? 0);
62  $this->ctrl->setParameter($this->getParentObject(), 'grp_id', $id);
63  $this->tpl->setVariable(
64  'VAL_LINK',
65  $this->ctrl->getLinkTarget($this->getParentObject(), 'showGroup')
66  );
67 
68  $this->tpl->setVariable('VAL_DESC', (string) ($a_set['description'] ?? ''));
69  $this->tpl->setVariable('VAL_LAST_UPDATE', (string) ($a_set['last_update'] ?? ''));
70  $this->tpl->setVariable('VAL_COMPLETED', (int) ($a_set['completed'] ?? 0));
71  $this->tpl->setVariable('VAL_FAILED', (int) ($a_set['failed'] ?? 0));
72 
73  switch ($a_set['status']) {
75  $this->tpl->setVariable('STATUS_CLASS', 'smallgreen');
76  break;
78  $this->tpl->setVariable('STATUS_CLASS', 'warning');
79  break;
80  }
81 
82  // Actions
83  $this->ctrl->setParameter($this->getParentObject(), 'grp_id', $id);
84  $dropDownItems = array(
85  $this->uiFactory->button()->shy(
86  $this->lng->txt('show'),
87  $this->ctrl->getLinkTarget($this->getParentObject(), 'showGroup')
88  )
89  );
90  $dropDown = $this->uiFactory->dropdown()->standard($dropDownItems)
91  ->withLabel($this->lng->txt('actions'));
92 
93  $this->tpl->setVariable('ACTIONS', $this->renderer->render($dropDown));
94  }
95 
96  public function parse(): void
97  {
98  $data = array();
99 
100  foreach (ilSCGroups::getInstance()->getGroups() as $group) {
101  $item = array();
102  $item['id'] = $group->getId();
103 
104  $task_gui = ilSCComponentTaskFactory::getComponentTaskGUIForGroup($group->getId());
105 
106  $item['title'] = $task_gui->getGroupTitle();
107  $item['description'] = $task_gui->getGroupDescription();
108  $item['status'] = $group->getStatus();
109 
110  $item['completed'] = ilSCTasks::lookupCompleted($group->getId());
111  $item['failed'] = ilSCTasks::lookupFailed($group->getId());
112 
113  $last_update = ilSCTasks::lookupLastUpdate($group->getId());
114  $item['last_update'] = ilDatePresentation::formatDate($last_update);
115  $item['last_update_sort'] = $last_update->get(IL_CAL_UNIX);
116  $data[] = $item;
117  }
118 
119  $this->setData($data);
120  }
121 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
const STATUS_FAILED
static lookupLastUpdate(int $a_grp_id)
static lookupFailed(int $a_grp_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
static getInstance()
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(object $a_parent_obj, string $a_parent_cmd='')
static lookupCompleted(int $a_grp_id)
const STATUS_COMPLETED
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getComponentTaskGUIForGroup(int $a_group_id, ?int $a_task_id=null)
UIImplementationFactory $uiFactory
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)