ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 }
ilGlobalTemplateInterface $tpl
global $DIC
Definition: feed.php:28
$keys
Definition: metadata.php:204
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_FKT_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
render(bool $a_items_only=false)
addItem(ilTimelineItemInt $a_item)
$i
Definition: metadata.php:41