ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTimelineGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/News/Timeline/interfaces/interface.ilTimelineItemInt.php");
6 
15 {
16  protected $items = array();
17 
21  protected $lng;
22 
26  protected $tpl;
27 
34  protected function __construct()
35  {
36  global $DIC;
37 
38  $this->lng = $DIC->language();
39  $this->tpl = $DIC["tpl"];
40  }
41 
48  public static function getInstance()
49  {
50  return new self();
51  }
52 
59  public function addItem(ilTimelineItemInt $a_item)
60  {
61  $this->items[] = $a_item;
62  }
63 
70  public function render($a_items_only = false)
71  {
72  $this->tpl->addJavaScript("./Services/News/Timeline/js/Timeline.js");
73  $this->tpl->addJavaScript("./Services/News/Timeline/libs/jquery-dynamic-max-height-master/src/jquery.dynamicmaxheight.js");
74 
75  $t = new ilTemplate("tpl.timeline.html", true, true, "Services/News/Timeline");
76  if (!$a_items_only) {
77  $t->touchBlock("list_start");
78  $t->touchBlock("list_end");
79  }
80  $keys = array_keys($this->items);
81  foreach ($this->items as $k => $i) {
82  $next = null;
83  if (isset($this->items[$keys[$k + 1]])) {
84  $next = $this->items[$keys[$k + 1]];
85  }
86 
87  $dt = $i->getDateTime();
88  if (is_null($next) || $dt->get(IL_CAL_FKT_DATE, "Y-m-d") != $next->getDateTime()->get(IL_CAL_FKT_DATE, "Y-m-d")) {
89  $t->setCurrentBlock("badge");
90  $t->setVariable("DAY", $dt->get(IL_CAL_FKT_DATE, "d"));
91  $t->setVariable("MONTH", $this->lng->txt("month_" . $dt->get(IL_CAL_FKT_DATE, "m") . "_short"));
92  $t->parseCurrentBlock();
93  }
94 
95  $t->setCurrentBlock("item");
96  $t->setVariable("CONTENT", $i->render());
97  $t->setVariable("FOOTER", $i->renderFooter());
98  $t->parseCurrentBlock();
99  }
100  return $t->get();
101  }
102 }
global $DIC
Definition: saml.php:7
__construct()
Construct.
$keys
Timline (temporary implementation)
render($a_items_only=false)
Render.
special template class to simplify handling of ITX/PEAR
const IL_CAL_FKT_DATE
Interface for timeline items.
static getInstance()
Get instance.
$i
Definition: disco.tpl.php:19
addItem(ilTimelineItemInt $a_item)
Add item.