ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDerivedTasksGUI.php
Go to the documentation of this file.
1<?php
2
21
28{
29 protected ?Container $dic;
30 protected ilCtrl $ctrl;
33 protected ilObjUser $user;
34 protected UIServices $ui;
35 protected ilLanguage $lng;
36 protected ilHelpGUI $help;
37
42 public function __construct(?Container $di_container = null)
43 {
44 global $DIC;
45
46 if (is_null($di_container)) {
47 $di_container = $DIC;
48 }
49 $this->dic = $di_container;
50 $this->ctrl = $DIC->ctrl();
51 $this->main_tpl = $DIC->ui()->mainTemplate();
52 $this->task = $DIC->task();
53 $this->user = $DIC->user();
54 $this->ui = $DIC->ui();
55 $this->lng = $DIC->language();
56 $this->help = $DIC->help();
57
58 $this->help->setScreenIdComponent('task');
59 $this->lng->loadLanguageModule("task");
60 }
61
65 public function executeCommand(): void
66 {
70
71 $next_class = $ctrl->getNextClass($this);
72 $cmd = $ctrl->getCmd("show");
73
74 if ($cmd == "show") {
75 $this->$cmd();
76 }
78 }
79
83 protected function show(): void
84 {
85 $ui = $this->ui;
88
89 $main_tpl->setTitle($lng->txt("task_derived_tasks"));
90 $main_tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_task.svg"));
91 $this->help->setScreenId('derived_tasks');
92
93 $f = $ui->factory();
95
96 $collector = $this->task->derived()->factory()->collector();
97
98 $entries = $collector->getEntries($this->user->getId());
99
100 $list_items_with_deadline = [];
101 $list_items_without_deadline = [];
102
103 // item groups from tasks
104 foreach ($entries as $i) {
105 $props = [];
106
107 $title = $i->getTitle();
108 $link = '';
109
110 if ($i->getRefId() > 0) {
111 $obj_id = ilObject::_lookupObjId($i->getRefId());
112 $obj_type = ilObject::_lookupType($obj_id);
113 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
114
115 $link = ilLink::_getStaticLink($i->getRefId());
116 }
117
118 if ($i->getWspId() > 0) {
119 $wst = new ilWorkspaceTree($this->user->getId());
120 $obj_id = $wst->lookupObjectId($i->getWspId());
121 $obj_type = ilObject::_lookupType($obj_id);
122 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
123 }
124
125 if (strlen($i->getUrl()) > 0) {
126 $link = $i->getUrl();
127 }
128
129 if (strlen($link) > 0) {
130 $title = $f->button()->shy($title, $link);
131 }
132
133 if ($i->getStartingTime() > 0) {
134 $start = new ilDateTime($i->getStartingTime(), IL_CAL_UNIX);
135 $props[$lng->txt("task_start")] = ilDatePresentation::formatDate($start);
136 }
137 if ($i->getDeadline() > 0) {
138 $end = new ilDateTime($i->getDeadline(), IL_CAL_UNIX);
139 $props[$lng->txt("task_deadline")] = ilDatePresentation::formatDate($end);
140 }
141 $item = $f->item()->standard($title)->withProperties($props);
142 if ($i->getDeadline() > 0) {
143 $list_items_with_deadline[] = $item;
144 } else {
145 $list_items_without_deadline[] = $item;
146 }
147 }
148
149 // output list panel or info message
150 if (count($list_items_with_deadline) > 0 || count($list_items_without_deadline) > 0) {
151 $panels = [];
152
153 if (count($list_items_with_deadline) > 0) {
154 $panels[] = $f->panel()->listing()->standard(
155 $lng->txt("task_tasks_with_deadline"),
156 [$f->item()->group("", $list_items_with_deadline)]
157 );
158 }
159 if (count($list_items_without_deadline) > 0) {
160 $panels[] = $f->panel()->listing()->standard(
161 $lng->txt("task_tasks_without_deadline"),
162 [$f->item()->group("", $list_items_without_deadline)]
163 );
164 }
165
166
167 $main_tpl->setContent($renderer->render($panels));
168 } else {
169 $this->main_tpl->setOnScreenMessage('info', $lng->txt("task_no_tasks"));
170 }
171 }
172}
$renderer
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
renderer()
Get a renderer for UI components.
Definition: UIServices.php:44
factory()
Get the factory that crafts UI components.
Definition: UIServices.php:36
const IL_CAL_UNIX
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
__construct(?Container $di_container=null)
Constructor.
executeCommand()
Execute command.
show()
Show list of tasks.
ilGlobalTemplateInterface $main_tpl
Help GUI class.
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26