ILIAS  release_8 Revision v8.24
class.ilADNNotificationTableGUI.php
Go to the documentation of this file.
1<?php
2
23
30{
31 protected \ILIAS\Data\Factory $data_factory;
32
33 protected \ILIAS\DI\UIServices $ui;
34 protected \ilObjAdministrativeNotificationAccess $access;
38 protected array $modals = [];
39
44 public function __construct(ilADNNotificationGUI $a_parent_obj, string $a_parent_cmd)
45 {
46 global $DIC;
50 $this->ctrl = $DIC->ctrl();
51 $this->lng = $DIC->language();
52 $this->data_factory = new Factory();
53 $this->ui = $DIC->ui();
55
56 $this->setId('msg_msg_table');
57 $this->setRowTemplate('Services/AdministrativeNotification/templates/default/tpl.row.html');
58 parent::__construct($a_parent_obj, $a_parent_cmd);
59 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
60 //
61 // Columns
62 $this->addColumn($this->lng->txt('msg_title'));
63 $this->addColumn($this->lng->txt('msg_type'));
64 $this->addColumn($this->lng->txt('msg_type_during_event'));
65 $this->addColumn($this->lng->txt('msg_event_date_start'));
66 $this->addColumn($this->lng->txt('msg_event_date_end'));
67 $this->addColumn($this->lng->txt('msg_display_date_start'));
68 $this->addColumn($this->lng->txt('msg_display_date_end'));
69 $this->addColumn($this->lng->txt('common_actions'));
70
71 $this->initData();
72 }
73
74 protected function initData(): void
75 {
77 }
78
79 protected function formatDate(DateTimeImmutable $timestamp): string
80 {
82 }
83
84 protected function fillRow(array $a_set): void
85 {
89 $notification = ilADNNotification::find($a_set['id']);
90 $this->tpl->setVariable('TITLE', $notification->getTitle());
91 $this->tpl->setVariable('TYPE', $this->lng->txt('msg_type_' . $notification->getType()));
92
93 if (!$notification->isPermanent()) {
94 $this->tpl->setVariable(
95 'TYPE_DURING_EVENT',
96 $this->lng->txt('msg_type_' . $notification->getTypeDuringEvent())
97 );
98 $this->tpl->setVariable('EVENT_START', $this->formatDate($notification->getEventStart()));
99 $this->tpl->setVariable('EVENT_END', $this->formatDate($notification->getEventEnd()));
100 $this->tpl->setVariable('DISPLAY_START', $this->formatDate($notification->getDisplayStart()));
101 $this->tpl->setVariable('DISPLAY_END', $this->formatDate($notification->getDisplayEnd()));
102 }
103 // Actions
104 if ($this->access->hasUserPermissionTo('write')) {
105 $items = [];
106 $this->ctrl->setParameter($this->parent_obj, ilADNAbstractGUI::IDENTIFIER, $notification->getId());
107
108 $items[] = $this->ui->factory()->button()->shy(
109 $this->lng->txt('btn_' . ilADNNotificationGUI::CMD_EDIT),
110 $this->ctrl->getLinkTargetByClass(ilADNNotificationGUI::class, ilADNNotificationGUI::CMD_EDIT)
111 );
112
113 // Modals and actions
114 $ditem = $this->ui->factory()->modal()->interruptiveItem((string) $notification->getId(), $notification->getTitle());
115 $delete_modal = $this->modal($ditem, ilADNNotificationGUI::CMD_DELETE);
116 $items[] = $this->ui->factory()->button()->shy($this->lng->txt('btn_' . ilADNNotificationGUI::CMD_DELETE), "")
117 ->withOnClick($delete_modal->getShowSignal());
118 $this->modals[] = $delete_modal;
119
120 $reset_modal = $this->modal($ditem, ilADNNotificationGUI::CMD_RESET);
121 $items[] = $this->ui->factory()->button()->shy($this->lng->txt('btn_' . ilADNNotificationGUI::CMD_RESET), "")
122 ->withOnClick($reset_modal->getShowSignal());
123 $this->modals[] = $reset_modal;
124
125 $actions = $this->ui->renderer()->render([$this->ui->factory()->dropdown()->standard($items)->withLabel($this->lng->txt('actions'))]);
126
127 $this->tpl->setVariable('ACTIONS', $actions);
128 } else {
129 $this->tpl->setVariable('ACTIONS', "");
130 }
131 }
132
133 protected function modal(InterruptiveItem $i, string $cmd): Interruptive
134 {
135 $action = $this->ctrl->getLinkTargetByClass(ilADNNotificationGUI::class, $cmd);
136
137 return $this->ui->factory()->modal()
138 ->interruptive(
139 $this->lng->txt('btn_' . $cmd),
140 $this->lng->txt('btn_' . $cmd . '_confirm'),
141 $action
142 )
143 ->withAffectedItems([$i])
144 ->withActionButtonLabel($cmd);
145 }
146
147 public function getHTML(): string
148 {
149 return parent::getHTML() . $this->ui->renderer()->render($this->modals);
150 }
151}
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
static getArray(?string $key=null, $values=null)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Builds data types.
Definition: Factory.php:21
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilADNNotificationTableGUI.
modal(InterruptiveItem $i, string $cmd)
formatDate(DateTimeImmutable $timestamp)
ilObjAdministrativeNotificationAccess $access
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
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)
fillRow(array $a_set)
Standard Version of Fill Row.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
global $DIC
Definition: feed.php:28
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc