sName = $sName; $this->sPrefix = $sPrefix; $this->sLayout = appUserPreferences::GetPref('tab_layout', static::DEFAULT_LAYOUT); } /** * @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\Layout\TabContainer\Tab\Tab $oTab */ $oTab = $this->GetSubBlock($sTabCode); return $oTab; } /** * @param string $sTabCode * @param string $sTitle * * @return \Combodo\iTop\Application\UI\Layout\TabContainer\Tab\Tab * @throws \Combodo\iTop\Application\UI\UIException */ public function AddAjaxTab(string $sTabCode, string $sTitle): Tab { $oTab = new AjaxTab($sTabCode, $sTitle); $this->AddSubBlock($oTab); return $oTab; } /** * @param string $sTabCode * @param string $sTitle * * @return \Combodo\iTop\Application\UI\Layout\TabContainer\Tab\Tab * @throws \Combodo\iTop\Application\UI\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\iUIBlock $oSubBlock * * @return iUIContentBlock * @throws \Combodo\iTop\Application\UI\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; } }