setTabs($tabs); } protected function filterTab($tab, ?array $tabs=null): bool { return false; } protected function getCod($tab): string { $codKey = static::COD_KEY; $tab = A::with($tab); if ($codKey !== null) return A::get($tab, $codKey, ""); return A::first($tab, ""); } protected function getTitle($tab): ?string { $titleKey = static::TITLE_KEY; $tab = A::with($tab); if ($titleKey !== null) return A::get($tab, $titleKey); else return A::second($tab); } private function getCodTitle($tab): array { $cod = $this->getCod($tab); $title = $this->getTitle($tab); if ($title == null) $title = $cod; return [$cod, $title]; } function setTabs(?array $tabs=null): void { $tabs = A::with($tabs); $filteredTabs = []; $tabCods = []; foreach ($tabs as $tab) { if ($this->filterTab($tab, $tabs)) continue; $filteredTabs[] = $tab; $tabCods[] = $this->getCod($tab); } $this->tabs = $filteredTabs; $this->tabCods = $tabCods; } const HAVE_JQUERY = true; protected function jqSetup(): void {} protected function jqBeforeDeactivate(): void {} protected function jqAfterActivate(): void {} function printJquery(): void { $tabCods = $this->tabCods; if (!$tabCods) return; ?> tabs; if (!$tabs) return; vo::sul(["class" => "nav nav-tabs"]); foreach ($tabs as $tab) { [$cod, $title] = $this->getCodTitle($tab); vo::li([ "id" => "${cod}_tab", "class" => $cod === $curCod? "active": null, "role" => "presentation", v::a([ "href" => $this->getUrl($tab), q($title), v::span(["class" => "badge", $this->getBadge($tab)]) ]), ]); } vo::eul(); } function paStartPanel($cod): void { if (!is_string($cod)) $cod = $this->getCod($cod); vo::sdiv(["id" => "${cod}_panel"]); } function paEndPanel(): void { vo::ediv(); } function printActions(?string $curCod, callable $printPanel, ?callable $beforePanels=null, ?callable $afterPanels=null): bool { $tabs = $this->tabs; if (!$tabs) return false; $func = func::_prepare($printPanel); $this->paTabs($curCod); if ($beforePanels !== null) $beforePanels(); foreach ($this->tabs as $tab) { $this->paStartPanel($tab); func::_call($func, [$tab, $this]); $this->paEndPanel(); } if ($afterPanels !== null) $afterPanels(); return true; } }