🎨 N°3566 Hub connector : code format

This commit is contained in:
Pierre Goiffon
2021-03-09 09:54:42 +01:00
parent 0f3df3a436
commit 9f06e82171
2 changed files with 206 additions and 252 deletions

View File

@@ -17,14 +17,14 @@
* You should have received a copy of the GNU Affero General Public License
*/
require_once ('../approot.inc.php');
require_once (APPROOT.'/application/application.inc.php');
require_once (APPROOT.'/application/itopwebpage.class.inc.php');
require_once (APPROOT.'setup/extensionsmap.class.inc.php');
require_once('../approot.inc.php');
require_once(APPROOT.'/application/application.inc.php');
require_once(APPROOT.'/application/itopwebpage.class.inc.php');
require_once(APPROOT.'setup/extensionsmap.class.inc.php');
require_once (APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
require_once (APPROOT.'/application/loginwebpage.class.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
$oAppContext = new ApplicationContext();
@@ -35,12 +35,9 @@ $oPage->SetBreadCrumbEntry('ui-hub-myextensions', Dict::S('Menu:iTopHub:MyExtens
function DisplayExtensionInfo(Webpage $oPage, iTopExtension $oExtension)
{
$oPage->add('<li>');
if ($oExtension->sInstalledVersion == '')
{
if ($oExtension->sInstalledVersion == '') {
$oPage->add('<b>'.$oExtension->sLabel.'</b> '.Dict::Format('UI:About:Extension_Version', $oExtension->sVersion).' <span class="extension-source">'.Dict::S('iTopHub:ExtensionNotInstalled').'</span>');
}
else
{
} else {
$oPage->add('<b>'.$oExtension->sLabel.'</b> '.Dict::Format('UI:About:Extension_Version', $oExtension->sInstalledVersion));
}
$oPage->add('<p style="margin-top: 0.25em;">'.$oExtension->sDescription.'</p>');
@@ -48,29 +45,25 @@ function DisplayExtensionInfo(Webpage $oPage, iTopExtension $oExtension)
}
// Main program
try
{
try {
$oExtensionsMap = new iTopExtensionsMap();
$oExtensionsMap->LoadChoicesFromDatabase(MetaModel::GetConfig());
$oPage->add('<h1>'.Dict::S('iTopHub:InstalledExtensions').'</h1>');
$oPage->add('<fieldset>');
$oPage->add('<legend>'.Dict::S('iTopHub:ExtensionCategory:Remote').'</legend>');
$oPage->p(Dict::S('iTopHub:ExtensionCategory:Remote+'));
$oPage->add('<ul style="margin: 0;">');
$iCount = 0;
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
{
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE)
{
$iCount++ ;
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
if ($oExtension->sSource == iTopExtension::SOURCE_REMOTE) {
$iCount++;
DisplayExtensionInfo($oPage, $oExtension);
}
}
$oPage->add('</ul>');
if ($iCount == 0)
{
if ($iCount == 0) {
$oPage->p(Dict::S('iTopHub:NoExtensionInThisCategory'));
}
$oPage->add('</fieldset>');
@@ -79,45 +72,39 @@ try
// Display the section about "manually deployed" extensions, only if there are some already
$iCount = 0;
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
{
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL)
{
$iCount++ ;
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL) {
$iCount++;
}
}
if ($iCount > 0)
{
if ($iCount > 0) {
$oPage->add('<fieldset>');
$oPage->add('<legend>'.Dict::S('iTopHub:ExtensionCategory:Manual').'</legend>');
$oPage->p(Dict::Format('iTopHub:ExtensionCategory:Manual+', '<span title="'.(APPROOT.'extensions').'" id="extension-dir-path">"extensions"</span>'));
$oPage->add('<ul style="margin: 0;">');
$iCount = 0;
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension)
{
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL)
{
foreach ($oExtensionsMap->GetAllExtensions() as $oExtension) {
if ($oExtension->sSource == iTopExtension::SOURCE_MANUAL) {
DisplayExtensionInfo($oPage, $oExtension);
}
}
$oPage->add('</ul>');
}
$oPage->add('</fieldset>');
$sExtensionsDirTooltip = json_encode(APPROOT.'extensions');
$oPage->add_style(
<<<EOF
<<<CSS
#extension-dir-path {
display: inline-block;
border-bottom: 1px #999 dashed;
cursor: help;
}
EOF
CSS
);
}
catch (Exception $e)
{
catch (Exception $e) {
$oPage->p('<b>'.Dict::Format('UI:Error_Details', $e->getMessage()).'</b>');
}