123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- // Copyright (C) 2010-2015 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/>
- /**
- * Required constants :
- * - PORTAL_MODULE_ID : Name of the portal instance module
- * - PORTAL_ID : Name of the portal instance module design (Configuration)
- */
- // Silex framework and components
- require_once APPROOT . '/lib/silex/vendor/autoload.php';
- // iTop application requirements
- //require_once __DIR__.'/../../../../approot.inc.php'; // Required by the instanciation module
- //require_once APPROOT.'/application/startup.inc.php'; // Required by the instanciation module
- require_once APPROOT . '/core/moduledesign.class.inc.php';
- require_once APPROOT . '/application/loginwebpage.class.inc.php';
- require_once APPROOT . '/sources/autoload.php';
- // Portal
- require_once __DIR__ . '/../src/providers/urlgeneratorserviceprovider.class.inc.php';
- require_once __DIR__ . '/../src/helpers/urlgeneratorhelper.class.inc.php';
- require_once __DIR__ . '/../src/providers/contextmanipulatorserviceprovider.class.inc.php';
- require_once __DIR__ . '/../src/helpers/contextmanipulatorhelper.class.inc.php';
- require_once __DIR__ . '/../src/providers/scopevalidatorserviceprovider.class.inc.php';
- require_once __DIR__ . '/../src/helpers/scopevalidatorhelper.class.inc.php';
- require_once __DIR__ . '/../src/helpers/securityhelper.class.inc.php';
- require_once __DIR__ . '/../src/helpers/applicationhelper.class.inc.php';
- use \Combodo\iTop\Portal\Helper\ApplicationHelper;
- // Checking user rights and prompt if needed
- LoginWebPage::DoLoginEx(PORTAL_ID);
- if (UserRights::GetContactId() == 0)
- {
- die(Dict::S('Portal:ErrorNoContactForThisUser'));
- }
- // Initializing Silex framework
- $oApp = new Silex\Application();
- // Registring optional silex components
- $oApp->register(new Combodo\iTop\Portal\Provider\UrlGeneratorServiceProvider());
- $oApp->register(new Combodo\iTop\Portal\Provider\ContextManipulatorServiceProvider());
- $oApp->register(new Combodo\iTop\Portal\Provider\ScopeValidatorServiceProvider(), array(
- 'scope_validator.scopes_path' => utils::GetCachePath(),
- 'scope_validator.scopes_filename' => PORTAL_ID . '.scopes.php',
- 'scope_validator.instance_name' => PORTAL_ID
- ));
- $oApp->register(new Silex\Provider\TwigServiceProvider(), array(
- 'twig.path' => APPROOT . 'env-' . utils::GetCurrentEnvironment()
- ));
- // Configuring Silex application
- $oApp['debug'] = true;
- $oApp['combodo.absolute_url'] = utils::GetAbsoluteUrlAppRoot();
- $oApp['combodo.portal.base.absolute_url'] = utils::GetAbsoluteUrlAppRoot() . 'env-' . utils::GetCurrentEnvironment() . '/itop-portal-base/portal/web/';
- $oApp['combodo.portal.instance.absolute_url'] = utils::GetAbsoluteUrlAppRoot() . 'env-' . utils::GetCurrentEnvironment() . '/' . PORTAL_MODULE_ID . '/';
- $oApp['combodo.portal.instance.id'] = PORTAL_MODULE_ID;
- $oApp['combodo.portal.instance.conf'] = array();
- $oApp['combodo.portal.instance.routes'] = array();
- // Registering error/exception handler in order to transform php error to exception
- ApplicationHelper::RegisterExceptionHandler($oApp);
- // Preparing portal foundations (Can't use Silex autoload through composer as we don't follow PSR conventions -filenames, functions-)
- ApplicationHelper::LoadControllers();
- ApplicationHelper::LoadRouters();
- ApplicationHelper::RegisterRoutes($oApp);
- ApplicationHelper::LoadBricks();
- ApplicationHelper::LoadFormManagers();
- ApplicationHelper::RegisterTwigExtensions($oApp);
- // Loading portal configuration from the module design
- ApplicationHelper::LoadPortalConfiguration($oApp);
- // Loading current user
- ApplicationHelper::LoadCurrentUser($oApp);
- // Running application
- $oApp->run();
|