68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
|
<?php
|
||
|
namespace nur\v\bs3;
|
||
|
|
||
|
use nur\md;
|
||
|
use nur\v\base\AbstractLayoutManager;
|
||
|
use nur\v\v;
|
||
|
|
||
|
class Bs3LayoutManager extends AbstractLayoutManager {
|
||
|
const ROW_OPTIONS_SCHEMA = [
|
||
|
"class" => "?string",
|
||
|
];
|
||
|
|
||
|
protected function getRowTags($options): array {
|
||
|
md::ensure_schema($options, self::ROW_OPTIONS_SCHEMA);
|
||
|
return [
|
||
|
v::sdiv(["class" => ["row", $options["class"]]]),
|
||
|
v::ediv(),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
const COL_OPTIONS_SCHEMA = [
|
||
|
"class" => "?string",
|
||
|
];
|
||
|
|
||
|
protected function getColTags($size, $options): array {
|
||
|
md::ensure_schema($options, self::COL_OPTIONS_SCHEMA);
|
||
|
$colClass = [];
|
||
|
if (is_array($size)) {
|
||
|
foreach ($size as $type => $amount) {
|
||
|
$colClass[] = "col-$type-$amount";
|
||
|
}
|
||
|
} else {
|
||
|
$colClass[] = "col-md-$size";
|
||
|
}
|
||
|
|
||
|
return [
|
||
|
v::sdiv(["class" => [$colClass, $options["class"]]]),
|
||
|
v::ediv(),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
const PANEL_OPTIONS_SCHEMA = [
|
||
|
"class" => "?string",
|
||
|
"type" => "?string",
|
||
|
"body" => ["bool", true, "faut-il ajouter la section panel-body?"],
|
||
|
];
|
||
|
|
||
|
protected function getPanelTags($title, $options): array {
|
||
|
md::ensure_schema($options, self::PANEL_OPTIONS_SCHEMA);
|
||
|
|
||
|
$type = $options["type"];
|
||
|
if ($type === null) $type = "default";
|
||
|
$body = $options["body"];
|
||
|
|
||
|
return [
|
||
|
[
|
||
|
v::sdiv(["class" => ["panel panel-$type", $options["class"]]]),
|
||
|
v::div(["class" => "panel-heading", q($title)]),
|
||
|
v::if($body, v::sdiv(["class" => "panel-body"])),
|
||
|
],
|
||
|
[
|
||
|
v::if($body, v::ediv()),
|
||
|
v::ediv(),
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
}
|