public function grid()
{
return _class('html')->grid([
[
['s1'],
['s1'],
['s1'],
['s1'],
['s1'],
['s1'],
['s1'],
['s1', 'class' => 'btn btn-warning'],
['s1'],
['s1', 'class' => 'btn btn-primary'],
['s1'],
['s1'],
],
[
['s4'],
['s4'],
['s4'],
],
[
['s4', 'col' => 4, 'class' => 'alert alert-error'],
['s8', 'col' => 8, 'class' => 'alert alert-info'],
],
[
['s6'],
['s6'],
],
[
['s12'],
],
]);
}
public function grid($data = [], $extra = [])
{
$extra['id'] = $extra['id'] ?: __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$rows = [];
$ul_opened = false;
foreach ((array) $data as $id => $row) {
$items = [];
$row_col = count((array) $row) ? floor(12 / count((array) $row)) : 1;
if ($row_col < 1) {
$row_col = 1;
}
foreach ((array) $row as $rid => $item) {
$body = $item[0] ?: $item['body'];
$col = $item[1] ?: $item['col'];
$class = $item['class'];
if ( ! $col) {
$col = $row_col;
}
$items[] = '<div class="span' . $col . ' col-md-' . $col . ($class ? ' ' . $class : '') . '">' . $body . '</div>';
}
$rows[] = '<div class="row-fluid show-grid">' . implode(PHP_EOL, $items) . '</div>';
}
return '<div class="grid' . ($extra['class'] ? ' ' . $extra['class'] : '') . '" id="' . $extra['id'] . '">' . implode(PHP_EOL, (array) $rows) . '</div>';
}