mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°1024 Portal: New portal instances can now be XML only (through ITSM Designer), no more need for a dedicated module !
SVN:trunk[4900]
This commit is contained in:
51
datamodels/2.x/itop-portal-base/index.php
Normal file
51
datamodels/2.x/itop-portal-base/index.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2017 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
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
/**
|
||||
* Executes a portal without having a dedicated module.
|
||||
* This allows to make a portal directly from the ITSM Designer.
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__ . '/../../approot.inc.php'))
|
||||
{
|
||||
require_once __DIR__ . '/../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once __DIR__ . '/../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
require_once APPROOT . '/application/startup.inc.php';
|
||||
|
||||
// If PORTAL_ID is not already defined, we look for it in a parameter
|
||||
if(!defined('PORTAL_ID'))
|
||||
{
|
||||
// Retrieving portal id from request params
|
||||
$sPortalId = utils::ReadParam('portal_id', '');
|
||||
if ($sPortalId == '')
|
||||
{
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Defining portal constants
|
||||
define('PORTAL_MODULE_ID', $sPortalId);
|
||||
define('PORTAL_ID', $sPortalId);
|
||||
}
|
||||
|
||||
require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/web/index.php';
|
||||
@@ -37,6 +37,7 @@ use \MetaModel;
|
||||
use \DBObjectSearch;
|
||||
use \DBObjectSet;
|
||||
use \iPortalUIExtension;
|
||||
use \ApplicationContext;
|
||||
use \Combodo\iTop\Portal\Brick\AbstractBrick;
|
||||
|
||||
/**
|
||||
@@ -406,6 +407,7 @@ class ApplicationHelper
|
||||
'layout' => 'itop-portal-base/portal/src/views/layout.html.twig',
|
||||
'home' => 'itop-portal-base/portal/src/views/home/layout.html.twig'
|
||||
),
|
||||
'urlmaker_class' => null,
|
||||
'triggers_query' => null,
|
||||
'attachments' => array(
|
||||
'allow_delete' => true
|
||||
@@ -433,6 +435,7 @@ class ApplicationHelper
|
||||
switch ($oPropertyNode->nodeName)
|
||||
{
|
||||
case 'name':
|
||||
case 'urlmaker_class':
|
||||
case 'triggers_query':
|
||||
$aPortalConf['properties'][$oPropertyNode->nodeName] = $oPropertyNode->GetText($aPortalConf['properties'][$oPropertyNode->nodeName]);
|
||||
break;
|
||||
@@ -539,6 +542,11 @@ class ApplicationHelper
|
||||
$aPortalConf['ui_extensions'] = static::LoadUIExtensions($oApp);
|
||||
// - Action rules
|
||||
static::LoadActionRulesConfiguration($oApp, $oDesign);
|
||||
// - Setting UrlMakerClass
|
||||
if($aPortalConf['properties']['urlmaker_class'] !== null)
|
||||
{
|
||||
ApplicationContext::SetUrlMakerClass($aPortalConf['properties']['urlmaker_class']);
|
||||
}
|
||||
// - Generating CSS files
|
||||
$aImportPaths = array($oApp['combodo.portal.base.absolute_path'] . 'css/');
|
||||
foreach ($aPortalConf['properties']['themes'] as $key => $value)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2015 Combodo SARL
|
||||
// Copyright (C) 2010-2017 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
@@ -54,12 +54,17 @@ class UrlGenerator extends SymfonyUrlGenerator
|
||||
}
|
||||
|
||||
// Optional parameters
|
||||
$sEnvSwitch = utils::ReadParam('env_switch', '', false, 'string');
|
||||
if ($sEnvSwitch !== '')
|
||||
{
|
||||
$parameters['env_switch'] = $sEnvSwitch;
|
||||
}
|
||||
$sDebug = utils::ReadParam('debug', '', false, 'string');
|
||||
$sPortalId = utils::ReadParam('portal_id', '', false, 'string');
|
||||
if ($sPortalId !== '')
|
||||
{
|
||||
$parameters['portal_id'] = $sPortalId;
|
||||
}
|
||||
$sEnvSwitch = utils::ReadParam('env_switch', '', false, 'string');
|
||||
if ($sEnvSwitch !== '')
|
||||
{
|
||||
$parameters['env_switch'] = $sEnvSwitch;
|
||||
}
|
||||
$sDebug = utils::ReadParam('debug', '', false, 'string');
|
||||
if ($sDebug !== '')
|
||||
{
|
||||
$parameters['debug'] = $sDebug;
|
||||
@@ -69,5 +74,3 @@ class UrlGenerator extends SymfonyUrlGenerator
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -3,7 +3,7 @@
|
||||
<portals>
|
||||
<portal id="legacy_portal" _delta="delete" /> <!-- TODO: voir si opportun de renommer au lieu de delete+define -->
|
||||
<portal id="itop-portal" _delta="define"><!-- ID must match module_design[id] -->
|
||||
<url>pages/exec.php?exec_module=itop-portal&exec_page=index.php</url><!-- exec_module must match module_design[id] -->
|
||||
<url>pages/exec.php?exec_module=itop-portal-base&exec_page=index.php&portal_id=itop-portal</url><!-- portal_id must match module_design[id] -->
|
||||
<rank>1.0</rank>
|
||||
<handler />
|
||||
<allow>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2016 Combodo SARL
|
||||
// Copyright (C) 2010-2017 Combodo SARL
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
@@ -17,6 +17,18 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
/**
|
||||
* Backward Compatibility file for default portal.
|
||||
* Needed when:
|
||||
* - PortalDispatcher uses the old url "pages/exec.php?exec_module=itop-portal&exec_page=index.php"
|
||||
* - Portal xml has no //properties/urlmaker_class tag
|
||||
* - Checks are necessary (eg. UserRequest/Incident class detection)
|
||||
*
|
||||
* NOT needed when:
|
||||
* - PortalDispatcher uses the new url "pages/exec.php?exec_module=itop-portal-base&exec_page=index.php&portal_id=itop-portal"
|
||||
* - Portal xml has a //properties/urlmaker_class tag (or doesn't need to register a UrlMakerClass)
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__ . '/../../approot.inc.php'))
|
||||
{
|
||||
require_once __DIR__ . '/../../approot.inc.php'; // When in env-xxxx folder
|
||||
@@ -33,9 +45,9 @@ if (!class_exists('UserRequest') && !class_exists('Incident'))
|
||||
die('iTop has neither been installed with User Request nor Incident tickets. Please contact your administrator.');
|
||||
}
|
||||
|
||||
// Defining portal constants
|
||||
$sDir = basename(__DIR__);
|
||||
define('PORTAL_MODULE_ID', $sDir);
|
||||
define('PORTAL_ID', $sDir);
|
||||
|
||||
ApplicationContext::SetUrlMakerClass('iTopPortalViewUrlMaker');
|
||||
require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/web/index.php';
|
||||
require_once APPROOT . '/env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/index.php';
|
||||
|
||||
@@ -994,6 +994,8 @@
|
||||
<!-- Can be either a fileref or a relative path to the file from /env-xxx (eg. itop-portal-base/mytemplate.html.twig) -->
|
||||
<!-- Available templates are id="layout|home" -->
|
||||
<templates/>
|
||||
<!-- Class used for generating objects view/edit urls (eg. in notifications) -->
|
||||
<urlmaker_class>iTopPortalViewUrlMaker</urlmaker_class>
|
||||
<!-- An OQL query to determine which TriggerOnPortalUpdate to use within THIS instance of the portal. This is mostly needed to enable different triggers on several portal instances -->
|
||||
<!-- Note : ":parent_classes" parameter is a reserved name that will be used for the current object class name (and its ancestors) -->
|
||||
<triggers_query><![CDATA[SELECT TriggerOnPortalUpdate AS t WHERE t.target_class IN (:parent_classes)]]></triggers_query>
|
||||
|
||||
Reference in New Issue
Block a user