ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPDTasksBlockGUI.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
5include_once("Services/Block/classes/class.ilBlockGUI.php");
6
15{
16 public static $block_type = "pdtasks";
17
18 protected $tasks = [];
19
23 public function __construct()
24 {
25 global $DIC;
26
27 $this->ctrl = $DIC->ctrl();
28 $this->lng = $DIC->language();
29 $this->user = $DIC->user();
30 $lng = $DIC->language();
31
33
34 $this->setLimit(5);
35 $lng->loadLanguageModule("task");
36 $this->setTitle($lng->txt("task_derived_tasks"));
37
38 $this->setPresentation(self::PRES_SEC_LIST);
39 }
40
44 public function getBlockType() : string
45 {
46 return self::$block_type;
47 }
48
52 protected function isRepositoryObject() : bool
53 {
54 return false;
55 }
56
60 public static function getScreenMode()
61 {
62 switch ($_GET["cmd"]) {
63 default:
64 return IL_SCREEN_SIDE;
65 break;
66 }
67 }
68
72 public function executeCommand()
73 {
74 $ilCtrl = $this->ctrl;
75
76 $cmd = $ilCtrl->getCmd("getHTML");
77
78 return $this->$cmd();
79 }
80
84 public function fillDataSection()
85 {
86 global $DIC;
87 $collector = $DIC->task()->derived()->factory()->collector();
88
89 $this->tasks = $collector->getEntries($this->user->getId());
90
91 if (count($this->tasks) > 0) {
92 $this->setRowTemplate("tpl.pd_tasks.html", "Services/Tasks");
93 $this->getListRowData();
94 parent::fillDataSection();
95 } else {
96 $this->setEnableNumInfo(false);
97 $this->setDataSection($this->getOverview());
98 }
99 }
100
101
105 public function getListRowData()
106 {
107 $data = [];
108
110 foreach ($this->tasks as $task) {
111 $data[] = array(
112 "title" => $task->getTitle(),
113 "url" => $task->getUrl(),
114 "ref_id" => $task->getRefId(),
115 "wsp_id" => $task->getWspId(),
116 "deadline" => $task->getDeadline(),
117 "starting_time" => $task->getStartingTime()
118 );
119 }
120
121 $this->setData($data);
122 }
123
127 public function fillRow($a_set)
128 {
129 global $DIC;
130
131 $factory = $DIC->ui()->factory();
132 $renderer = $DIC->ui()->renderer();
134
135 $info_screen = new ilInfoScreenGUI($this);
136 $info_screen->setFormAction("#");
137 $info_screen->addSection($lng->txt(""));
138 //$toolbar = new ilToolbarGUI();
139
140 $info_screen->addProperty(
141 $lng->txt("task_task"),
142 $a_set["title"]
143 );
144
145 if ($a_set["ref_id"] > 0) {
146 $obj_id = ilObject::_lookupObjId($a_set["ref_id"]);
147 $obj_type = ilObject::_lookupType($obj_id);
148
149 if (0 === $a_set['url']) {
150 $url = ilLink::_getStaticLink($a_set["ref_id"]);
151 } else {
152 $url = $a_set['url'];
153 }
154 $link = $factory->button()->shy(ilObject::_lookupTitle($obj_id), $url);
155
156 $info_screen->addProperty(
157 $lng->txt("obj_" . $obj_type),
158 $renderer->render($link)
159 );
160 }
161
162 if ($a_set["wsp_id"] > 0) {
163 $wst = new ilWorkspaceTree($this->user->getId());
164 $obj_id = $wst->lookupObjectId($a_set["wsp_id"]);
165 $obj_type = ilObject::_lookupType($obj_id);
166
167 if (0 === $a_set['url']) {
168 $url = ilLink::_getStaticLink($a_set["wsp_id"]);
169 } else {
170 $url = $a_set['url'];
171 }
172 $link = $factory->button()->shy(ilObject::_lookupTitle($obj_id), $url);
173
174 $info_screen->addProperty(
175 $lng->txt("obj_" . $obj_type),
176 $renderer->render($link)
177 );
178 }
179
180 if ($a_set["starting_time"] > 0) {
181 $start = new ilDateTime($a_set["starting_time"], IL_CAL_UNIX);
182 $info_screen->addProperty(
183 $lng->txt("task_start"),
185 );
186 }
187
188 if ($a_set["deadline"] > 0) {
189 $end = new ilDateTime($a_set["deadline"], IL_CAL_UNIX);
190 $info_screen->addProperty(
191 $lng->txt("task_deadline"),
193 );
194 }
195
196 $modal = $factory->modal()->roundtrip(
197 $lng->txt("task_details"),
198 $factory->legacy($info_screen->getHTML())
199 )
200 ->withCancelButtonLabel("close");
201 $button1 = $factory->button()->shy($a_set["title"], '#')
202 ->withOnClick($modal->getShowSignal());
203
204 $this->tpl->setVariable("TITLE", $renderer->render([$button1, $modal]));
205 }
206
210 public function getOverview()
211 {
213
214 return '<div class="small">' . ((int) count($this->tasks)) . " " . $lng->txt("task_derived_tasks") . "</div>";
215 }
216
217 //
218 // New rendering
219 //
220
221 protected $new_rendering = true;
222
226 public function getHTMLNew() : string
227 {
228 global $DIC;
229 $collector = $DIC->task()->derived()->factory()->collector();
230
231 $this->tasks = $collector->getEntries($this->user->getId());
232
233 $this->getListRowData();
234
235 return parent::getHTMLNew();
236 }
237
241 protected function getListItemForData(array $data) : \ILIAS\UI\Component\Item\Item
242 {
243 $factory = $this->ui->factory();
245
246 $title = $data["title"];
247 $props = [];
248
249 if ($data["ref_id"] > 0) {
250 $obj_id = ilObject::_lookupObjId($data["ref_id"]);
251 $obj_type = ilObject::_lookupType($obj_id);
252 if ($data['url'] == "") {
253 $url = ilLink::_getStaticLink($data["ref_id"]);
254 } else {
255 $url = $data['url'];
256 }
257 $link = $url;
258 $title = $factory->link()->standard($data["title"], $link);
259 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
260 }
261
262 if ($data["wsp_id"] > 0) {
263 $wst = new ilWorkspaceTree($this->user->getId());
264 $obj_id = $wst->lookupObjectId($data["wsp_id"]);
265 $obj_type = ilObject::_lookupType($obj_id);
266 if ($data['url'] == "") {
267 $url = ilLink::_getStaticLink($data["wsp_id"]);
268 } else {
269 $url = $data['url'];
270 }
271 $link = $url;
272 $title = $factory->link()->standard($data["title"], $link);
273 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
274 }
275
276 if ($data["starting_time"] > 0) {
277 $start = new ilDateTime($data["starting_time"], IL_CAL_UNIX);
278 $props[$lng->txt("task_start")] = ilDatePresentation::formatDate($start);
279 }
280
281 $factory = $this->ui->factory();
282 $item = $factory->item()->standard($title)
283 ->withProperties($props);
284
285 if ($data["deadline"] > 0) {
286 $end = new ilDateTime($data["deadline"], IL_CAL_UNIX);
287 //$props[$lng->txt("task_deadline")] =
288 // ilDatePresentation::formatDate($end);
289 $item = $item->withDescription(ilDatePresentation::formatDate($end));
290 }
291
292
293 return $item;
294 }
295
301 protected function getNoItemFoundContent() : string
302 {
303 return $this->lng->txt("task_no_task_items");
304 }
305}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_CAL_UNIX
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
setData($a_data)
Set Data.
setPresentation(int $type)
Set presentation.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
setTitle($a_title)
Set Title.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
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 ilInfoScreenGUI.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
BlockGUI class for Tasks on PD.
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
executeCommand()
execute command
static getScreenMode()
Get Screen Mode for current command.
getNoItemFoundContent()
No item entry.
fillRow($a_set)
get flat list for personal desktop
fillDataSection()
Fill data section.
getListItemForData(array $data)
Get list item for data array.null|\ILIAS\UI\Component\Item\Item
Tree handler for personal workspace.
global $DIC
Definition: goto.php:24
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$url
ui()
Definition: ui.php:5