Fix files using CrLf, convert them to Lf to have the whole repo using Lf

Warn your git config (core.autocrlf = input or true)
This commit is contained in:
Pierre Goiffon
2018-09-04 17:38:22 +02:00
parent cad18bee73
commit 40a4e6d7b0
378 changed files with 152833 additions and 152833 deletions

View File

@@ -1,42 +1,42 @@
<?php
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-portal-base/2.5.0', array(
// Identification
'label' => 'Portal Development Library',
'category' => 'Portal',
// Setup
'dependencies' => array(
),
'mandatory' => false,
'visible' => true,
// Components
'datamodel' => array(
'portal/src/controllers/abstractcontroller.class.inc.php',
'portal/src/controllers/brickcontroller.class.inc.php',
'portal/src/entities/abstractbrick.class.inc.php',
'portal/src/entities/portalbrick.class.inc.php',
'portal/src/routers/abstractrouter.class.inc.php',
),
'webservice' => array(
//'webservices.itop-portal-base.php',
),
'dictionary' => array(
'fr.dict.itop-portal-base.php',
//'de.dict.itop-portal-base.php',
),
'data.struct' => array(
//'data.struct.itop-portal-base.xml',
),
'data.sample' => array(
//'data.sample.itop-portal-base.xml',
),
// Documentation
'doc.manual_setup' => '',
'doc.more_information' => '',
// Default settings
'settings' => array(
),
)
);
<?php
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-portal-base/2.5.0', array(
// Identification
'label' => 'Portal Development Library',
'category' => 'Portal',
// Setup
'dependencies' => array(
),
'mandatory' => false,
'visible' => true,
// Components
'datamodel' => array(
'portal/src/controllers/abstractcontroller.class.inc.php',
'portal/src/controllers/brickcontroller.class.inc.php',
'portal/src/entities/abstractbrick.class.inc.php',
'portal/src/entities/portalbrick.class.inc.php',
'portal/src/routers/abstractrouter.class.inc.php',
),
'webservice' => array(
//'webservices.itop-portal-base.php',
),
'dictionary' => array(
'fr.dict.itop-portal-base.php',
//'de.dict.itop-portal-base.php',
),
'data.struct' => array(
//'data.struct.itop-portal-base.xml',
),
'data.sample' => array(
//'data.sample.itop-portal-base.xml',
),
// Documentation
'doc.manual_setup' => '',
'doc.more_information' => '',
// Default settings
'settings' => array(
),
)
);

View File

@@ -1,32 +1,32 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
/**
* Class AbstractController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class AbstractController
{
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
/**
* Class AbstractController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class AbstractController
{
}

View File

@@ -1,32 +1,32 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
/**
* Class BrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class BrickController extends AbstractController
{
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
/**
* Class BrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class BrickController extends AbstractController
{
}

View File

@@ -1,113 +1,113 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use MetaModel;
use Combodo\iTop\Portal\Helper\ApplicationHelper;
use Combodo\iTop\Portal\Helper\ContextManipulatorHelper;
use Combodo\iTop\Portal\Helper\SecurityHelper;
/**
* Class CreateBrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class CreateBrickController extends BrickController
{
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sBrickId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
* @throws \CoreException
* @throws \DictExceptionMissingString
*/
public function DisplayAction(Request $oRequest, Application $oApp, $sBrickId)
{
/** @var \Combodo\iTop\Portal\Brick\CreateBrick $oBrick */
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
$sObjectClass = $oBrick->GetClass();
$aRouteParams = array(
'sObjectClass' => $oBrick->GetClass()
);
// Checking for actions rules
$aRules = $oBrick->GetRules();
if (!empty($aRules))
{
$aRouteParams['ar_token'] = ContextManipulatorHelper::PrepareAndEncodeRulesToken($aRules);
}
// Checking if the target object class is asbtract or not
// - If is not abstract, we redirect to object creation form
if (!MetaModel::IsAbstract($sObjectClass))
{
// Preparing redirection route
// - Adding brick id to the params
$aRouteParams['sBrickId'] = $sBrickId;
// - Generating route
$sRedirectRoute = $oApp['url_generator']->generate('p_object_create', $aRouteParams);
// - Request
$oSubRequest = Request::create($sRedirectRoute, 'GET', $oRequest->query->all(), $oRequest->cookies->all(), array(), $oRequest->server->all());
$oResponse = $oApp->handle($oSubRequest, HttpKernelInterface::SUB_REQUEST, true);
}
// - Else, we list the leaf classes as an intermediate step
else
{
$aData = array(
'oBrick' => $oBrick,
'sBrickId' => $sBrickId,
'aLeafClasses' => array(),
'ar_token' => $aRouteParams['ar_token']
);
$aLeafClasses = array();
$aChildClasses = MetaModel::EnumChildClasses($sObjectClass);
foreach ($aChildClasses as $sChildClass)
{
if (!MetaModel::IsAbstract($sChildClass) && SecurityHelper::IsActionAllowed($oApp, UR_ACTION_CREATE, $sChildClass))
{
$aLeafClasses[] = array(
'id' => $sChildClass,
'name' => MetaModel::GetName($sChildClass)
);
}
}
$aData['aLeafClasses'] = $aLeafClasses;
$oResponse = $oApp['twig']->render($oBrick->GetPageTemplatePath(), $aData);
}
return $oResponse;
}
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use MetaModel;
use Combodo\iTop\Portal\Helper\ApplicationHelper;
use Combodo\iTop\Portal\Helper\ContextManipulatorHelper;
use Combodo\iTop\Portal\Helper\SecurityHelper;
/**
* Class CreateBrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class CreateBrickController extends BrickController
{
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sBrickId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
* @throws \CoreException
* @throws \DictExceptionMissingString
*/
public function DisplayAction(Request $oRequest, Application $oApp, $sBrickId)
{
/** @var \Combodo\iTop\Portal\Brick\CreateBrick $oBrick */
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
$sObjectClass = $oBrick->GetClass();
$aRouteParams = array(
'sObjectClass' => $oBrick->GetClass()
);
// Checking for actions rules
$aRules = $oBrick->GetRules();
if (!empty($aRules))
{
$aRouteParams['ar_token'] = ContextManipulatorHelper::PrepareAndEncodeRulesToken($aRules);
}
// Checking if the target object class is asbtract or not
// - If is not abstract, we redirect to object creation form
if (!MetaModel::IsAbstract($sObjectClass))
{
// Preparing redirection route
// - Adding brick id to the params
$aRouteParams['sBrickId'] = $sBrickId;
// - Generating route
$sRedirectRoute = $oApp['url_generator']->generate('p_object_create', $aRouteParams);
// - Request
$oSubRequest = Request::create($sRedirectRoute, 'GET', $oRequest->query->all(), $oRequest->cookies->all(), array(), $oRequest->server->all());
$oResponse = $oApp->handle($oSubRequest, HttpKernelInterface::SUB_REQUEST, true);
}
// - Else, we list the leaf classes as an intermediate step
else
{
$aData = array(
'oBrick' => $oBrick,
'sBrickId' => $sBrickId,
'aLeafClasses' => array(),
'ar_token' => $aRouteParams['ar_token']
);
$aLeafClasses = array();
$aChildClasses = MetaModel::EnumChildClasses($sObjectClass);
foreach ($aChildClasses as $sChildClass)
{
if (!MetaModel::IsAbstract($sChildClass) && SecurityHelper::IsActionAllowed($oApp, UR_ACTION_CREATE, $sChildClass))
{
$aLeafClasses[] = array(
'id' => $sChildClass,
'name' => MetaModel::GetName($sChildClass)
);
}
}
$aData['aLeafClasses'] = $aLeafClasses;
$oResponse = $oApp['twig']->render($oBrick->GetPageTemplatePath(), $aData);
}
return $oResponse;
}
}

View File

@@ -1,72 +1,72 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
/**
* Class DefaultController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class DefaultController
{
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function homeAction(Request $oRequest, Application $oApp)
{
$aData = array();
// Rendering tiles
$aData['aTilesRendering'] = array();
/** @var \Combodo\iTop\Portal\Brick\PortalBrick $oBrick */
foreach($oApp['combodo.portal.instance.conf']['bricks'] as $oBrick)
{
// Doing it only for tile visible on home page to avoid unnecessary rendering
if (($oBrick->GetVisibleHome() === true) && ($oBrick->GetTileControllerAction() !== null))
{
$aControllerActionParts = explode('::', $oBrick->GetTileControllerAction());
if (count($aControllerActionParts) !== 2)
{
$oApp->abort(500, 'Tile controller action must be of form "\Namespace\ControllerClass::FunctionName" for brick "' . $oBrick->GetId() . '"');
}
$sControllerName = $aControllerActionParts[0];
$sControllerAction = $aControllerActionParts[1];
$oController = new $sControllerName($oRequest, $oApp, $oBrick->GetId());
$aData['aTilesRendering'][$oBrick->GetId()] = $oController->$sControllerAction($oRequest, $oApp, $oBrick->GetId());
}
}
// Home page template
$template = $oApp['combodo.portal.instance.conf']['properties']['templates']['home'];
return $oApp['twig']->render($template, $aData);
}
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
/**
* Class DefaultController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class DefaultController
{
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function homeAction(Request $oRequest, Application $oApp)
{
$aData = array();
// Rendering tiles
$aData['aTilesRendering'] = array();
/** @var \Combodo\iTop\Portal\Brick\PortalBrick $oBrick */
foreach($oApp['combodo.portal.instance.conf']['bricks'] as $oBrick)
{
// Doing it only for tile visible on home page to avoid unnecessary rendering
if (($oBrick->GetVisibleHome() === true) && ($oBrick->GetTileControllerAction() !== null))
{
$aControllerActionParts = explode('::', $oBrick->GetTileControllerAction());
if (count($aControllerActionParts) !== 2)
{
$oApp->abort(500, 'Tile controller action must be of form "\Namespace\ControllerClass::FunctionName" for brick "' . $oBrick->GetId() . '"');
}
$sControllerName = $aControllerActionParts[0];
$sControllerAction = $aControllerActionParts[1];
$oController = new $sControllerName($oRequest, $oApp, $oBrick->GetId());
$aData['aTilesRendering'][$oBrick->GetId()] = $oController->$sControllerAction($oRequest, $oApp, $oBrick->GetId());
}
}
// Home page template
$template = $oApp['combodo.portal.instance.conf']['properties']['templates']['home'];
return $oApp['twig']->render($template, $aData);
}
}

View File

@@ -1,345 +1,345 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Exception;
use FileUploadException;
use IssueLog;
use utils;
use MetaModel;
use UserRights;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Combodo\iTop\Portal\Helper\ApplicationHelper;
use Combodo\iTop\Portal\Brick\UserProfileBrick;
use Combodo\iTop\Portal\Form\PreferencesFormManager;
use Combodo\iTop\Portal\Form\PasswordFormManager;
use Combodo\iTop\Renderer\Bootstrap\BsFormRenderer;
/**
* Class UserProfileBrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class UserProfileBrickController extends BrickController
{
const ENUM_FORM_TYPE_PICTURE = 'picture';
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param $sBrickId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function DisplayAction(Request $oRequest, Application $oApp, $sBrickId)
{
// If the brick id was not specified, we get the first one registered that is an instance of UserProfileBrick as default
if ($sBrickId === null)
{
foreach ($oApp['combodo.portal.instance.conf']['bricks'] as $oTmpBrick)
{
if ($oTmpBrick instanceof UserProfileBrick)
{
$oBrick = $oTmpBrick;
}
}
// We make sure a UserProfileBrick was found
if (!isset($oBrick) || $oBrick === null)
{
$oBrick = new UserProfileBrick();
//$oApp->abort(500, 'UserProfileBrick : Brick could not be loaded as there was no UserProfileBrick loaded in the application.');
}
}
else
{
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
}
$aData = array();
// Setting form mode regarding the demo mode parameter
$bDemoMode = MetaModel::GetConfig()->Get('demo_mode');
$sFormMode = ($bDemoMode) ? ObjectController::ENUM_MODE_VIEW : ObjectController::ENUM_MODE_EDIT;
// If this is ajax call, we are just submiting preferences or password forms
if ($oRequest->isXmlHttpRequest())
{
$aCurrentValues = $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW);
$sFormType = $aCurrentValues['form_type'];
if ($sFormType === PreferencesFormManager::FORM_TYPE)
{
$aData['form'] = $this->HandlePreferencesForm($oRequest, $oApp, $sFormMode);
}
elseif ($sFormType === PasswordFormManager::FORM_TYPE)
{
$aData['form'] = $this->HandlePasswordForm($oRequest, $oApp, $sFormMode);
}
elseif ($sFormType === static::ENUM_FORM_TYPE_PICTURE)
{
$aData['form'] = $this->HandlePictureForm($oRequest, $oApp);
}
else
{
throw new Exception('Unknown form type.');
}
$oResponse = $oApp->json($aData);
}
// Else, we are displaying page for first time
else
{
// Retrieving current contact
$oCurContact = UserRights::GetContactObject();
$sCurContactClass = get_class($oCurContact);
$sCurContactId = $oCurContact->GetKey();
// Preparing forms
$aData['forms']['contact'] = ObjectController::HandleForm($oRequest, $oApp, $sFormMode, $sCurContactClass, $sCurContactId, $oBrick->GetForm());
$aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $oApp, $sFormMode);
// - If user can change password, we display the form
$aData['forms']['password'] = (UserRights::CanChangePassword()) ? $this->HandlePasswordForm($oRequest, $oApp, $sFormMode) : null;
$aData = $aData + array(
'oBrick' => $oBrick,
'sFormMode' => $sFormMode,
'bDemoMode' => $bDemoMode
);
$oResponse = $oApp['twig']->render($oBrick->GetPageTemplatePath(), $aData);
}
return $oResponse;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sFormMode
*
* @return array
*
* @throws \Exception
*/
public function HandlePreferencesForm(Request $oRequest, Application $oApp, $sFormMode)
{
$aFormData = array();
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - Create
if ($sOperation === null)
{
// - Creating renderer
$oFormRenderer = new BsFormRenderer();
$oFormRenderer->SetEndpoint($_SERVER['REQUEST_URI']);
// - Creating manager
$oFormManager = new PreferencesFormManager();
$oFormManager->SetRenderer($oFormRenderer)
->Build();
// - Checking if we have to make the form read only
if ($sFormMode === ObjectController::ENUM_MODE_VIEW)
{
$oFormManager->GetForm()->MakeReadOnly();
}
}
// - Submit
else if ($sOperation === 'submit')
{
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW);
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW);
if ($sFormManagerClass === null || $sFormManagerData === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
$oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.');
}
// Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW)));
// Reloading page only if preferences were changed
if (($aFormData['validation']['valid'] === true) && !empty($aFormData['validation']['messages']['success']))
{
$aFormData['validation']['redirection'] = array(
'url' => $oApp['url_generator']->generate('p_user_profile_brick'),
);
}
}
// Else, submit from another form
// Preparing field_set data
$aFieldSetData = array(
'fields_list' => $oFormManager->GetRenderer()->Render(),
'fields_impacts' => $oFormManager->GetForm()->GetFieldsImpacts(),
'form_path' => $oFormManager->GetForm()->GetId()
);
// Preparing form data
$aFormData['id'] = $oFormManager->GetForm()->GetId();
$aFormData['formmanager_class'] = $oFormManager->GetClass();
$aFormData['formmanager_data'] = $oFormManager->ToJSON();
$aFormData['renderer'] = $oFormManager->GetRenderer();
$aFormData['fieldset'] = $aFieldSetData;
return $aFormData;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sFormMode
*
* @return array
*
* @throws \Exception
*/
public function HandlePasswordForm(Request $oRequest, Application $oApp, $sFormMode)
{
$aFormData = array();
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - Create
if ($sOperation === null)
{
// - Creating renderer
$oFormRenderer = new BsFormRenderer();
$oFormRenderer->SetEndpoint($_SERVER['REQUEST_URI']);
// - Creating manager
$oFormManager = new PasswordFormManager();
$oFormManager->SetRenderer($oFormRenderer)
->Build();
// - Checking if we have to make the form read only
if ($sFormMode === ObjectController::ENUM_MODE_VIEW)
{
$oFormManager->GetForm()->MakeReadOnly();
}
}
// - Submit
else if ($sOperation === 'submit')
{
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW);
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW);
if ($sFormManagerClass === null || $sFormManagerData === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
$oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.');
}
// Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW)));
}
// Else, submit from another form
// Preparing field_set data
$aFieldSetData = array(
'fields_list' => $oFormManager->GetRenderer()->Render(),
'fields_impacts' => $oFormManager->GetForm()->GetFieldsImpacts(),
'form_path' => $oFormManager->GetForm()->GetId()
);
// Preparing form data
$aFormData['id'] = $oFormManager->GetForm()->GetId();
$aFormData['formmanager_class'] = $oFormManager->GetClass();
$aFormData['formmanager_data'] = $oFormManager->ToJSON();
$aFormData['renderer'] = $oFormManager->GetRenderer();
$aFormData['fieldset'] = $aFieldSetData;
return $aFormData;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
*
* @return array
*
* @throws \Exception
*/
public function HandlePictureForm(Request $oRequest, Application $oApp)
{
$aFormData = array();
$sPictureAttCode = 'picture';
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - No operation specified
if ($sOperation === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Operation parameter must be specified.');
$oApp->abort(500, 'Operation parameter must be specified.');
}
// - Submit
else if ($sOperation === 'submit')
{
$oRequestFiles = $oRequest->files;
$oPictureFile = $oRequestFiles->get($sPictureAttCode);
if ($oPictureFile === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameter picture must be defined.');
$oApp->abort(500, 'Parameter picture must be defined.');
}
try
{
// Retrieving image as an ORMDocument
$oImage = utils::ReadPostedDocument($sPictureAttCode);
// Retrieving current contact
$oCurContact = UserRights::GetContactObject();
// Resizing image
$oAttDef = MetaModel::GetAttributeDef(get_class($oCurContact), $sPictureAttCode);
$aSize = utils::GetImageSize($oImage->GetData());
$oImage = utils::ResizeImageToFit($oImage, $aSize[0], $aSize[1], $oAttDef->Get('storage_max_width'), $oAttDef->Get('storage_max_height'));
// Setting it to the contact
$oCurContact->Set($sPictureAttCode, $oImage);
// Forcing allowed writing on the object if necessary.
$oCurContact->AllowWrite(true);
$oCurContact->DBUpdate();
}
catch (FileUploadException $e)
{
$aFormData['error'] = $e->GetMessage();
}
$aFormData['picture_url'] = $oImage->GetDownloadURL(get_class($oCurContact), $oCurContact->GetKey(), $sPictureAttCode);
$aFormData['validation'] = array(
'valid' => true,
'messages' => array()
);
}
// Else, submit from another form
return $aFormData;
}
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Controller;
use Exception;
use FileUploadException;
use IssueLog;
use utils;
use MetaModel;
use UserRights;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Combodo\iTop\Portal\Helper\ApplicationHelper;
use Combodo\iTop\Portal\Brick\UserProfileBrick;
use Combodo\iTop\Portal\Form\PreferencesFormManager;
use Combodo\iTop\Portal\Form\PasswordFormManager;
use Combodo\iTop\Renderer\Bootstrap\BsFormRenderer;
/**
* Class UserProfileBrickController
*
* @package Combodo\iTop\Portal\Controller
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class UserProfileBrickController extends BrickController
{
const ENUM_FORM_TYPE_PICTURE = 'picture';
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param $sBrickId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function DisplayAction(Request $oRequest, Application $oApp, $sBrickId)
{
// If the brick id was not specified, we get the first one registered that is an instance of UserProfileBrick as default
if ($sBrickId === null)
{
foreach ($oApp['combodo.portal.instance.conf']['bricks'] as $oTmpBrick)
{
if ($oTmpBrick instanceof UserProfileBrick)
{
$oBrick = $oTmpBrick;
}
}
// We make sure a UserProfileBrick was found
if (!isset($oBrick) || $oBrick === null)
{
$oBrick = new UserProfileBrick();
//$oApp->abort(500, 'UserProfileBrick : Brick could not be loaded as there was no UserProfileBrick loaded in the application.');
}
}
else
{
$oBrick = ApplicationHelper::GetLoadedBrickFromId($oApp, $sBrickId);
}
$aData = array();
// Setting form mode regarding the demo mode parameter
$bDemoMode = MetaModel::GetConfig()->Get('demo_mode');
$sFormMode = ($bDemoMode) ? ObjectController::ENUM_MODE_VIEW : ObjectController::ENUM_MODE_EDIT;
// If this is ajax call, we are just submiting preferences or password forms
if ($oRequest->isXmlHttpRequest())
{
$aCurrentValues = $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW);
$sFormType = $aCurrentValues['form_type'];
if ($sFormType === PreferencesFormManager::FORM_TYPE)
{
$aData['form'] = $this->HandlePreferencesForm($oRequest, $oApp, $sFormMode);
}
elseif ($sFormType === PasswordFormManager::FORM_TYPE)
{
$aData['form'] = $this->HandlePasswordForm($oRequest, $oApp, $sFormMode);
}
elseif ($sFormType === static::ENUM_FORM_TYPE_PICTURE)
{
$aData['form'] = $this->HandlePictureForm($oRequest, $oApp);
}
else
{
throw new Exception('Unknown form type.');
}
$oResponse = $oApp->json($aData);
}
// Else, we are displaying page for first time
else
{
// Retrieving current contact
$oCurContact = UserRights::GetContactObject();
$sCurContactClass = get_class($oCurContact);
$sCurContactId = $oCurContact->GetKey();
// Preparing forms
$aData['forms']['contact'] = ObjectController::HandleForm($oRequest, $oApp, $sFormMode, $sCurContactClass, $sCurContactId, $oBrick->GetForm());
$aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $oApp, $sFormMode);
// - If user can change password, we display the form
$aData['forms']['password'] = (UserRights::CanChangePassword()) ? $this->HandlePasswordForm($oRequest, $oApp, $sFormMode) : null;
$aData = $aData + array(
'oBrick' => $oBrick,
'sFormMode' => $sFormMode,
'bDemoMode' => $bDemoMode
);
$oResponse = $oApp['twig']->render($oBrick->GetPageTemplatePath(), $aData);
}
return $oResponse;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sFormMode
*
* @return array
*
* @throws \Exception
*/
public function HandlePreferencesForm(Request $oRequest, Application $oApp, $sFormMode)
{
$aFormData = array();
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - Create
if ($sOperation === null)
{
// - Creating renderer
$oFormRenderer = new BsFormRenderer();
$oFormRenderer->SetEndpoint($_SERVER['REQUEST_URI']);
// - Creating manager
$oFormManager = new PreferencesFormManager();
$oFormManager->SetRenderer($oFormRenderer)
->Build();
// - Checking if we have to make the form read only
if ($sFormMode === ObjectController::ENUM_MODE_VIEW)
{
$oFormManager->GetForm()->MakeReadOnly();
}
}
// - Submit
else if ($sOperation === 'submit')
{
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW);
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW);
if ($sFormManagerClass === null || $sFormManagerData === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
$oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.');
}
// Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW)));
// Reloading page only if preferences were changed
if (($aFormData['validation']['valid'] === true) && !empty($aFormData['validation']['messages']['success']))
{
$aFormData['validation']['redirection'] = array(
'url' => $oApp['url_generator']->generate('p_user_profile_brick'),
);
}
}
// Else, submit from another form
// Preparing field_set data
$aFieldSetData = array(
'fields_list' => $oFormManager->GetRenderer()->Render(),
'fields_impacts' => $oFormManager->GetForm()->GetFieldsImpacts(),
'form_path' => $oFormManager->GetForm()->GetId()
);
// Preparing form data
$aFormData['id'] = $oFormManager->GetForm()->GetId();
$aFormData['formmanager_class'] = $oFormManager->GetClass();
$aFormData['formmanager_data'] = $oFormManager->ToJSON();
$aFormData['renderer'] = $oFormManager->GetRenderer();
$aFormData['fieldset'] = $aFieldSetData;
return $aFormData;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
* @param string $sFormMode
*
* @return array
*
* @throws \Exception
*/
public function HandlePasswordForm(Request $oRequest, Application $oApp, $sFormMode)
{
$aFormData = array();
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - Create
if ($sOperation === null)
{
// - Creating renderer
$oFormRenderer = new BsFormRenderer();
$oFormRenderer->SetEndpoint($_SERVER['REQUEST_URI']);
// - Creating manager
$oFormManager = new PasswordFormManager();
$oFormManager->SetRenderer($oFormRenderer)
->Build();
// - Checking if we have to make the form read only
if ($sFormMode === ObjectController::ENUM_MODE_VIEW)
{
$oFormManager->GetForm()->MakeReadOnly();
}
}
// - Submit
else if ($sOperation === 'submit')
{
$sFormManagerClass = $oApp['request_manipulator']->ReadParam('formmanager_class', null, FILTER_UNSAFE_RAW);
$sFormManagerData = $oApp['request_manipulator']->ReadParam('formmanager_data', null, FILTER_UNSAFE_RAW);
if ($sFormManagerClass === null || $sFormManagerData === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameters formmanager_class and formamanager_data must be defined.');
$oApp->abort(500, 'Parameters formmanager_class and formmanager_data must be defined.');
}
// Rebuilding manager from json
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
// Applying modification to object
$aFormData['validation'] = $oFormManager->OnSubmit(array('currentValues' => $oApp['request_manipulator']->ReadParam('current_values', array(), FILTER_UNSAFE_RAW)));
}
// Else, submit from another form
// Preparing field_set data
$aFieldSetData = array(
'fields_list' => $oFormManager->GetRenderer()->Render(),
'fields_impacts' => $oFormManager->GetForm()->GetFieldsImpacts(),
'form_path' => $oFormManager->GetForm()->GetId()
);
// Preparing form data
$aFormData['id'] = $oFormManager->GetForm()->GetId();
$aFormData['formmanager_class'] = $oFormManager->GetClass();
$aFormData['formmanager_data'] = $oFormManager->ToJSON();
$aFormData['renderer'] = $oFormManager->GetRenderer();
$aFormData['fieldset'] = $aFieldSetData;
return $aFormData;
}
/**
* @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param \Silex\Application $oApp
*
* @return array
*
* @throws \Exception
*/
public function HandlePictureForm(Request $oRequest, Application $oApp)
{
$aFormData = array();
$sPictureAttCode = 'picture';
// Handling form
$sOperation = $oApp['request_manipulator']->ReadParam('operation', null);
// - No operation specified
if ($sOperation === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Operation parameter must be specified.');
$oApp->abort(500, 'Operation parameter must be specified.');
}
// - Submit
else if ($sOperation === 'submit')
{
$oRequestFiles = $oRequest->files;
$oPictureFile = $oRequestFiles->get($sPictureAttCode);
if ($oPictureFile === null)
{
IssueLog::Error(__METHOD__ . ' at line ' . __LINE__ . ' : Parameter picture must be defined.');
$oApp->abort(500, 'Parameter picture must be defined.');
}
try
{
// Retrieving image as an ORMDocument
$oImage = utils::ReadPostedDocument($sPictureAttCode);
// Retrieving current contact
$oCurContact = UserRights::GetContactObject();
// Resizing image
$oAttDef = MetaModel::GetAttributeDef(get_class($oCurContact), $sPictureAttCode);
$aSize = utils::GetImageSize($oImage->GetData());
$oImage = utils::ResizeImageToFit($oImage, $aSize[0], $aSize[1], $oAttDef->Get('storage_max_width'), $oAttDef->Get('storage_max_height'));
// Setting it to the contact
$oCurContact->Set($sPictureAttCode, $oImage);
// Forcing allowed writing on the object if necessary.
$oCurContact->AllowWrite(true);
$oCurContact->DBUpdate();
}
catch (FileUploadException $e)
{
$aFormData['error'] = $e->GetMessage();
}
$aFormData['picture_url'] = $oImage->GetDownloadURL(get_class($oCurContact), $oCurContact->GetKey(), $sPictureAttCode);
$aFormData['validation'] = array(
'valid' => true,
'messages' => array()
);
}
// Else, submit from another form
return $aFormData;
}
}

View File

@@ -1,140 +1,140 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
use Silex\Application;
/**
* AbstractRouter class is where URLs are defined with their callback, parameters and constraints (assertions).
* It allows us to have URL pattern at one place only and to generate them anywhere in the code, avoiding to maintain URLs in multiple places.
*
* @package \Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class AbstractRouter
{
/**
* List of routes for that Router.
*
* Each route is defined as an associative array and can have the following parameters :
* - pattern : URL pattern with its parameters names (eg: '/{sBrickId}/browse/{sBrowseMode}')
* - hash : String to append to the URL with an '#' (eg: 'modal-popup' will append '#modal-popup' to the above URL)
* - callback : Function to be called for that route, usally in a Controller. (eg: 'Combodo\\iTop\\Portal\\Controller\\CreateBrickController::DisplayAction')
* - bind : Unique name of the route, must not contain blanks. Usually lowercase with underscore (eg: 'p_browse_brick')
* - asserts : Associative array of assertions to check for the pattern parameters (eg: array( 'sBrowseMode' => 'list|tree'))
* - values : Associative array of default values for the pattern parameters (eg: array('sBrowseMode' => 'tree'))
*
* @var array
*/
static $aRoutes = array();
/**
* Returns routes of the current AbstractRouter defined in $aRoutes.
*
* @return array
*/
static function GetRoutes()
{
return static::$aRoutes;
}
/**
* Returns the route named $name of the current AbstractRouter.
* Throws an exception if not found.
*
* @param string $name
*
* @return array
*
* @throws \Exception
*/
static function GetRoute($name)
{
$bFound = false;
$aFoundRoute = array();
foreach (static::$aRoutes as $aRoute)
{
if (isset($aRoute['bind']) && $aRoute['bind'] === $name)
{
$bFound = true;
$aFoundRoute = $aRoute;
break;
}
}
if (!$bFound)
{
throw new \Exception('Unknown route "' . $name . '" for ' . get_class() . '');
}
return $aFoundRoute;
}
/**
* Registers all routes of the current AbstractRouter to the Application $oApp.
*
* @param Application $oApp
* @return int Number of succesfully registered routes
* @throws \Exception
*/
static function RegisterAllRoutes(Application $oApp)
{
$iCounter = 0;
foreach (static::$aRoutes as $aRoute)
{
// Check if we have the base parameters to register the route
if (!isset($aRoute['pattern']) || !isset($aRoute['callback']))
{
throw new \Exception('Unable to register routes from ' . get_class() . ', some parameters are missing.');
}
// Registering base route
$controller = $oApp->match($aRoute['pattern'], $aRoute['callback']);
// Checking if route has optionnal parameters
if (isset($aRoute['bind']))
{
$controller->bind($aRoute['bind']);
}
if (isset($aRoute['asserts']))
{
foreach ($aRoute['asserts'] as $sKey => $sValue)
{
$controller->assert($sKey, $sValue);
}
}
if (isset($aRoute['values']))
{
foreach ($aRoute['values'] as $sKey => $sValue)
{
$controller->value($sKey, $sValue);
}
}
$iCounter++;
}
return $iCounter;
}
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
use Silex\Application;
/**
* AbstractRouter class is where URLs are defined with their callback, parameters and constraints (assertions).
* It allows us to have URL pattern at one place only and to generate them anywhere in the code, avoiding to maintain URLs in multiple places.
*
* @package \Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
abstract class AbstractRouter
{
/**
* List of routes for that Router.
*
* Each route is defined as an associative array and can have the following parameters :
* - pattern : URL pattern with its parameters names (eg: '/{sBrickId}/browse/{sBrowseMode}')
* - hash : String to append to the URL with an '#' (eg: 'modal-popup' will append '#modal-popup' to the above URL)
* - callback : Function to be called for that route, usally in a Controller. (eg: 'Combodo\\iTop\\Portal\\Controller\\CreateBrickController::DisplayAction')
* - bind : Unique name of the route, must not contain blanks. Usually lowercase with underscore (eg: 'p_browse_brick')
* - asserts : Associative array of assertions to check for the pattern parameters (eg: array( 'sBrowseMode' => 'list|tree'))
* - values : Associative array of default values for the pattern parameters (eg: array('sBrowseMode' => 'tree'))
*
* @var array
*/
static $aRoutes = array();
/**
* Returns routes of the current AbstractRouter defined in $aRoutes.
*
* @return array
*/
static function GetRoutes()
{
return static::$aRoutes;
}
/**
* Returns the route named $name of the current AbstractRouter.
* Throws an exception if not found.
*
* @param string $name
*
* @return array
*
* @throws \Exception
*/
static function GetRoute($name)
{
$bFound = false;
$aFoundRoute = array();
foreach (static::$aRoutes as $aRoute)
{
if (isset($aRoute['bind']) && $aRoute['bind'] === $name)
{
$bFound = true;
$aFoundRoute = $aRoute;
break;
}
}
if (!$bFound)
{
throw new \Exception('Unknown route "' . $name . '" for ' . get_class() . '');
}
return $aFoundRoute;
}
/**
* Registers all routes of the current AbstractRouter to the Application $oApp.
*
* @param Application $oApp
* @return int Number of succesfully registered routes
* @throws \Exception
*/
static function RegisterAllRoutes(Application $oApp)
{
$iCounter = 0;
foreach (static::$aRoutes as $aRoute)
{
// Check if we have the base parameters to register the route
if (!isset($aRoute['pattern']) || !isset($aRoute['callback']))
{
throw new \Exception('Unable to register routes from ' . get_class() . ', some parameters are missing.');
}
// Registering base route
$controller = $oApp->match($aRoute['pattern'], $aRoute['callback']);
// Checking if route has optionnal parameters
if (isset($aRoute['bind']))
{
$controller->bind($aRoute['bind']);
}
if (isset($aRoute['asserts']))
{
foreach ($aRoute['asserts'] as $sKey => $sValue)
{
$controller->assert($sKey, $sValue);
}
}
if (isset($aRoute['values']))
{
foreach ($aRoute['values'] as $sKey => $sValue)
{
$controller->value($sKey, $sValue);
}
}
$iCounter++;
}
return $iCounter;
}
}

View File

@@ -1,70 +1,70 @@
<?php
// Copyright (C) 2010-2018 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 havze received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
namespace Combodo\iTop\Portal\Router;
/**
* Class BrowseBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class BrowseBrickRouter extends AbstractRouter
{
static $aRoutes = array(
// We don't set asserts for sBrowseMode on that route, as it the generic one, it can be extended by another brick.
array('pattern' => '/browse/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick'
),
array('pattern' => '/browse/{sBrickId}/{sBrowseMode}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode'
),
array('pattern' => '/browse/{sBrickId}/list/page/{iPageNumber}/show/{iListLength}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode_list',
'asserts' => array(
'sBrowseMode' => 'list',
'iPageNumber' => '\d+',
'iListLength' => '\d+'
),
'values' => array(
'sBrowseMode' => 'list',
'sDataLoading' => 'lazy',
'iPageNumber' => '1',
'iListLength' => '20'
)
),
array('pattern' => '/browse/{sBrickId}/tree/expand/{sLevelAlias}/{sNodeId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode_tree',
'asserts' => array(
'sBrowseMode' => 'tree'
),
'values' => array(
'sBrowseMode' => 'tree',
'sDataLoading' => 'lazy',
'sNodeId' => null
)
),
);
}
<?php
// Copyright (C) 2010-2018 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 havze received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
namespace Combodo\iTop\Portal\Router;
/**
* Class BrowseBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class BrowseBrickRouter extends AbstractRouter
{
static $aRoutes = array(
// We don't set asserts for sBrowseMode on that route, as it the generic one, it can be extended by another brick.
array('pattern' => '/browse/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick'
),
array('pattern' => '/browse/{sBrickId}/{sBrowseMode}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode'
),
array('pattern' => '/browse/{sBrickId}/list/page/{iPageNumber}/show/{iListLength}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode_list',
'asserts' => array(
'sBrowseMode' => 'list',
'iPageNumber' => '\d+',
'iListLength' => '\d+'
),
'values' => array(
'sBrowseMode' => 'list',
'sDataLoading' => 'lazy',
'iPageNumber' => '1',
'iListLength' => '20'
)
),
array('pattern' => '/browse/{sBrickId}/tree/expand/{sLevelAlias}/{sNodeId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\BrowseBrickController::DisplayAction',
'bind' => 'p_browse_brick_mode_tree',
'asserts' => array(
'sBrowseMode' => 'tree'
),
'values' => array(
'sBrowseMode' => 'tree',
'sDataLoading' => 'lazy',
'sNodeId' => null
)
),
);
}

View File

@@ -1,37 +1,37 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class CreateBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class CreateBrickRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/create/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\CreateBrickController::DisplayAction',
'bind' => 'p_create_brick')
);
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class CreateBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class CreateBrickRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/create/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\CreateBrickController::DisplayAction',
'bind' => 'p_create_brick')
);
}

View File

@@ -1,44 +1,44 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class DefaultRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class DefaultRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\DefaultController::homeAction',
'bind' => 'p_home'),
// // Example route
// array('pattern' => '/url-pattern',
// 'hash' => 'string-to-be-append-to-the-pattern-after-a-#',
// 'navigation_menu_attr' => array('id' => 'link_id', 'rel' => 'foo'),
// 'callback' => 'Combodo\\iTop\\Portal\\Controller\\DefaultController::exampleAction',
// 'bind' => 'p_example')
);
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class DefaultRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class DefaultRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\DefaultController::homeAction',
'bind' => 'p_home'),
// // Example route
// array('pattern' => '/url-pattern',
// 'hash' => 'string-to-be-append-to-the-pattern-after-a-#',
// 'navigation_menu_attr' => array('id' => 'link_id', 'rel' => 'foo'),
// 'callback' => 'Combodo\\iTop\\Portal\\Controller\\DefaultController::exampleAction',
// 'bind' => 'p_example')
);
}

View File

@@ -1,77 +1,77 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class ManageBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @author Pierre Goiffon <pierre.goiffon@combodo.com>
* @author Eric Espie <eric.espie@combodo.com>
* @since 2.3.0
*/
class ManageBrickRouter extends AbstractRouter
{
static $aRoutes = array(
array(
'pattern' => '/manage/{sBrickId}/{sGroupingTab}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick',
'asserts' => array(),
'values' => array(
'sGroupingTab' => null,
)
),
array(
'pattern' => '/manage/{sBrickId}/display-as/{sDisplayMode}/{sGroupingTab}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick_display_as',
'asserts' => array(
'sDisplayMode' => 'list|pie-chart|bar-chart'
),
'values' => array(
'sGroupingTab' => null,
)
),
array(
'pattern' => '/manage/{sBrickId}/{sGroupingTab}/{sGroupingArea}/page/{iPageNumber}/show/{iListLength}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick_lazy',
'asserts' => array(
'iPageNumber' => '\d+',
'iListLength' => '\d+',
),
'values' => array(
'sDataLoading' => 'lazy',
'iPageNumber' => '1',
'iListLength' => '20',
)
),
array(
'pattern' => '/manage/export/excel/start/{sBrickId}/{sGroupingTab}/{sGroupingArea}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::ExcelExportStartAction',
'bind' => 'p_manage_brick_excel_export_start',
'asserts' => array(),
'values' => array(),
),
);
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class ManageBrickRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @author Pierre Goiffon <pierre.goiffon@combodo.com>
* @author Eric Espie <eric.espie@combodo.com>
* @since 2.3.0
*/
class ManageBrickRouter extends AbstractRouter
{
static $aRoutes = array(
array(
'pattern' => '/manage/{sBrickId}/{sGroupingTab}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick',
'asserts' => array(),
'values' => array(
'sGroupingTab' => null,
)
),
array(
'pattern' => '/manage/{sBrickId}/display-as/{sDisplayMode}/{sGroupingTab}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick_display_as',
'asserts' => array(
'sDisplayMode' => 'list|pie-chart|bar-chart'
),
'values' => array(
'sGroupingTab' => null,
)
),
array(
'pattern' => '/manage/{sBrickId}/{sGroupingTab}/{sGroupingArea}/page/{iPageNumber}/show/{iListLength}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::DisplayAction',
'bind' => 'p_manage_brick_lazy',
'asserts' => array(
'iPageNumber' => '\d+',
'iListLength' => '\d+',
),
'values' => array(
'sDataLoading' => 'lazy',
'iPageNumber' => '1',
'iListLength' => '20',
)
),
array(
'pattern' => '/manage/export/excel/start/{sBrickId}/{sGroupingTab}/{sGroupingArea}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ManageBrickController::ExcelExportStartAction',
'bind' => 'p_manage_brick_excel_export_start',
'asserts' => array(),
'values' => array(),
),
);
}

View File

@@ -1,120 +1,120 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class ObjectRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class ObjectRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/object/create/{sObjectClass}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::CreateAction',
'bind' => 'p_object_create'
),
array('pattern' => '/object/create-from-factory/{sObjectClass}/{sObjectId}/{sEncodedMethodName}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::CreateFromFactoryAction',
'bind' => 'p_object_create_from_factory'
),
array('pattern' => '/object/edit/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::EditAction',
'bind' => 'p_object_edit'
),
array('pattern' => '/object/view/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::ViewAction',
'bind' => 'p_object_view'
),
array('pattern' => '/object/apply-stimulus/{sStimulusCode}/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::ApplyStimulusAction',
'bind' => 'p_object_apply_stimulus'
),
array('pattern' => '/object/search',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchRegularAction',
'bind' => 'p_object_search_regular'
),
array('pattern' => '/object/search/from-attribute/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchFromAttributeAction',
'bind' => 'p_object_search_from_attribute',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/autocomplete/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchAutocompleteAction',
'bind' => 'p_object_search_autocomplete',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/hierarchy/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchHierarchyAction',
'bind' => 'p_object_search_hierarchy',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/{sMode}/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchAction',
'bind' => 'p_object_search_generic',
'values' => array(
'sMode' => '-sMode-',
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/get-informations/json',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::GetInformationsAsJsonAction',
'bind' => 'p_object_get_informations_json',
),
array('pattern' => '/object/document/display/{sObjectClass}/{sObjectId}/{sObjectField}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::DocumentAction',
'bind' => 'p_object_document_display',
'values' => array(
'sOperation' => 'display'
)
),
array('pattern' => '/object/document/download/{sObjectClass}/{sObjectId}/{sObjectField}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::DocumentAction',
'bind' => 'p_object_document_download',
'values' => array(
'sOperation' => 'download'
)
),
array('pattern' => '/object/attachment/add',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::AttachmentAction',
'bind' => 'p_object_attachment_add'
),
array('pattern' => '/object/attachment/download/{sAttachmentId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::AttachmentAction',
'bind' => 'p_object_attachment_download',
'values' => array(
'sOperation' => 'download'
)
),
);
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class ObjectRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class ObjectRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/object/create/{sObjectClass}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::CreateAction',
'bind' => 'p_object_create'
),
array('pattern' => '/object/create-from-factory/{sObjectClass}/{sObjectId}/{sEncodedMethodName}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::CreateFromFactoryAction',
'bind' => 'p_object_create_from_factory'
),
array('pattern' => '/object/edit/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::EditAction',
'bind' => 'p_object_edit'
),
array('pattern' => '/object/view/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::ViewAction',
'bind' => 'p_object_view'
),
array('pattern' => '/object/apply-stimulus/{sStimulusCode}/{sObjectClass}/{sObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::ApplyStimulusAction',
'bind' => 'p_object_apply_stimulus'
),
array('pattern' => '/object/search',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchRegularAction',
'bind' => 'p_object_search_regular'
),
array('pattern' => '/object/search/from-attribute/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchFromAttributeAction',
'bind' => 'p_object_search_from_attribute',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/autocomplete/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchAutocompleteAction',
'bind' => 'p_object_search_autocomplete',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/hierarchy/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchHierarchyAction',
'bind' => 'p_object_search_hierarchy',
'values' => array(
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/search/{sMode}/{sTargetAttCode}/{sHostObjectClass}/{sHostObjectId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::SearchAction',
'bind' => 'p_object_search_generic',
'values' => array(
'sMode' => '-sMode-',
'sHostObjectClass' => null,
'sHostObjectId' => null
)
),
array('pattern' => '/object/get-informations/json',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::GetInformationsAsJsonAction',
'bind' => 'p_object_get_informations_json',
),
array('pattern' => '/object/document/display/{sObjectClass}/{sObjectId}/{sObjectField}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::DocumentAction',
'bind' => 'p_object_document_display',
'values' => array(
'sOperation' => 'display'
)
),
array('pattern' => '/object/document/download/{sObjectClass}/{sObjectId}/{sObjectField}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::DocumentAction',
'bind' => 'p_object_document_download',
'values' => array(
'sOperation' => 'download'
)
),
array('pattern' => '/object/attachment/add',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::AttachmentAction',
'bind' => 'p_object_attachment_add'
),
array('pattern' => '/object/attachment/download/{sAttachmentId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\ObjectController::AttachmentAction',
'bind' => 'p_object_attachment_download',
'values' => array(
'sOperation' => 'download'
)
),
);
}

View File

@@ -1,41 +1,41 @@
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class UserProfileRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class UserProfileRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/user/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\UserProfileBrickController::DisplayAction',
'bind' => 'p_user_profile_brick',
'values' => array(
'sBrickId' => null
)
)
);
}
<?php
// Copyright (C) 2010-2018 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/>
namespace Combodo\iTop\Portal\Router;
/**
* Class UserProfileRouter
*
* @package Combodo\iTop\Portal\Router
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 2.3.0
*/
class UserProfileRouter extends AbstractRouter
{
static $aRoutes = array(
array('pattern' => '/user/{sBrickId}',
'callback' => 'Combodo\\iTop\\Portal\\Controller\\UserProfileBrickController::DisplayAction',
'bind' => 'p_user_profile_brick',
'values' => array(
'sBrickId' => null
)
)
);
}

View File

@@ -1,83 +1,83 @@
/**
* Tree List Filter jQuery plugin 1.0
*
* Copyright (c) 2014, AIWSolutions
* License: GPL2
* Project Website: http://wiki.aiwsolutions.net/dOQKO
**/
jQuery.fn.treeListFilter = function(list, timeout, callback) {
var list = jQuery(list);
var input = this;
var keyTimeout;
var lastFilter = '';
// Default timeout
if (timeout === undefined) {
timeout = 200;
}
// Default callback
if (callback === undefined) {
callback = function(){ return null; };
}
function filterList(ulObject, filterValue) {
if (!ulObject.is('ul') && !ulObject.is('ol')) {
return false;
}
var children = ulObject.children();
var result = false;
for (var i = 0; i < children.length; i++) {
var liObject = jQuery(children[i]);
if(liObject.is('li')) {
var display = false;
if (liObject.children().length > 0) {
for (var j = 0; j < liObject.children().length; j++) {
var subDisplay = filterList(jQuery(liObject.children()[j]), filterValue);
display = display || subDisplay;
}
}
if (!display) {
// Modified the search so it looks for each parts of the search and not the entire sentance
// Modified the text to remove accents (latinise())
var text = liObject.find('.tree-item-wrapper').text();
var textLC = text.toLowerCase().latinise();
var filterValues = filterValue.split(' ');
var display = true;
for(var k in filterValues)
{
if(textLC.indexOf(filterValues[k]) < 0)
{
display = false;
break;
}
}
}
liObject.css('display', display ? '' : 'none');
result = result || display;
}
}
return result;
}
input.on('change', function(event) {
// Modified the search t remove accents (latinise())
var filter = input.val().toLowerCase().trim().latinise();
//var startTime = new Date().getTime();
filterList(list, filter);
//var endTime = new Date().getTime();
//console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + 'ms');
callback();
return false;
}).keydown(function() {
clearTimeout(keyTimeout);
keyTimeout = setTimeout(function() {
if( input.val() === lastFilter ) return;
lastFilter = input.val();
input.change();
}, timeout);
});
return this;
}
/**
* Tree List Filter jQuery plugin 1.0
*
* Copyright (c) 2014, AIWSolutions
* License: GPL2
* Project Website: http://wiki.aiwsolutions.net/dOQKO
**/
jQuery.fn.treeListFilter = function(list, timeout, callback) {
var list = jQuery(list);
var input = this;
var keyTimeout;
var lastFilter = '';
// Default timeout
if (timeout === undefined) {
timeout = 200;
}
// Default callback
if (callback === undefined) {
callback = function(){ return null; };
}
function filterList(ulObject, filterValue) {
if (!ulObject.is('ul') && !ulObject.is('ol')) {
return false;
}
var children = ulObject.children();
var result = false;
for (var i = 0; i < children.length; i++) {
var liObject = jQuery(children[i]);
if(liObject.is('li')) {
var display = false;
if (liObject.children().length > 0) {
for (var j = 0; j < liObject.children().length; j++) {
var subDisplay = filterList(jQuery(liObject.children()[j]), filterValue);
display = display || subDisplay;
}
}
if (!display) {
// Modified the search so it looks for each parts of the search and not the entire sentance
// Modified the text to remove accents (latinise())
var text = liObject.find('.tree-item-wrapper').text();
var textLC = text.toLowerCase().latinise();
var filterValues = filterValue.split(' ');
var display = true;
for(var k in filterValues)
{
if(textLC.indexOf(filterValues[k]) < 0)
{
display = false;
break;
}
}
}
liObject.css('display', display ? '' : 'none');
result = result || display;
}
}
return result;
}
input.on('change', function(event) {
// Modified the search t remove accents (latinise())
var filter = input.val().toLowerCase().trim().latinise();
//var startTime = new Date().getTime();
filterList(list, filter);
//var endTime = new Date().getTime();
//console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + 'ms');
callback();
return false;
}).keydown(function() {
clearTimeout(keyTimeout);
keyTimeout = setTimeout(function() {
if( input.val() === lastFilter ) return;
lastFilter = input.val();
input.change();
}, timeout);
});
return this;
}