ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilSCGroupTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
29 {
32 
33  public function __construct(object $a_parent_obj, string $a_parent_cmd = '')
34  {
35  $this->setId('sc_groups');
36  parent::__construct($a_parent_obj, $a_parent_cmd);
37 
38  global $DIC;
39  $this->renderer = $DIC->ui()->renderer();
40  $this->uiFactory = $DIC->ui()->factory();
41  }
42 
43  public function init(): void
44  {
45  $this->lng->loadLanguageModule('sysc');
46  $this->addColumn($this->lng->txt('title'), 'title', '60%');
47  $this->addColumn($this->lng->txt('last_update'), 'last_update_sort', '20%');
48  $this->addColumn($this->lng->txt('sysc_completed_num'), 'completed', '10%');
49  $this->addColumn($this->lng->txt('sysc_failed_num'), 'failed', '10%');
50  $this->addColumn($this->lng->txt('actions'), '', '10%');
51 
52  $this->setTitle($this->lng->txt('sysc_overview'));
53 
54  $this->setRowTemplate('tpl.syscheck_groups_row.html', 'components/ILIAS/SystemCheck');
55  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
56  }
57 
58  protected function fillRow(array $a_set): void
59  {
60  $this->tpl->setVariable('VAL_TITLE', (string) ($a_set['title'] ?? ''));
61 
62  $id = (int) ($a_set['id'] ?? 0);
63  $this->ctrl->setParameter($this->getParentObject(), 'grp_id', $id);
64  $this->tpl->setVariable(
65  'VAL_LINK',
66  $this->ctrl->getLinkTarget($this->getParentObject(), 'showGroup')
67  );
68 
69  $this->tpl->setVariable('VAL_DESC', (string) ($a_set['description'] ?? ''));
70  $this->tpl->setVariable('VAL_LAST_UPDATE', (string) ($a_set['last_update'] ?? ''));
71  $this->tpl->setVariable('VAL_COMPLETED', (int) ($a_set['completed'] ?? 0));
72  $this->tpl->setVariable('VAL_FAILED', (int) ($a_set['failed'] ?? 0));
73 
74  switch ($a_set['status']) {
76  $this->tpl->setVariable('STATUS_CLASS', 'smallgreen');
77  break;
79  $this->tpl->setVariable('STATUS_CLASS', 'warning');
80  break;
81  }
82 
83  // Actions
84  $this->ctrl->setParameter($this->getParentObject(), 'grp_id', $id);
85  $dropDownItems = array(
86  $this->uiFactory->button()->shy(
87  $this->lng->txt('show'),
88  $this->ctrl->getLinkTarget($this->getParentObject(), 'showGroup')
89  )
90  );
91  $dropDown = $this->uiFactory->dropdown()->standard($dropDownItems)
92  ->withLabel($this->lng->txt('actions'));
93 
94  $this->tpl->setVariable('ACTIONS', $this->renderer->render($dropDown));
95  }
96 
97  public function parse(): void
98  {
99  $data = array();
100 
101  foreach (ilSCGroups::getInstance()->getGroups() as $group) {
102  $item = array();
103  $item['id'] = $group->getId();
104 
105  $task_gui = ilSCComponentTaskFactory::getComponentTaskGUIForGroup($group->getId());
106 
107  $item['title'] = $task_gui->getGroupTitle();
108  $item['description'] = $task_gui->getGroupDescription();
109  $item['status'] = $group->getStatus();
110 
111  $item['completed'] = ilSCTasks::lookupCompleted($group->getId());
112  $item['failed'] = ilSCTasks::lookupFailed($group->getId());
113 
114  $last_update = ilSCTasks::lookupLastUpdate($group->getId());
115  $item['last_update'] = ilDatePresentation::formatDate($last_update);
116  $item['last_update_sort'] = $last_update->get(IL_CAL_UNIX);
117  $data[] = $item;
118  }
119 
120  $this->setData($data);
121  }
122 }
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)
renderer()
const IL_CAL_UNIX
setId(string $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:26
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
__construct(Container $dic, ilPlugin $plugin)
Table GUI for system check groups overview.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static getComponentTaskGUIForGroup(int $a_group_id, ?int $a_task_id=null)
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)