Newer
Older
michael.daniel
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* This file contains QUI\Timeline\Controls\Timeline
*/
namespace QUI\Timeline\Controls;
use QUI;
use QUI\Projects\Site\Utils;
/**
* Class Timeline
*
* @package quiqqer/timeline
*/
class Timeline extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'class' => 'timeline',
'order' => 'c_date ASC',
'parentInputList' => false, //todo später für brick
'showLinks' => true,
'display' => 'VerticalBothSides',
// Custom children template (path to html file); overwrites "display"
'displayTemplate' => false,
// Custom children template css (path to css file); overwrites "display"
'displayCss' => false,
'nodeName' => 'section',
));
parent::__construct($attributes);
}
/**
* Return the inner body of the element
* Can be overwritten
*
* @return String
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Site = $this->getSite();
$Project = $this->getProject();
if (!$Site && !$this->getAttribute('parentInputList')) {
return '';
}
$parents = $this->getAttribute('parentInputList');
if (!$parents) {
$parents = $Site->getId();
}
// only active sites
$where['active'] = 1;
if ($this->getAttribute('parentInputList')) {
// for bricks
$children = Utils::getSitesByInputList($Project, $parents, array(
'where' => $where,
'order' => $this->getAttribute('order')
));
} else {
// for site types
$children = $Site->getChildren(array(
'where' => $where,
));
}
$Engine->assign(array(
'this' => $this,
'Site' => $Site,
'Project' => $this->getProject(),
'children' => $children,
'showLinks' => $this->getAttribute('showLinks')
));
// load custom template (if set)
if ($this->getAttribute('displayTemplate')
&& file_exists($this->getAttribute('displayTemplate'))
) {
if ($this->getAttribute('displayCss')
&& file_exists($this->getAttribute('displayCss'))
) {
$this->addCSSFile($this->getAttribute('displayCss'));
}
return $Engine->fetch($this->getAttribute('displayTemplate'));
}
// template
$css = dirname(__FILE__) . $this->getAttribute('display') . '.css';
$template = dirname(__FILE__) . $this->getAttribute('display') . '.template';
$this->addCSSFile($css);
return $Engine->fetch($template);
}
/**
* @return mixed|QUI\Projects\Site
*/
protected function getSite()
{
if ($this->getAttribute('Site')) {
return $this->getAttribute('Site');
}
$Site = QUI::getRewrite()->getSite();
$this->setAttribute('Site', $Site);
return $Site;
}
}