ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDerivedTasksGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $dic;
17
21 protected $ctrl;
22
26 protected $main_tpl;
27
31 protected $task;
32
36 protected $user;
37
41 protected $ui;
42
46 protected $lng;
47
51 protected $help;
52
57 public function __construct(\ILIAS\DI\Container $di_container = null)
58 {
59 global $DIC;
60
61 if (is_null($di_container)) {
62 $di_container = $DIC;
63 }
64 $this->dic = $di_container;
65 $this->ctrl = $DIC->ctrl();
66 $this->main_tpl = $DIC->ui()->mainTemplate();
67 $this->task = $DIC->task();
68 $this->user = $DIC->user();
69 $this->ui = $DIC->ui();
70 $this->lng = $DIC->language();
71 $this->help = $DIC->help();
72
73 $this->help->setScreenIdComponent('task');
74 $this->lng->loadLanguageModule("task");
75 }
76
80 public function executeCommand()
81 {
84 $main_tpl->loadStandardTemplate();
85
86 $next_class = $ctrl->getNextClass($this);
87 $cmd = $ctrl->getCmd("show");
88
89 switch ($next_class) {
90 default:
91 if (in_array($cmd, array("show"))) {
92 $this->$cmd();
93 }
94 }
95 $main_tpl->printToStdout();
96 }
97
101 protected function show()
102 {
103 $ui = $this->ui;
106
107 $main_tpl->setTitle($lng->txt("task_derived_tasks"));
108 $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_task.svg"));
109 $this->help->setScreenId('derived_tasks');
110
111 $f = $ui->factory();
112 $renderer = $ui->renderer();
113
114 $collector = $this->task->derived()->factory()->collector();
115
116 $entries = $collector->getEntries($this->user->getId());
117
118 $list_items_with_deadline = [];
119 $list_items_without_deadline = [];
120 $item_groups = [];
121
122 // item groups from tasks
123 foreach ($entries as $i) {
124 $props = [];
125
126 $title = $i->getTitle();
127 $link = '';
128
129 if ($i->getRefId() > 0) {
130 $obj_id = ilObject::_lookupObjId($i->getRefId());
131 $obj_type = ilObject::_lookupType($obj_id);
132 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
133
134 $link = ilLink::_getStaticLink($i->getRefId());
135 }
136
137 if ($i->getWspId() > 0) {
138 $wst = new ilWorkspaceTree($this->user->getId());
139 $obj_id = $wst->lookupObjectId($i->getWspId());
140 $obj_type = ilObject::_lookupType($obj_id);
141 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
142 }
143
144 if (strlen($i->getUrl()) > 0) {
145 $link = $i->getUrl();
146 }
147
148 if (strlen($link) > 0) {
149 $title = $f->button()->shy($title, $link);
150 }
151
152 if ($i->getStartingTime() > 0) {
153 $start = new ilDateTime($i->getStartingTime(), IL_CAL_UNIX);
154 $props[$lng->txt("task_start")] = ilDatePresentation::formatDate($start);
155 }
156 if ($i->getDeadline() > 0) {
157 $end = new ilDateTime($i->getDeadline(), IL_CAL_UNIX);
158 $props[$lng->txt("task_deadline")] = ilDatePresentation::formatDate($end);
159 }
160 $item = $f->item()->standard($title)->withProperties($props);
161 if ($i->getDeadline() > 0) {
162 $list_items_with_deadline[] = $item;
163 } else {
164 $list_items_without_deadline[] = $item;
165 }
166 }
167
168 // output list panel or info message
169 if (count($list_items_with_deadline) > 0 || count($list_items_without_deadline) > 0) {
170 $panels = [];
171
172 if (count($list_items_with_deadline) > 0) {
173 $panels[] = $f->panel()->listing()->standard(
174 $lng->txt("task_tasks_with_deadline"),
175 [$f->item()->group("", $list_items_with_deadline)]
176 );
177 }
178 if (count($list_items_without_deadline) > 0) {
179 $panels[] = $f->panel()->listing()->standard(
180 $lng->txt("task_tasks_without_deadline"),
181 [$f->item()->group("", $list_items_without_deadline)]
182 );
183 }
184
185
186 $main_tpl->setContent($renderer->render($panels));
187 } else {
188 ilUtil::sendInfo($lng->txt("task_no_tasks"));
189 }
190 }
191}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
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
__construct(\ILIAS\DI\Container $di_container=null)
Constructor.
executeCommand()
Execute command.
show()
Show list of tasks.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Tree handler for personal workspace.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$i
Definition: metadata.php:24
Class HTTPServicesTest.
Class ChatMainBarProvider \MainMenu\Provider.
ui()
Definition: ui.php:5