ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTimelineGUI.php
Go to the documentation of this file.
1<?php
2
25{
27 protected array $items = [];
28 protected ilLanguage $lng;
30
31 protected function __construct()
32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->tpl = $DIC->ui()->mainTemplate();
37 }
38
39 public static function getInstance(): self
40 {
41 return new self();
42 }
43
44 public function addItem(ilTimelineItemInt $a_item): void
45 {
46 $this->items[] = $a_item;
47 }
48
49 public function render(
50 bool $a_items_only = false
51 ): string {
52 $debug = false;
53 if ($debug) {
54 $this->tpl->addJavaScript("../components/ILIAS/News/resources/Timeline.js");
55 } else {
56 $this->tpl->addJavaScript("assets/js/Timeline.js");
57 }
58
59 $t = new ilTemplate("tpl.timeline.html", true, true, "components/ILIAS/News/Timeline");
60 if (!$a_items_only) {
61 $t->touchBlock("list_start");
62 $t->touchBlock("list_end");
63 }
64 $keys = array_keys($this->items);
65 foreach ($this->items as $k => $i) {
66 $next = null;
67 if (isset($keys[$k + 1], $this->items[$keys[$k + 1]])) {
68 $next = $this->items[$keys[$k + 1]];
69 }
70
71 $dt = $i->getDateTime();
72 if (is_null($next) || $dt->get(IL_CAL_FKT_DATE, "Y-m-d") !== $next->getDateTime()->get(IL_CAL_FKT_DATE, "Y-m-d")) {
73 $t->setCurrentBlock("badge");
74 $t->setVariable("DAY", $dt->get(IL_CAL_FKT_DATE, "d"));
75 $t->setVariable("MONTH", $this->lng->txt("month_" . $dt->get(IL_CAL_FKT_DATE, "m") . "_short"));
76 $t->parseCurrentBlock();
77 }
78
79 $t->setCurrentBlock("item");
80 $t->setVariable("CONTENT", $i->render());
81 $t->setVariable("FOOTER", $i->renderFooter());
82 $t->parseCurrentBlock();
83 }
84 return $t->get();
85 }
86}
const IL_CAL_FKT_DATE
language handling
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addItem(ilTimelineItemInt $a_item)
ilGlobalTemplateInterface $tpl
render(bool $a_items_only=false)
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