ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPDTasksBlockGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 public static string $block_type = "pdtasks";
31
32 protected array $tasks = [];
33
37 public function __construct()
38 {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->lng = $DIC->language();
43 $this->user = $DIC->user();
44 $lng = $DIC->language();
45
47
48 $this->setLimit(5);
49 $lng->loadLanguageModule("task");
50 $this->setTitle($lng->txt("task_derived_tasks"));
51
52 $this->setPresentation(self::PRES_SEC_LIST);
53 }
54
58 public function getBlockType(): string
59 {
60 return self::$block_type;
61 }
62
66 protected function isRepositoryObject(): bool
67 {
68 return false;
69 }
70
74 public static function getScreenMode(): string
75 {
76 return IL_SCREEN_SIDE;
77 }
78
82 public function executeCommand()
83 {
84 $ilCtrl = $this->ctrl;
85
86 $cmd = $ilCtrl->getCmd("getHTML");
87
88 return $this->$cmd();
89 }
90
94 public function getListRowData(): void
95 {
96 $data = [];
97
99 foreach ($this->tasks as $task) {
100 $data[] = array(
101 "title" => $task->getTitle(),
102 "url" => $task->getUrl(),
103 "ref_id" => $task->getRefId(),
104 "wsp_id" => $task->getWspId(),
105 "deadline" => $task->getDeadline(),
106 "starting_time" => $task->getStartingTime()
107 );
108 }
109
110 $this->setData($data);
111 }
112
116 public function getOverview(): string
117 {
119
120 return '<div class="small">' . (count($this->tasks)) . " " . $lng->txt("task_derived_tasks") . "</div>";
121 }
122
126 public function getHTML(): string
127 {
128 global $DIC;
129 $collector = $DIC->task()->derived()->factory()->collector();
130
131 $this->tasks = $collector->getEntries($this->user->getId());
132
133 $this->getListRowData();
134
135 return parent::getHTML();
136 }
137
141 protected function getListItemForData(array $data): ?Item
142 {
143 $factory = $this->ui->factory();
145
146 $title = $data["title"];
147 $props = [];
148
149 if ($data["ref_id"] > 0) {
150 $obj_id = ilObject::_lookupObjId($data["ref_id"]);
151 $obj_type = ilObject::_lookupType($obj_id);
152 $url = $data['url'] == "" ? ilLink::_getStaticLink($data["ref_id"]) : $data['url'];
153 $link = $url;
154 $title = $factory->link()->standard($data["title"], $link);
155 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
156 }
157
158 if ($data["wsp_id"] > 0) {
159 $wst = new ilWorkspaceTree($this->user->getId());
160 $obj_id = $wst->lookupObjectId($data["wsp_id"]);
161 $obj_type = ilObject::_lookupType($obj_id);
162 $url = $data['url'] == "" ? ilLink::_getStaticLink($data["wsp_id"]) : $data['url'];
163 $link = $url;
164 $title = $factory->link()->standard($data["title"], $link);
165 $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
166 }
167
168 if ($data["starting_time"] > 0) {
169 $start = new ilDateTime($data["starting_time"], IL_CAL_UNIX);
170 $props[$lng->txt("task_start")] = ilDatePresentation::formatDate($start);
171 }
172
173 $factory = $this->ui->factory();
174 $item = $factory->item()->standard($title)
175 ->withProperties($props);
176
177 if ($data["deadline"] > 0) {
178 $end = new ilDateTime($data["deadline"], IL_CAL_UNIX);
179 //$props[$lng->txt("task_deadline")] =
180 // ilDatePresentation::formatDate($end);
181 $item = $item->withDescription(ilDatePresentation::formatDate($end));
182 }
183
184
185 return $item;
186 }
187
191 public function getNoItemFoundContent(): string
192 {
193 return $this->lng->txt("task_no_task_items");
194 }
195}
const IL_SCREEN_SIDE
const IL_CAL_UNIX
This class represents a block method of a block.
setData(array $a_data)
ilLanguage $lng
Factory $factory
setTitle(string $a_title)
setPresentation(int $type)
setLimit(int $a_limit)
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
loadLanguageModule(string $a_module)
Load language module.
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...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
BlockGUI class for Tasks on PD.
isRepositoryObject()
Returns whether block has a corresponding repository object.
executeCommand()
execute command
static getScreenMode()
Get Screen Mode for current command.
getNoItemFoundContent()
No item entry.
getListItemForData(array $data)
Get list item for data array.null|\ILIAS\UI\Component\Item\Item
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Common interface to all items.
Definition: Item.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68