sName = $sId; $this->sPrefix = $sPrefix; $this->sLayout = appUserPreferences::GetPref('tab_layout', static::DEFAULT_LAYOUT); $this->bIsScrollable = appUserPreferences::GetPref('tab_scrollable', static::DEFAULT_SCROLLABLE); } /** * @param string $sTabCode * * @return bool */ public function TabExists(string $sTabCode): bool { return $this->HasSubBlock($sTabCode); } public function GetTab($sTabCode): ?Tab { /** @var \Combodo\iTop\Application\UI\Base\Layout\TabContainer\Tab\Tab $oTab */ $oTab = $this->GetSubBlock($sTabCode); return $oTab; } /** * @param string $sTabCode * @param string $sTitle * @param string|null $sPlaceholder * * @return \Combodo\iTop\Application\UI\Base\Layout\TabContainer\Tab\Tab * @throws \Combodo\iTop\Application\UI\Base\UIException */ public function AddAjaxTab(string $sTabCode, string $sTitle, ?string $sPlaceholder = null): Tab { if($sPlaceholder === null){ $sPlaceholder = AjaxTab::DEFAULT_TAB_PLACEHOLDER; } $oTab = new AjaxTab($sTabCode, $sTitle, $sPlaceholder); $this->AddSubBlock($oTab); return $oTab; } /** * @param string $sTabCode * @param string $sTitle * * @return \Combodo\iTop\Application\UI\Base\Layout\TabContainer\Tab\Tab * @throws \Combodo\iTop\Application\UI\Base\UIException */ public function AddTab(string $sTabCode, string $sTitle): Tab { $oTab = new Tab($sTabCode, $sTitle); $this->AddSubBlock($oTab); return $oTab; } public function RemoveTab(string $sTabCode): self { $this->RemoveSubBlock($sTabCode); return $this; } /** * @param \Combodo\iTop\Application\UI\Base\iUIBlock $oSubBlock * * @return iUIContentBlock * @throws \Combodo\iTop\Application\UI\Base\UIException */ public function AddSubBlock(?iUIBlock $oSubBlock): iUIContentBlock { if (!($oSubBlock instanceof Tab)) { throw new UIException($this, Dict::Format('UIBlock:Error:AddBlockNotTabForbidden', $oSubBlock->GetId(), $this->GetId())); } return parent::AddSubBlock($oSubBlock); } /** * Return tab list * * @return array */ public function Get(): array { $aTabs = []; foreach ($this->GetSubBlocks() as $oTab) { $aTabs[] = $oTab->GetParameters(); } return [ 'sBlockId' => $this->GetId(), 'aTabs' => $aTabs ]; } /** * @param string $sLayout * * @return $this */ public function SetLayout($sLayout) { $this->sLayout = $sLayout; return $this; } /** * @return string */ public function GetLayout(): string { return $this->sLayout; } /** * @param bool $bIsScrollable * @return $this */ public function SetIsScrollable($bIsScrollable) { $this->bIsScrollable = $bIsScrollable; return $this; } /** * @return bool */ public function GetIsScrollable(): bool { return $this->bIsScrollable; } }