-
Notifications
You must be signed in to change notification settings - Fork 3
/
Grid.php
51 lines (44 loc) · 949 Bytes
/
Grid.php
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
<?php
namespace xj\weui;
/**
*
* @author xjflyttp <xjflyttp@gmail.com>
* @see https://github.com/weui/weui/wiki/Grid
*/
class Grid extends Widget
{
/**
* Grid Items
* @var GridItem[]
*/
public $items = [];
/**
* @var string
*/
public $itemsClass = 'xj\weui\GridItem';
public function init()
{
parent::init();
Html::addCssClass($this->options, ['weui_grids']);
}
public function run()
{
if (empty($this->items)) {
return '';
}
$options = $this->options;
$content = $this->renderItems();
return Html::tag('div', $content, $options);
}
/**
* @return string
*/
protected function renderItems()
{
$itemsHtml = '';
foreach ($this->items as $item) {
$itemsHtml .= call_user_func([$this->itemsClass, 'widget'], $item);
}
return $itemsHtml;
}
}