71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
namespace nur\v\bs3\vc;
|
|
|
|
use nur\A;
|
|
use nur\b\params\Tparametrable;
|
|
use nur\v\base\MenuManager;
|
|
use nur\v\page;
|
|
use nur\v\v;
|
|
use nur\v\vo;
|
|
|
|
class CNavTabs extends _CItemList {
|
|
use Tparametrable;
|
|
|
|
/** @var array tabs à afficher par défaut */
|
|
const TABS = null;
|
|
|
|
const PARAMETRABLE_PARAMS_SCHEMA = [
|
|
"select" => ["?string", null, "identifiant de l'élément sélectionné"],
|
|
"params" => ["?array", null, "paramètres par défaut à rajouter à tous les urls"]
|
|
];
|
|
|
|
const AUTOPRINT = true;
|
|
|
|
function __construct(?iterable $items=null, ?string $select=null, ?array $params=null) {
|
|
A::set_nn($params, "select", $select);
|
|
parent::__construct($items, $params);
|
|
}
|
|
|
|
protected function ITEMS(): ?iterable {
|
|
return static::TABS;
|
|
}
|
|
|
|
/** @var ?string */
|
|
protected $ppSelect;
|
|
|
|
/** @var ?array */
|
|
protected $ppParams;
|
|
|
|
protected function buildItems(): void {
|
|
if ($this->ppItems !== null) {
|
|
$menu = new MenuManager(["items" => $this->ppItems], $this->ppSelect);
|
|
$items = $menu->get()["navbar_items"];
|
|
} else {
|
|
$items = null;
|
|
}
|
|
$this->items = $items;
|
|
}
|
|
|
|
function printStartContainer(): void {
|
|
vo::sul([
|
|
"class" => "nav nav-tabs",
|
|
]);
|
|
}
|
|
|
|
function printItem($item): void {
|
|
vo::li([
|
|
"class" => ["active" => $item["active"]],
|
|
"role" => "presentation",
|
|
v::a([
|
|
"href" => page::bu($item["url"], $this->ppParams, $item["params"]),
|
|
"accesskey" => $item["accesskey"],
|
|
$item["text"],
|
|
]),
|
|
]);
|
|
}
|
|
|
|
function printEndContainer(): void {
|
|
vo::eul();
|
|
}
|
|
}
|