ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 
91 
95  public function getListRowData(): void
96  {
97  $data = [];
98 
100  foreach ($this->tasks as $task) {
101  $data[] = array(
102  "title" => $task->getTitle(),
103  "url" => $task->getUrl(),
104  "ref_id" => $task->getRefId(),
105  "wsp_id" => $task->getWspId(),
106  "deadline" => $task->getDeadline(),
107  "starting_time" => $task->getStartingTime()
108  );
109  }
110 
111  $this->setData($data);
112  }
113 
117  public function getOverview(): string
118  {
119  $lng = $this->lng;
120 
121  return '<div class="small">' . (count($this->tasks)) . " " . $lng->txt("task_derived_tasks") . "</div>";
122  }
123 
127  public function getHTML(): string
128  {
129  global $DIC;
130  $collector = $DIC->task()->derived()->factory()->collector();
131 
132  $this->tasks = $collector->getEntries($this->user->getId());
133 
134  $this->getListRowData();
135 
136  return parent::getHTML();
137  }
138 
142  protected function getListItemForData(array $data): ?Item
143  {
144  $factory = $this->ui->factory();
145  $lng = $this->lng;
146 
147  $title = $data["title"];
148  $props = [];
149 
150  if ($data["ref_id"] > 0) {
151  $obj_id = ilObject::_lookupObjId($data["ref_id"]);
152  $obj_type = ilObject::_lookupType($obj_id);
153  $url = $data['url'] == "" ? ilLink::_getStaticLink($data["ref_id"]) : $data['url'];
154  $link = $url;
155  $title = $factory->link()->standard($data["title"], $link);
156  $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
157  }
158 
159  if ($data["wsp_id"] > 0) {
160  $wst = new ilWorkspaceTree($this->user->getId());
161  $obj_id = $wst->lookupObjectId($data["wsp_id"]);
162  $obj_type = ilObject::_lookupType($obj_id);
163  $url = $data['url'] == "" ? ilLink::_getStaticLink($data["wsp_id"]) : $data['url'];
164  $link = $url;
165  $title = $factory->link()->standard($data["title"], $link);
166  $props[$lng->txt("obj_" . $obj_type)] = ilObject::_lookupTitle($obj_id);
167  }
168 
169  if ($data["starting_time"] > 0) {
170  $start = new ilDateTime($data["starting_time"], IL_CAL_UNIX);
171  $props[$lng->txt("task_start")] = ilDatePresentation::formatDate($start);
172  }
173 
174  $factory = $this->ui->factory();
175  $item = $factory->item()->standard($title)
176  ->withProperties($props);
177 
178  if ($data["deadline"] > 0) {
179  $end = new ilDateTime($data["deadline"], IL_CAL_UNIX);
180  //$props[$lng->txt("task_deadline")] =
181  // ilDatePresentation::formatDate($end);
182  $item = $item->withDescription(ilDatePresentation::formatDate($end));
183  }
184 
185 
186  return $item;
187  }
188 
192  public function getNoItemFoundContent(): string
193  {
194  return $this->lng->txt("task_no_task_items");
195  }
196 }
static getScreenMode()
Get Screen Mode for current command.
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...
ilLanguage $lng
getCmd(string $fallback_command=null)
setLimit(int $a_limit)
Factory $factory
executeCommand()
execute command
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
loadLanguageModule(string $a_module)
Load language module.
const IL_CAL_UNIX
BlockGUI class for Tasks on PD.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
getNoItemFoundContent()
No item entry.
__construct(VocabulariesInterface $vocabularies)
static _lookupTitle(int $obj_id)
Common interface to all items.
Definition: Item.php:31
$url
Definition: ltiregstart.php:35
lookupObjectId(int $a_node_id)
Get object id for node id.
setTitle(string $a_title)
This class represents a block method of a block.
setData(array $a_data)
static _lookupType(int $id, bool $reference=false)
const IL_SCREEN_SIDE
setPresentation(int $type)