oAttDef = $oAttDef; $this->sAttCode = $sAttCode; $this->sObjectClass = $sObjectClass; $this->oDbObject = $oDbObject; $this->sTableId = 'rel_'.$this->sAttCode; $this->SetDataAttributes(['role' => 'ibo-block-links-table', 'link-attcode' => $sAttCode, 'link-class' => $this->oAttDef->GetLinkedClass()]); // Initialization $this->Init(); // UI Initialization $this->InitUI($oPage); } /** * Init. * * @return void * @throws Exception */ private function Init() { $this->sTargetClass = $this->GetTargetClass(); } /** * @param string $sKey * @param \DBObject|null $oDBObject * * @return string * @throws \ArchivedObjectException * @throws \CoreException */ public function GetDictionaryEntry(string $sKey, DBObject $oDBObject = null) { return $this->oAttDef->SearchSpecificLabel($sKey, '', true, $this->sObjectClass, $this->oDbObject->Get('friendlyname'), $this->oAttDef->GetLabel(), $this->sTargetClass, $oDBObject !== null ? $oDBObject->Get('friendlyname') : '{item}'); } /** * Initialize UI. * * @return void * @throws CoreException */ private function InitUI(WebPage $oPage) { // header $this->InitHeader(); // Table $this->InitTable($oPage); } /** * InitHeader by adding UIBlocks to the current self * * @return void * @throws CoreException * @throws \Exception */ private function InitHeader() { } /** * InitTable. * * @param WebPage $oPage * * @return void * @throws ApplicationException * @throws ArchivedObjectException * @throws CoreException * @throws CoreWarning * @throws DictExceptionMissingString * @throws MySQLException */ private function InitTable(WebPage $oPage) { // retrieve db object set $oOrmLinkSet = $this->oDbObject->Get($this->sAttCode); $oLinkSet = $oOrmLinkSet->ToDBObjectSet(utils::ShowObsoleteData()); // add list block $oBlock = new DisplayBlock($oLinkSet->GetFilter(), 'listInObject', false); $this->AddSubBlock($oBlock->GetRenderContent($oPage, $this->GetExtraParam(), $this->sTableId)); } /** * GetTableId. * * @return string table identifier */ protected function GetTableId(): string { return $this->sObjectClass.'_'.$this->sAttCode; } /** * GetDoNotShowAgainPreferenceKey. * * @return string do not show again preference key */ protected function GetDoNotShowAgainPreferenceKey(): string { return "{$this->GetTableId()}.remove_link.do_not_show_again"; } /** * GetExtraParam. * * Provide parameters for display block as list. * * @see DisplayBlock::RenderList * * @return array * @throws ArchivedObjectException * @throws CoreException */ abstract function GetExtraParam(): array; /** * Return row actions. * * Register row actions for table. * * @see \Combodo\iTop\Application\UI\Base\Component\DataTable\tTableRowActions * * @return string[][] */ abstract function GetRowActions(): array; /** * GetTargetClass. * * Return link set target class. * * @return string * @throws Exception */ abstract function GetTargetClass(): string; /** * GetAttCode. * * @return string */ public function GetAttCode(): string { return $this->sAttCode; } /** * GetLinkedClass. * * @return mixed */ public function GetLinkedClass() { return $this->oAttDef->GetLinkedClass(); } /** * GetExternalKeyToMe. * * @return mixed */ public function GetExternalKeyToMe() { return $this->oAttDef->GetExtKeyToMe(); } /** * GetWidgetName. * * @return string */ public function GetWidgetName(): string { return "oWidget{$this->GetId()}"; } }