Box.php
1.28 KB
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
<?php
class N2Box extends N2EmbedWidget implements N2EmbedWidgetInterface
{
public static $params = array(
'attributes' => array(),
'center' => null,
'centerAttributes' => array(),
'lt' => null,
'rt' => null,
'lb' => null,
'rb' => null,
'ltAttributes' => array(),
'rtAttributes' => array(),
'lbAttributes' => array(),
'rbAttributes' => array(),
'overlay' => false,
'placeholderContent' => ''
);
public function run($params) {
$params = array_merge(self::$params, $params);
$this->addClass($params['attributes'], 'n2-box');
$this->addClass($params['centerAttributes'], 'n2-box-center');
$this->addClass($params['ltAttributes'], 'n2-box-lt');
$this->addClass($params['rtAttributes'], 'n2-box-rt');
$this->addClass($params['lbAttributes'], 'n2-box-lb');
$this->addClass($params['rbAttributes'], 'n2-box-rb');
$this->render($params);
}
private function addClass(&$a, $class) {
if (empty($a['class'])) {
$a['class'] = '';
}
$a['class'] .= ' ' . $class;
}
}