Newer
Older
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
<?php
/**
* This file contains QUI\Bricks\Controls\SideBox1
*/
namespace QUI\Bricks\Controls;
use QUI;
/**
* Class SocialBox
*
* @package quiqqer/bricks
*/
class SideBox1 extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = array())
{
// default options
$this->setAttributes(array(
'showImage' => true,
'showTitle' => true,
'showDescription' => true,
'showContent' => true,
'class' => 'quiqqer-bricks-sidebox1',
'nodeName' => 'article',
'site' => false,
'order' => 'release_from DESC'
));
parent::__construct($attributes);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(array(
'this' => $this,
'Site' => $this->getSite()
));
return $Engine->fetch(dirname(__FILE__) . '/SideBox1.html');
}
/**
* Return the site object
*
* @return QUI\Projects\Site
*/
protected function getSite()
{
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
$site = $this->getAttribute('site');
if (is_numeric($site)) {
try {
return $Project->get((int)$site);
} catch (QUI\Exception $Exception) {
QUI\System\Log::addWarning($Exception->getMessage());
return $Project->firstChild();
}
}
// order
switch ($this->getAttribute('order')) {
case 'name ASC':
case 'name DESC':
case 'title ASC':
case 'title DESC':
case 'c_date ASC':
case 'c_date DESC':
case 'd_date ASC':
case 'd_date DESC':
case 'release_from ASC':
case 'release_from DESC':
$order = $this->getAttribute('order');
break;
default:
$order = 'release_from DESC';
break;
}
$children = QUI\Projects\Site\Utils::getSitesByInputList(
$this->getProject(),
$this->getAttribute('site'),
array(
'limit' => 1,
'order' => $order
)
);
if (isset($children[0])) {
return $children[0];
}
return $Project->firstChild();
}
}