SetBreadCrumbEntry('ui-hub-myextensions', Dict::S('Menu:iTopHub:MyExtensions'), Dict::S('Menu:iTopHub:MyExtensions+'), '', 'fas fa-puzzle-piece', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES); function GetExtensionInfoComponent(iTopExtension $oExtension): UIBlock { $sExtensionDescription = Dict::Format('UI:About:Extension_Version', $oExtension->sVersion); if (!empty($oExtension->sLabel)) { $sExtensionDescription .= '
'.$oExtension->sDescription.''; } return AlertUIBlockFactory::MakeForInformation($oExtension->sLabel, $sExtensionDescription) ->SetIsClosable(false) ->SetIsCollapsible(true) ->SetOpenedByDefault(false); } try { $oExtensionsMap = new iTopExtensionsMap(); $oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig()); $oPage->AddUiBlock(TitleUIBlockFactory::MakeForPage(Dict::S('iTopHub:InstalledExtensions'))); /**------------------------------------------------------------------------------------------------------ * Remotely deployed ext */ $oFieldsetRemote = FieldSetUIBlockFactory::MakeStandard(Dict::S('iTopHub:ExtensionCategory:Remote')); $oPage->AddUiBlock($oFieldsetRemote); $aRemotelyDeployedExt = array_filter($oExtensionsMap->GetAllExtensions(), static function ($oExtension) { return ($oExtension->sSource === iTopExtension::SOURCE_REMOTE); }); $iRemotelyDeployedExtCount = count($aRemotelyDeployedExt); if ($iRemotelyDeployedExtCount === 0) { $oFieldsetRemote->AddSubBlock( AlertUIBlockFactory::MakeForWarning(Dict::S('iTopHub:NoExtensionInThisCategory'), Dict::S('iTopHub:NoExtensionInThisCategory+')) ->SetIsClosable(false) ->SetIsCollapsible(false) ); } else { $oFieldsetRemote->AddHtml('

'.Dict::S('iTopHub:ExtensionCategory:Remote+').'

'); foreach ($aRemotelyDeployedExt as $oExtension) { $oFieldsetRemote->AddSubBlock(GetExtensionInfoComponent($oExtension)); } } /**------------------------------------------------------------------------------------------------------ * Hub button */ $oHubButtonContainer = UIContentBlockUIBlockFactory::MakeStandard() ->AddCSSClass('hub-button'); $oPage->AddSubBlock($oHubButtonContainer); $sUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', ['target' => 'browse_extensions']); $oHubButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('iTopHub:GetMoreExtensions'), 'install-extensions-button') ->SetOnClickJsCode("window.location.href='$sUrl'") ->SetIconClass('fa-fw fc fc-itophub-icon fc-1-5x'); $oHubButtonContainer->AddSubBlock($oHubButton); /**------------------------------------------------------------------------------------------------------ * Manually deployed ext * Only if there are some ! */ $aManuallyDeployedExt = array_filter($oExtensionsMap->GetAllExtensions(), static function ($oExtension) { return ($oExtension->sSource === iTopExtension::SOURCE_MANUAL); }); $iManuallyDeployedExtCount = count($aManuallyDeployedExt); if ($iManuallyDeployedExtCount > 0) { $oFieldsetManual = FieldSetUIBlockFactory::MakeStandard(Dict::S('iTopHub:ExtensionCategory:Manual')); $oPage->AddUiBlock($oFieldsetManual); $oFieldsetManual->AddHtml(Dict::Format('iTopHub:ExtensionCategory:Manual+', '"extensions"')); foreach ($aManuallyDeployedExt as $oExtension) { $oFieldsetManual->AddSubBlock(GetExtensionInfoComponent($oExtension)); } } $sExtensionsDirTooltip = json_encode(APPROOT.'extensions'); $oPage->add_style( <<p(''.Dict::Format('UI:Error_Details', $e->getMessage()).''); } $oPage->output();