ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilADNNotificationTableGUI.php
Go to the documentation of this file.
1<?php
2
7
14{
15
19 protected $ctrl;
23 protected $data_factory;
27 protected $ui;
31 protected $access;
35 protected $modals = [];
36
42 public function __construct(ilADNNotificationGUI $a_parent_obj, $a_parent_cmd)
43 {
44 global $DIC;
48 $this->ctrl = $DIC->ctrl();
49 $this->lng = $DIC->language();
50 $this->data_factory = new Factory();
51 $this->ui = $DIC->ui();
52 $this->access = new ilObjAdministrativeNotificationAccess();
53
54 $this->setId('msg_msg_table');
55 $this->setRowTemplate('Services/AdministrativeNotification/templates/default/tpl.row.html');
56 parent::__construct($a_parent_obj, $a_parent_cmd);
57 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
58 //
59 // Columns
60 $this->addColumn($this->lng->txt('msg_title'));
61 $this->addColumn($this->lng->txt('msg_type'));
62 $this->addColumn($this->lng->txt('msg_type_during_event'));
63 $this->addColumn($this->lng->txt('msg_event_date_start'));
64 $this->addColumn($this->lng->txt('msg_event_date_end'));
65 $this->addColumn($this->lng->txt('msg_display_date_start'));
66 $this->addColumn($this->lng->txt('msg_display_date_end'));
67 $this->addColumn($this->lng->txt('common_actions'));
68
69 $this->initData();
70 }
71
72 protected function initData()
73 {
75 }
76
77 protected function formatDate(DateTimeImmutable $timestamp) : string
78 {
80 }
81
82 protected function fillRow($a_set)
83 {
87 $notification = ilADNNotification::find($a_set['id']);
88 $this->tpl->setVariable('TITLE', $notification->getTitle());
89 $this->tpl->setVariable('TYPE', $this->lng->txt('msg_type_' . $notification->getType()));
90
91 if (!$notification->isPermanent()) {
92 $this->tpl->setVariable(
93 'TYPE_DURING_EVENT',
94 $this->lng->txt('msg_type_' . $notification->getTypeDuringEvent())
95 );
96 $this->tpl->setVariable('EVENT_START', $this->formatDate($notification->getEventStart()));
97 $this->tpl->setVariable('EVENT_END', $this->formatDate($notification->getEventEnd()));
98 $this->tpl->setVariable('DISPLAY_START', $this->formatDate($notification->getDisplayStart()));
99 $this->tpl->setVariable('DISPLAY_END', $this->formatDate($notification->getDisplayEnd()));
100 }
101 // Actions
102 if ($this->access->hasUserPermissionTo('write')) {
103 $items = [];
104 $this->ctrl->setParameter($this->parent_obj, ilADNNotificationGUI::IDENTIFIER, $notification->getId());
105
106 $items[] = $this->ui->factory()->button()->shy(
107 $this->lng->txt('btn_' . ilADNNotificationGUI::CMD_EDIT),
108 $this->ctrl->getLinkTargetByClass(ilADNNotificationGUI::class, ilADNNotificationGUI::CMD_EDIT)
109 );
110
111 // Modals and actions
112 $ditem = $this->ui->factory()->modal()->interruptiveItem($notification->getId(), $notification->getTitle());
113 $delete_modal = $this->modal($ditem, ilADNNotificationGUI::CMD_DELETE);
114 $items[] = $this->ui->factory()->button()->shy($this->lng->txt('btn_' . ilADNNotificationGUI::CMD_DELETE), "")
115 ->withOnClick($delete_modal->getShowSignal());
116 $this->modals[] = $delete_modal;
117
118 $reset_modal = $this->modal($ditem, ilADNNotificationGUI::CMD_RESET);
119 $items[] = $this->ui->factory()->button()->shy($this->lng->txt('btn_' . ilADNNotificationGUI::CMD_RESET), "")
120 ->withOnClick($reset_modal->getShowSignal());
121 $this->modals[] = $reset_modal;
122
123 $actions = $this->ui->renderer()->render([$this->ui->factory()->dropdown()->standard($items)->withLabel($this->lng->txt('actions'))]);
124
125 $this->tpl->setVariable('ACTIONS', $actions);
126 } else {
127 $this->tpl->setVariable('ACTIONS', "");
128 }
129 }
130
131 protected function modal(InterruptiveItem $i, string $cmd) : Interruptive
132 {
133 $action = $this->ctrl->getLinkTargetByClass(ilADNNotificationGUI::class, $cmd);
134 $modal = $this->ui->factory()->modal()
135 ->interruptive(
136 $this->lng->txt('btn_' . $cmd),
137 $this->lng->txt('btn_' . $cmd . '_confirm'),
138 $action
139 )
140 ->withAffectedItems([$i])
141 ->withActionButtonLabel($cmd);
142
143 return $modal;
144 }
145
146 public function getHTML()
147 {
148 return parent::getHTML() . $this->ui->renderer()->render($this->modals);
149 }
150}
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
static getArray($key=null, $values=null)
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
Builds data types.
Definition: Factory.php:20
const IL_CAL_UNIX
Class ilADNNotificationGUI @ilCtrl_IsCalledBy ilADNNotificationGUI: ilObjAdministrativeNotificationGU...
Class ilADNNotificationTableGUI.
modal(InterruptiveItem $i, string $cmd)
formatDate(DateTimeImmutable $timestamp)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Class ilTable2GUI.
fillRow($a_set)
Standard Version of Fill Row.
setData($a_data)
set table data @access public
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
ui()
Definition: ui.php:5