mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
N°2060 Fix regression introduced during migration (iPortalUIExtension extensions not working)
This commit is contained in:
@@ -124,6 +124,9 @@ services:
|
||||
navigation_rule_helper:
|
||||
alias: Combodo\iTop\Portal\Helper\NavigationRuleHelper
|
||||
public: true
|
||||
ui_extensions_helper:
|
||||
alias: Combodo\iTop\Portal\Helper\UIExtensionsHelper
|
||||
public: true
|
||||
lifecycle_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\LifecycleValidatorHelper
|
||||
public: true
|
||||
|
||||
@@ -15,17 +15,14 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration;
|
||||
|
||||
use Combodo\iTop\DesignElement;
|
||||
use Combodo\iTop\Portal\Helper\UIExtensionsHelper;
|
||||
use DOMFormatException;
|
||||
use Exception;
|
||||
use iPortalUIExtension;
|
||||
use MetaModel;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use utils;
|
||||
|
||||
@@ -54,9 +51,6 @@ class Basic extends AbstractConfiguration
|
||||
$aPortalConf = $this->ParseGlobalProperties($aPortalConf);
|
||||
// - Rectifying portal logo url
|
||||
$aPortalConf = $this->AppendLogoUri($aPortalConf);
|
||||
|
||||
// - class list
|
||||
$aPortalConf['ui_extensions'] = $this->GetUiExtensions($oContainer);
|
||||
}
|
||||
catch (Exception $oException)
|
||||
{
|
||||
@@ -97,13 +91,6 @@ class Basic extends AbstractConfiguration
|
||||
),
|
||||
),
|
||||
'forms' => array(),
|
||||
'ui_extensions' => array(
|
||||
'css_files' => array(),
|
||||
'css_inline' => null,
|
||||
'js_files' => array(),
|
||||
'js_inline' => null,
|
||||
'html' => array(),
|
||||
),
|
||||
'bricks' => array(),
|
||||
'bricks_total_width' => 0,
|
||||
);
|
||||
@@ -283,82 +270,4 @@ class Basic extends AbstractConfiguration
|
||||
|
||||
return $aPortalConf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\DependencyInjection\Container $oContainer
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function GetUiExtensions(Container $oContainer)
|
||||
{
|
||||
$aUIExtensions = array(
|
||||
'css_files' => array(),
|
||||
'css_inline' => null,
|
||||
'js_files' => array(),
|
||||
'js_inline' => null,
|
||||
'html' => array(),
|
||||
);
|
||||
$aUIExtensionHooks = array(
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY,
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU,
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT,
|
||||
);
|
||||
|
||||
/** @var iPortalUIExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iPortalUIExtension') as $oExtensionInstance)
|
||||
{
|
||||
// Adding CSS files
|
||||
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
|
||||
foreach ($oExtensionInstance->GetCSSFiles($oContainer) as $sCSSFile)
|
||||
{
|
||||
// Removing app root url as we need to pass a path on the file system (relative to app root)
|
||||
$sCSSFilePath = str_replace(utils::GetAbsoluteUrlAppRoot(), '', $sCSSFile);
|
||||
// Compiling SCSS file
|
||||
$sCSSFileCompiled = utils::GetAbsoluteUrlAppRoot().utils::GetCSSFromSASS($sCSSFilePath,
|
||||
$aImportPaths);
|
||||
|
||||
if (!in_array($sCSSFileCompiled, $aUIExtensions['css_files']))
|
||||
{
|
||||
$aUIExtensions['css_files'][] = $sCSSFileCompiled;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding CSS inline
|
||||
$sCSSInline = $oExtensionInstance->GetCSSInline($oContainer);
|
||||
if ($sCSSInline !== null)
|
||||
{
|
||||
$aUIExtensions['css_inline'] .= "\n\n".$sCSSInline;
|
||||
}
|
||||
|
||||
// Adding JS files
|
||||
$aUIExtensions['js_files'] = array_merge($aUIExtensions['js_files'],
|
||||
$oExtensionInstance->GetJSFiles($oContainer));
|
||||
|
||||
// Adding JS inline
|
||||
$sJSInline = $oExtensionInstance->GetJSInline($oContainer);
|
||||
if ($sJSInline !== null)
|
||||
{
|
||||
// Note: Semi-colon is to prevent previous script that would have omitted it.
|
||||
$aUIExtensions['js_inline'] .= "\n\n;\n".$sJSInline;
|
||||
}
|
||||
|
||||
// Adding HTML for each hook
|
||||
foreach ($aUIExtensionHooks as $sUIExtensionHook)
|
||||
{
|
||||
$sFunctionName = 'Get'.$sUIExtensionHook.'HTML';
|
||||
$sHTML = $oExtensionInstance->$sFunctionName($oContainer);
|
||||
if ($sHTML !== null)
|
||||
{
|
||||
if (!array_key_exists($sUIExtensionHook, $aUIExtensions['html']))
|
||||
{
|
||||
$aUIExtensions['html'][$sUIExtensionHook] = '';
|
||||
}
|
||||
$aUIExtensions['html'][$sUIExtensionHook] .= "\n\n".$sHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aUIExtensions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Portal\Helper;
|
||||
|
||||
|
||||
use InvalidParameterException;
|
||||
use iPortalUIExtension;
|
||||
use MetaModel;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Class UIExtensionsHelper
|
||||
*
|
||||
* @property array css_files
|
||||
* @property string|null css_inline
|
||||
* @property array js_files
|
||||
* @property string|null js_inline
|
||||
* @property array html
|
||||
*
|
||||
* @package Combodo\iTop\Portal\Helper
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class UIExtensionsHelper
|
||||
{
|
||||
/** @var null|array $aUIExtensions Lazy loaded (hence the null by default) */
|
||||
protected $aUIExtensions;
|
||||
/** @var \Symfony\Component\DependencyInjection\Container $oContainer */
|
||||
private $oContainer;
|
||||
|
||||
/**
|
||||
* UIExtensionsHelper constructor.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $oContainer
|
||||
*/
|
||||
public function __construct(ContainerInterface $oContainer)
|
||||
{
|
||||
$this->oContainer = $oContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPropName
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \InvalidParameterException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($sPropName)
|
||||
{
|
||||
if ($this->aUIExtensions === null)
|
||||
{
|
||||
$this->InitUIExtensions();
|
||||
}
|
||||
|
||||
if (array_key_exists($sPropName, $this->aUIExtensions))
|
||||
{
|
||||
return $this->aUIExtensions[$sPropName];
|
||||
}
|
||||
|
||||
throw new InvalidParameterException("Invalid property name $sPropName");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPropName
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __isset($sPropName)
|
||||
{
|
||||
if ($this->aUIExtensions === null)
|
||||
{
|
||||
$this->InitUIExtensions();
|
||||
}
|
||||
|
||||
return array_key_exists($sPropName, $this->aUIExtensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetUIExtensions()
|
||||
{
|
||||
return $this->aUIExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the UI extensions implementing iPortalUIExtension
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function InitUIExtensions()
|
||||
{
|
||||
$aUIExtensions = array(
|
||||
'css_files' => array(),
|
||||
'css_inline' => null,
|
||||
'js_files' => array(),
|
||||
'js_inline' => null,
|
||||
'html' => array(),
|
||||
);
|
||||
|
||||
$aUIExtensionHooks = array(
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY,
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU,
|
||||
iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT,
|
||||
);
|
||||
|
||||
/** @var iPortalUIExtension $oExtensionInstance */
|
||||
foreach (MetaModel::EnumPlugins('iPortalUIExtension') as $oExtensionInstance)
|
||||
{
|
||||
// Adding CSS files
|
||||
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
|
||||
foreach ($oExtensionInstance->GetCSSFiles($this->oContainer) as $sCSSFile)
|
||||
{
|
||||
// Removing app root url as we need to pass a path on the file system (relative to app root)
|
||||
$sCSSFilePath = str_replace(utils::GetAbsoluteUrlAppRoot(), '', $sCSSFile);
|
||||
// Compiling SCSS file
|
||||
$sCSSFileCompiled = utils::GetAbsoluteUrlAppRoot().utils::GetCSSFromSASS($sCSSFilePath,
|
||||
$aImportPaths);
|
||||
|
||||
if (!in_array($sCSSFileCompiled, $aUIExtensions['css_files']))
|
||||
{
|
||||
$aUIExtensions['css_files'][] = $sCSSFileCompiled;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding CSS inline
|
||||
$sCSSInline = $oExtensionInstance->GetCSSInline($this->oContainer);
|
||||
if ($sCSSInline !== null)
|
||||
{
|
||||
$aUIExtensions['css_inline'] .= "\n\n".$sCSSInline;
|
||||
}
|
||||
|
||||
// Adding JS files
|
||||
$aUIExtensions['js_files'] = array_merge($aUIExtensions['js_files'],
|
||||
$oExtensionInstance->GetJSFiles($this->oContainer));
|
||||
|
||||
// Adding JS inline
|
||||
$sJSInline = $oExtensionInstance->GetJSInline($this->oContainer);
|
||||
if ($sJSInline !== null)
|
||||
{
|
||||
// Note: Semi-colon is to prevent previous script that would have omitted it.
|
||||
$aUIExtensions['js_inline'] .= "\n\n;\n".$sJSInline;
|
||||
}
|
||||
|
||||
// Adding HTML for each hook
|
||||
foreach ($aUIExtensionHooks as $sUIExtensionHook)
|
||||
{
|
||||
$sFunctionName = 'Get'.$sUIExtensionHook.'HTML';
|
||||
$sHTML = $oExtensionInstance->$sFunctionName($this->oContainer);
|
||||
if ($sHTML !== null)
|
||||
{
|
||||
if (!array_key_exists($sUIExtensionHook, $aUIExtensions['html']))
|
||||
{
|
||||
$aUIExtensions['html'][$sUIExtensionHook] = '';
|
||||
}
|
||||
$aUIExtensions['html'][$sUIExtensionHook] .= "\n\n".$sHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->aUIExtensions = $aUIExtensions;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@
|
||||
{# - Portal adjustments for BS theme #}
|
||||
<link href="{{ app['combodo.portal.instance.conf'].properties.themes.portal|add_itop_version }}" rel="stylesheet" id="css_portal">
|
||||
{# UI Extensions CSS, in an undefined order #}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.css_files is defined %}
|
||||
{% for css_file in app['combodo.portal.instance.conf'].ui_extensions.css_files %}
|
||||
{% if app['ui_extensions_helper'].css_files is defined %}
|
||||
{% for css_file in app['ui_extensions_helper'].css_files %}
|
||||
<link href="{{ css_file|add_itop_version }}" rel="stylesheet">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -73,9 +73,9 @@
|
||||
|
||||
{% block pStyleinline %}
|
||||
{# UI Extensions inline CSS #}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.css_inline is not null %}
|
||||
{% if app['ui_extensions_helper'].css_inline is not null %}
|
||||
<style>
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.css_inline|raw }}
|
||||
{{ app['ui_extensions_helper'].css_inline|raw }}
|
||||
</style>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -146,8 +146,8 @@
|
||||
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal-clipboard.js'|add_itop_version }}"></script>
|
||||
|
||||
{# UI Extensions JS, in an undefined order #}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.js_files is defined %}
|
||||
{% for js_file in app['combodo.portal.instance.conf'].ui_extensions.js_files %}
|
||||
{% if app['ui_extensions_helper'].js_files is defined %}
|
||||
{% for js_file in app['ui_extensions_helper'].js_files %}
|
||||
<script type="text/javascript" src="{{ js_file|add_itop_version }}"></script>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -237,8 +237,8 @@
|
||||
</div>
|
||||
|
||||
{% block pPageUIExtensionNavigationMenuTopbar %}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
|
||||
{% if app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
|
||||
{{ app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
@@ -299,8 +299,8 @@
|
||||
</div>
|
||||
|
||||
{% block pPageUIExtensionNavigationMenuSidebar %}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
|
||||
{% if app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')] is defined %}
|
||||
{{ app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_NAVIGATION_MENU')]|raw }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -349,8 +349,8 @@
|
||||
</div>
|
||||
|
||||
{% block pPageUIExtensionMainContent %}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')] is defined %}
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')]|raw }}
|
||||
{% if app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')] is defined %}
|
||||
{{ app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_MAIN_CONTENT')]|raw }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
@@ -400,8 +400,8 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block pPageUIExtensionBody %}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')] is defined %}
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')]|raw }}
|
||||
{% if app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')] is defined %}
|
||||
{{ app['ui_extensions_helper'].html[constant('iPortalUIExtension::ENUM_PORTAL_EXT_UI_BODY')]|raw }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
@@ -503,9 +503,9 @@
|
||||
|
||||
{% block pPageExtensionsScripts %}
|
||||
{# UI Extensions inline JS #}
|
||||
{% if app['combodo.portal.instance.conf'].ui_extensions.js_inline is not null %}
|
||||
{% if app['ui_extensions_helper'].js_inline is not null %}
|
||||
<script type="text/javascript">
|
||||
{{ app['combodo.portal.instance.conf'].ui_extensions.js_inline|raw }}
|
||||
{{ app['ui_extensions_helper'].js_inline|raw }}
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -63,6 +63,7 @@ return array(
|
||||
'Combodo\\iTop\\Portal\\Helper\\RequestManipulatorHelper' => $baseDir . '/src/Helper/RequestManipulatorHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\ScopeValidatorHelper' => $baseDir . '/src/Helper/ScopeValidatorHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\SecurityHelper' => $baseDir . '/src/Helper/SecurityHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\UIExtensionsHelper' => $baseDir . '/src/Helper/UIExtensionsHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Kernel' => $baseDir . '/src/Kernel.php',
|
||||
'Combodo\\iTop\\Portal\\Routing\\ItopExtensionsExtraRoutes' => $baseDir . '/src/Routing/ItopExtensionsExtraRoutes.php',
|
||||
'Combodo\\iTop\\Portal\\Routing\\UrlGenerator' => $baseDir . '/src/Routing/UrlGenerator.php',
|
||||
|
||||
@@ -83,6 +83,7 @@ class ComposerStaticInitdf408f3f8ea034d298269cdf7647358b
|
||||
'Combodo\\iTop\\Portal\\Helper\\RequestManipulatorHelper' => __DIR__ . '/../..' . '/src/Helper/RequestManipulatorHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\ScopeValidatorHelper' => __DIR__ . '/../..' . '/src/Helper/ScopeValidatorHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\SecurityHelper' => __DIR__ . '/../..' . '/src/Helper/SecurityHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Helper\\UIExtensionsHelper' => __DIR__ . '/../..' . '/src/Helper/UIExtensionsHelper.php',
|
||||
'Combodo\\iTop\\Portal\\Kernel' => __DIR__ . '/../..' . '/src/Kernel.php',
|
||||
'Combodo\\iTop\\Portal\\Routing\\ItopExtensionsExtraRoutes' => __DIR__ . '/../..' . '/src/Routing/ItopExtensionsExtraRoutes.php',
|
||||
'Combodo\\iTop\\Portal\\Routing\\UrlGenerator' => __DIR__ . '/../..' . '/src/Routing/UrlGenerator.php',
|
||||
|
||||
Reference in New Issue
Block a user