mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
- Added support for ExternalKey, LinkedSet, linkedSetIndirect, CaseLog to the new portal
- Fixed some bugs on the customfields integration with he portal SVN:trunk[4003]
This commit is contained in:
55
sources/form/field/caselogfield.class.inc.php
Normal file
55
sources/form/field/caselogfield.class.inc.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2016 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\Form\Field;
|
||||
|
||||
use \Closure;
|
||||
use \DBObject;
|
||||
use \Combodo\iTop\Form\Field\TextAreaField;
|
||||
|
||||
/**
|
||||
* Description of CaseLogField
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
*/
|
||||
class CaseLogField extends TextAreaField
|
||||
{
|
||||
protected $aEntries;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetEntries()
|
||||
{
|
||||
return $this->aEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $aEntries
|
||||
* @return \Combodo\iTop\Form\Field\TextAreaField
|
||||
*/
|
||||
public function SetEntries($aEntries)
|
||||
{
|
||||
$this->aEntries = $aEntries;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -358,6 +358,16 @@ abstract class Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the field is editable. Meaning that it is not editable nor hidden.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsEditable()
|
||||
{
|
||||
return (!$this->bReadOnly && !$this->bHidden);
|
||||
}
|
||||
|
||||
public function OnCancel()
|
||||
{
|
||||
// Overload when needed
|
||||
|
||||
154
sources/form/field/linkedsetfield.class.inc.php
Normal file
154
sources/form/field/linkedsetfield.class.inc.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2016 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\Form\Field;
|
||||
|
||||
use \Combodo\iTop\Form\Field\Field;
|
||||
|
||||
/**
|
||||
* Description of LinkedSetField
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
*/
|
||||
class LinkedSetField extends Field
|
||||
{
|
||||
protected $sTargetClass;
|
||||
protected $sExtKeyToRemote;
|
||||
protected $bIndirect;
|
||||
protected $aAttributesToDisplay;
|
||||
protected $sSearchEndpoint;
|
||||
protected $sInformationEndpoint;
|
||||
|
||||
public function __construct($sId, \Closure $onFinalizeCallback = null)
|
||||
{
|
||||
$this->sTargetClass = null;
|
||||
$this->sExtKeyToRemote = null;
|
||||
$this->bIndirect = false;
|
||||
$this->aAttributesToDisplay = array();
|
||||
$this->sSearchEndpoint = null;
|
||||
$this->sInformationEndpoint = null;
|
||||
|
||||
parent::__construct($sId, $onFinalizeCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetTargetClass()
|
||||
{
|
||||
return $this->sTargetClass;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sTargetClass
|
||||
* @return \Combodo\iTop\Form\Field\LinkedSetField
|
||||
*/
|
||||
public function SetTargetClass($sTargetClass)
|
||||
{
|
||||
$this->sTargetClass = $sTargetClass;
|
||||
return $sTargetClass;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetExtKeyToRemote()
|
||||
{
|
||||
return $this->sExtKeyToRemote;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sExtKeyToRemote
|
||||
* @return \Combodo\iTop\Form\Field\LinkedSetField
|
||||
*/
|
||||
public function SetExtKeyToRemote($sExtKeyToRemote)
|
||||
{
|
||||
$this->sExtKeyToRemote = $sExtKeyToRemote;
|
||||
return $sExtKeyToRemote;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function IsIndirect()
|
||||
{
|
||||
return $this->bIndirect;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $bIndirect
|
||||
* @return \Combodo\iTop\Form\Field\LinkedSetField
|
||||
*/
|
||||
public function SetIndirect($bIndirect)
|
||||
{
|
||||
$this->bIndirect = $bIndirect;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash array of attributes to be displayed in the linkedset in the form $sAttCode => $sAttLabel
|
||||
*
|
||||
* @param $bAttCodesOnly If set to true, will return only the attcodes
|
||||
* @return array
|
||||
*/
|
||||
public function GetAttributesToDisplay($bAttCodesOnly = false)
|
||||
{
|
||||
return ($bAttCodesOnly) ? array_keys($this->aAttributesToDisplay) : $this->aAttributesToDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $aAttCodes
|
||||
* @return \Combodo\iTop\Form\Field\LinkedSetField
|
||||
*/
|
||||
public function SetAttributesToDisplay(array $aAttributesToDisplay)
|
||||
{
|
||||
$this->aAttributesToDisplay = $aAttributesToDisplay;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetSearchEndpoint()
|
||||
{
|
||||
return $this->sSearchEndpoint;
|
||||
}
|
||||
|
||||
public function SetSearchEndpoint($sSearchEndpoint)
|
||||
{
|
||||
$this->sSearchEndpoint = $sSearchEndpoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetInformationEndpoint()
|
||||
{
|
||||
return $this->sInformationEndpoint;
|
||||
}
|
||||
|
||||
public function SetInformationEndpoint($sInformationEndpoint)
|
||||
{
|
||||
$this->sInformationEndpoint = $sInformationEndpoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,14 +26,16 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
/**
|
||||
* Description of SelectObjectField
|
||||
*
|
||||
* @author Romain Quetiez <romain.quetiez@combodo.com>
|
||||
*/
|
||||
class SelectObjectField extends Field
|
||||
{
|
||||
protected $oSearch;
|
||||
protected $iMaximumComboLength;
|
||||
protected $iMinAutoCompleteChars;
|
||||
|
||||
protected $bHierarchical;
|
||||
protected $iControlType;
|
||||
protected $sSearchEndpoint;
|
||||
|
||||
const CONTROL_SELECT = 1;
|
||||
const CONTROL_RADIO_VERTICAL = 2;
|
||||
@@ -44,22 +46,33 @@ class SelectObjectField extends Field
|
||||
$this->oSearch = null;
|
||||
$this->iMaximumComboLength = null;
|
||||
$this->iMinAutoCompleteChars = 3;
|
||||
$this->bHierarchical = false;
|
||||
$this->iControlType = self::CONTROL_SELECT;
|
||||
$this->sSearchEndpoint = null;
|
||||
}
|
||||
|
||||
public function SetSearch(DBSearch $oSearch)
|
||||
{
|
||||
$this->oSearch = $oSearch;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetMaximumComboLength($iMaximumComboLength)
|
||||
{
|
||||
$this->iMaximumComboLength = $iMaximumComboLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetMinAutoCompleteChars($iMinAutoCompleteChars)
|
||||
{
|
||||
$this->iMinAutoCompleteChars = $iMinAutoCompleteChars;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetHierarchical($bHierarchical)
|
||||
{
|
||||
$this->bHierarchical = $bHierarchical;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetControlType($iControlType)
|
||||
@@ -67,6 +80,12 @@ class SelectObjectField extends Field
|
||||
$this->iControlType = $iControlType;
|
||||
}
|
||||
|
||||
public function SetSearchEndpoint($sSearchEndpoint)
|
||||
{
|
||||
$this->sSearchEndpoint = $sSearchEndpoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the field is mandatory or not.
|
||||
* Setting the value will automatically add/remove a MandatoryValidator to the Field
|
||||
@@ -112,8 +131,18 @@ class SelectObjectField extends Field
|
||||
return $this->iMinAutoCompleteChars;
|
||||
}
|
||||
|
||||
public function GetHierarchical()
|
||||
{
|
||||
return $this->bHierarchical;
|
||||
}
|
||||
|
||||
public function GetControlType()
|
||||
{
|
||||
return $this->iControlType;
|
||||
}
|
||||
|
||||
public function GetSearchEndpoint()
|
||||
{
|
||||
return $this->sSearchEndpoint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,49 @@ class SubFormField extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mandatory flag on all the fields on the form
|
||||
*
|
||||
* @param boolean $bMandatory
|
||||
*/
|
||||
public function SetMandatory($bMandatory)
|
||||
{
|
||||
foreach ($this->oForm->GetFields() as $oField)
|
||||
{
|
||||
$oField->SetMandatory($bMandatory);
|
||||
}
|
||||
parent::SetMandatory($bMandatory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read-only flag on all the fields on the form
|
||||
*
|
||||
* @param boolean $bReadOnly
|
||||
*/
|
||||
public function SetReadOnly($bReadOnly)
|
||||
{
|
||||
foreach ($this->oForm->GetFields() as $oField)
|
||||
{
|
||||
$oField->SetReadOnly($bReadOnly);
|
||||
$oField->SetMandatory(false);
|
||||
}
|
||||
parent::SetReadOnly($bReadOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hidden flag on all the fields on the form
|
||||
*
|
||||
* @param boolean $bHidden
|
||||
*/
|
||||
public function SetHidden($bHidden)
|
||||
{
|
||||
foreach ($this->oForm->GetFields() as $oField)
|
||||
{
|
||||
$oField->SetHidden($bHidden);
|
||||
}
|
||||
parent::SetHidden($bHidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sFormPath
|
||||
* @return Form|null
|
||||
|
||||
@@ -37,6 +37,7 @@ class Form
|
||||
protected $aDependencies;
|
||||
protected $bValid;
|
||||
protected $aErrorMessages;
|
||||
protected $iEditableFieldCount;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -51,6 +52,7 @@ class Form
|
||||
$this->aDependencies = array();
|
||||
$this->bValid = true;
|
||||
$this->aErrorMessages = array();
|
||||
$this->iEditableFieldCount = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,6 +373,39 @@ class Form
|
||||
return $aRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of editable fields in this form.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function GetEditableFieldCount($bForce = false)
|
||||
{
|
||||
// Count is usally done by the Finalize function but it can be done there if Finalize hasn't been called yet or if we choose to force it.
|
||||
if (($this->iEditableFieldCount === null) || ($bForce === true))
|
||||
{
|
||||
$this->iEditableFieldCount = 0;
|
||||
foreach ($this->aFields as $oField)
|
||||
{
|
||||
if ($oField->IsEditable())
|
||||
{
|
||||
$this->iEditableFieldCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->iEditableFieldCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the form has at least one editable field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function HasEditableFields()
|
||||
{
|
||||
return ($this->GetEditableFieldCount() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sFormPath
|
||||
* @return Form|null
|
||||
@@ -450,7 +485,11 @@ class Form
|
||||
foreach ($aFieldList as $sId => $oField)
|
||||
{
|
||||
$oField->OnFinalize();
|
||||
}
|
||||
if ($oField->IsEditable())
|
||||
{
|
||||
$this->iEditableFieldCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user