ILIAS  release_8 Revision v8.24
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 $this->tpl->addJavaScript("./Services/News/Timeline/js/Timeline.js");
53 $this->tpl->addJavaScript("./Services/News/Timeline/libs/jquery-dynamic-max-height-master/src/jquery.dynamicmaxheight.js");
54
55 $t = new ilTemplate("tpl.timeline.html", true, true, "Services/News/Timeline");
56 if (!$a_items_only) {
57 $t->touchBlock("list_start");
58 $t->touchBlock("list_end");
59 }
60 $keys = array_keys($this->items);
61 foreach ($this->items as $k => $i) {
62 $next = null;
63 if (isset($keys[$k + 1], $this->items[$keys[$k + 1]])) {
64 $next = $this->items[$keys[$k + 1]];
65 }
66
67 $dt = $i->getDateTime();
68 if (is_null($next) || $dt->get(IL_CAL_FKT_DATE, "Y-m-d") !== $next->getDateTime()->get(IL_CAL_FKT_DATE, "Y-m-d")) {
69 $t->setCurrentBlock("badge");
70 $t->setVariable("DAY", $dt->get(IL_CAL_FKT_DATE, "d"));
71 $t->setVariable("MONTH", $this->lng->txt("month_" . $dt->get(IL_CAL_FKT_DATE, "m") . "_short"));
72 $t->parseCurrentBlock();
73 }
74
75 $t->setCurrentBlock("item");
76 $t->setVariable("CONTENT", $i->render());
77 $t->setVariable("FOOTER", $i->renderFooter());
78 $t->parseCurrentBlock();
79 }
80 return $t->get();
81 }
82}
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)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$i
Definition: metadata.php:41
$keys
Definition: metadata.php:204