mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,7 +17,7 @@ use ValueSetEnum;
|
||||
*/
|
||||
class AttributeApplicationLanguage extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class AttributeApplicationLanguage extends AttributeString
|
||||
{
|
||||
$this->m_sCode = $sCode;
|
||||
$aAvailableLanguages = Dict::GetLanguages();
|
||||
$aLanguageCodes = array();
|
||||
$aLanguageCodes = [];
|
||||
foreach ($aAvailableLanguages as $sLangCode => $aInfo) {
|
||||
$aLanguageCodes[$sLangCode] = $aInfo['description'].' ('.$aInfo['localized_description'].')';
|
||||
}
|
||||
@@ -50,4 +51,4 @@ class AttributeApplicationLanguage extends AttributeString
|
||||
{
|
||||
return '=';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -41,4 +42,4 @@ class AttributeArchiveDate extends AttributeDate
|
||||
|
||||
return parent::GetDescription($sDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -12,13 +13,13 @@ class AttributeArchiveFlag extends AttributeBoolean
|
||||
{
|
||||
public function __construct($sCode)
|
||||
{
|
||||
parent::__construct($sCode, array(
|
||||
parent::__construct($sCode, [
|
||||
"allowed_values" => null,
|
||||
"sql" => $sCode,
|
||||
"default_value" => false,
|
||||
"is_null_allowed" => false,
|
||||
"depends_on" => array(),
|
||||
));
|
||||
"depends_on" => [],
|
||||
]);
|
||||
}
|
||||
|
||||
public function RequiresIndex()
|
||||
@@ -54,4 +55,4 @@ class AttributeArchiveFlag extends AttributeBoolean
|
||||
|
||||
return parent::GetDescription($sDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -22,7 +23,7 @@ use utils;
|
||||
*/
|
||||
class AttributeBlob extends AttributeDefinition
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -43,7 +44,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("depends_on"));
|
||||
return array_merge(parent::ListExpectedParams(), ["depends_on"]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -101,8 +102,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
try {
|
||||
// Read the file from iTop, an URL (or the local file system - for admins only)
|
||||
$proposedValue = utils::FileGetContentsAndMIMEType($proposedValue);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
IssueLog::Warning(get_class($this)."::MakeRealValue - ".$e->getMessage());
|
||||
// Not a real document !! store is as text !!! (This was the default behavior before)
|
||||
$proposedValue = new ormDocument($e->getMessage()." \n".$proposedValue, 'text/plain');
|
||||
@@ -117,7 +117,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
if ($sPrefix == '') {
|
||||
$sPrefix = $this->GetCode();
|
||||
}
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $sPrefix.'_mimetype';
|
||||
$aColumns['_data'] = $sPrefix.'_data';
|
||||
@@ -167,7 +167,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
// We will have to remove the blobs from the list of attributes when doing the select
|
||||
// then the use of Get() should finalize the load
|
||||
if ($value instanceof ormDocument) {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
if (!$value->IsEmpty()) {
|
||||
$aValues[$this->GetCode().'_data'] = $value->GetData();
|
||||
} else {
|
||||
@@ -177,7 +177,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
$aValues[$this->GetCode().'_filename'] = $value->GetFileName();
|
||||
$aValues[$this->GetCode().'_downloads_count'] = $value->GetDownloadsCount();
|
||||
} else {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode().'_data'] = '';
|
||||
$aValues[$this->GetCode().'_mimetype'] = '';
|
||||
$aValues[$this->GetCode().'_filename'] = '';
|
||||
@@ -189,7 +189,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode().'_data'] = 'LONGBLOB'; // 2^32 (4 Gb)
|
||||
$aColumns[$this->GetCode().'_mimetype'] = 'VARCHAR(255)'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
$aColumns[$this->GetCode().'_filename'] = 'VARCHAR(255)'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
@@ -200,7 +200,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -233,10 +233,13 @@ class AttributeBlob extends AttributeDefinition
|
||||
* @return string
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
$sAttCode = $this->GetCode();
|
||||
if ($sValue instanceof ormDocument && !$sValue->IsEmpty()) {
|
||||
return $sValue->GetDownloadURL(get_class($oHostObject), $oHostObject->GetKey(), $sAttCode);
|
||||
@@ -271,7 +274,7 @@ class AttributeBlob extends AttributeDefinition
|
||||
public function GetForJSON($value)
|
||||
{
|
||||
if ($value instanceof ormDocument) {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues['data'] = base64_encode($value->GetData());
|
||||
$aValues['mimetype'] = $value->GetMimeType();
|
||||
$aValues['filename'] = $value->GetFileName();
|
||||
@@ -383,4 +386,4 @@ class AttributeBlob extends AttributeDefinition
|
||||
{
|
||||
return CMDBChangeOpSetAttributeBlob::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -18,7 +19,7 @@ use Dict;
|
||||
*/
|
||||
class AttributeBoolean extends AttributeInteger
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -97,8 +98,11 @@ class AttributeBoolean extends AttributeInteger
|
||||
} else {
|
||||
$sValue = $bValue ? 'yes' : 'no';
|
||||
$sDefault = Dict::S('Core:'.get_class($this).'/Value:'.$sValue.'+');
|
||||
$sDescription = $this->SearchLabel('/Attribute:'.$this->m_sCode.'/Value:'.$sValue.'+', $sDefault,
|
||||
true /*user lang*/);
|
||||
$sDescription = $this->SearchLabel(
|
||||
'/Attribute:'.$this->m_sCode.'/Value:'.$sValue.'+',
|
||||
$sDefault,
|
||||
true /*user lang*/
|
||||
);
|
||||
}
|
||||
|
||||
return $sDescription;
|
||||
@@ -135,10 +139,13 @@ class AttributeBoolean extends AttributeInteger
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$bValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$bValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (is_null($bValue)) {
|
||||
$sFinalValue = '';
|
||||
} elseif ($bLocalize) {
|
||||
@@ -170,7 +177,7 @@ class AttributeBoolean extends AttributeInteger
|
||||
$oFormField = new $sFormFieldClass($this->GetCode());
|
||||
}
|
||||
|
||||
$oFormField->SetChoices(array('yes' => $this->GetValueLabel(true), 'no' => $this->GetValueLabel(false)));
|
||||
$oFormField->SetChoices(['yes' => $this->GetValueLabel(true), 'no' => $this->GetValueLabel(false)]);
|
||||
parent::MakeFormField($oObject, $oFormField);
|
||||
|
||||
return $oFormField;
|
||||
@@ -191,10 +198,13 @@ class AttributeBoolean extends AttributeInteger
|
||||
}
|
||||
|
||||
public function MakeValueFromString(
|
||||
$sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null,
|
||||
$sProposedValue,
|
||||
$bLocalizedValue = false,
|
||||
$sSepItem = null,
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
$sInput = mb_strtolower(trim($sProposedValue));
|
||||
if ($bLocalizedValue) {
|
||||
switch ($sInput) {
|
||||
@@ -238,7 +248,7 @@ class AttributeBoolean extends AttributeInteger
|
||||
return CMDBChangeOpSetAttributeScalar::class;
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = ''): array
|
||||
public function GetAllowedValues($aArgs = [], $sContains = ''): array
|
||||
{
|
||||
return [
|
||||
0 => $this->GetValueLabel(false),
|
||||
@@ -250,4 +260,4 @@ class AttributeBoolean extends AttributeInteger
|
||||
{
|
||||
return $this->GetOptional('display_style', 'select');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -25,7 +26,7 @@ use utils;
|
||||
*/
|
||||
class AttributeCaseLog extends AttributeLongText
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -74,16 +75,15 @@ class AttributeCaseLog extends AttributeLongText
|
||||
return $proposedValue->GetEntryCount() > 0;
|
||||
}
|
||||
|
||||
|
||||
public function ScalarToSQL($value)
|
||||
{
|
||||
if (!is_string($value) && !is_null($value)) {
|
||||
throw new CoreWarning('Expected the attribute value to be a string', array(
|
||||
throw new CoreWarning('Expected the attribute value to be a string', [
|
||||
'found_type' => gettype($value),
|
||||
'value' => $value,
|
||||
'class' => $this->GetCode(),
|
||||
'attribute' => $this->GetHostClass(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -131,7 +131,6 @@ class AttributeCaseLog extends AttributeLongText
|
||||
return ($val1->GetText() == $val2->GetText());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Facilitate things: allow the user to Set the value from a string
|
||||
*
|
||||
@@ -153,7 +152,8 @@ class AttributeCaseLog extends AttributeLongText
|
||||
if ($oHostObj != null) {
|
||||
$oPreviousLog = $oHostObj->Get($this->GetCode());
|
||||
if (!is_object($oPreviousLog)) {
|
||||
$oPreviousLog = $oHostObj->GetOriginal($this->GetCode());;
|
||||
$oPreviousLog = $oHostObj->GetOriginal($this->GetCode());
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class AttributeCaseLog extends AttributeLongText
|
||||
if ($sPrefix == '') {
|
||||
$sPrefix = $this->Get('sql');
|
||||
}
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $sPrefix;
|
||||
$aColumns['_index'] = $sPrefix.'_index';
|
||||
@@ -232,7 +232,7 @@ class AttributeCaseLog extends AttributeLongText
|
||||
if (!($value instanceof ormCaseLog)) {
|
||||
$value = new ormCaseLog('');
|
||||
}
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode()] = $value->GetText();
|
||||
$aValues[$this->GetCode().'_index'] = serialize($value->GetIndex());
|
||||
|
||||
@@ -241,7 +241,7 @@ class AttributeCaseLog extends AttributeLongText
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'LONGTEXT' // 2^32 (4 Gb)
|
||||
.CMDBSource::GetSqlStringColumnDefinition();
|
||||
$aColumns[$this->GetCode().'_index'] = 'BLOB';
|
||||
@@ -252,11 +252,11 @@ class AttributeCaseLog extends AttributeLongText
|
||||
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if ($value instanceof ormCaseLog) {
|
||||
$sContent = $value->GetAsHTML(null, false, array(__class__, 'RenderWikiHtml'));
|
||||
$sContent = $value->GetAsHTML(null, false, [__class__, 'RenderWikiHtml']);
|
||||
} else {
|
||||
$sContent = '';
|
||||
}
|
||||
$aStyles = array();
|
||||
$aStyles = [];
|
||||
if ($this->GetWidth() != '') {
|
||||
$aStyles[] = 'width:'.$this->GetWidth();
|
||||
}
|
||||
@@ -271,15 +271,23 @@ class AttributeCaseLog extends AttributeLongText
|
||||
return "<div class=\"caselog\" $sStyle>".$sContent.'</div>';
|
||||
}
|
||||
|
||||
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if ($value instanceof ormCaseLog) {
|
||||
return parent::GetAsCSV($value->GetText($bConvertToPlainText), $sSeparator, $sTextQualifier, $oHostObject,
|
||||
$bLocalize, $bConvertToPlainText);
|
||||
return parent::GetAsCSV(
|
||||
$value->GetText($bConvertToPlainText),
|
||||
$sSeparator,
|
||||
$sTextQualifier,
|
||||
$oHostObject,
|
||||
$bLocalize,
|
||||
$bConvertToPlainText
|
||||
);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@@ -299,12 +307,12 @@ class AttributeCaseLog extends AttributeLongText
|
||||
*/
|
||||
public function EnumTemplateVerbs()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'' => 'Plain text representation of all the log entries',
|
||||
'head' => 'Plain text representation of the latest entry',
|
||||
'head_html' => 'HTML representation of the latest entry',
|
||||
'html' => 'HTML representation of all the log entries',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,4 +418,4 @@ class AttributeCaseLog extends AttributeLongText
|
||||
{
|
||||
return CMDBChangeOpSetAttributeCaseLog::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,11 +18,11 @@ use ValueSetEnumClasses;
|
||||
*/
|
||||
class AttributeClass extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_ENUM;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_ENUM;
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('class_category', 'more_values'));
|
||||
return array_merge(parent::ListExpectedParams(), ['class_category', 'more_values']);
|
||||
}
|
||||
|
||||
public function __construct($sCode, $aParams)
|
||||
@@ -53,7 +54,7 @@ class AttributeClass extends AttributeString
|
||||
* @return array|null
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$oValSetDef = $this->GetValuesDef();
|
||||
if (!$oValSetDef) {
|
||||
@@ -91,4 +92,4 @@ class AttributeClass extends AttributeString
|
||||
return '=';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,9 +16,9 @@ use utils;
|
||||
|
||||
class AttributeClassAttCodeSet extends AttributeSet
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
const DEFAULT_PARAM_INCLUDE_CHILD_CLASSES_ATTRIBUTES = false;
|
||||
public const DEFAULT_PARAM_INCLUDE_CHILD_CLASSES_ATTRIBUTES = false;
|
||||
|
||||
public function __construct($sCode, array $aParams)
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('class_field', 'attribute_definition_list', 'attribute_definition_exclusion_list'));
|
||||
return array_merge(parent::ListExpectedParams(), ['class_field', 'attribute_definition_list', 'attribute_definition_exclusion_list']);
|
||||
}
|
||||
|
||||
public function GetMaxSize()
|
||||
@@ -42,7 +43,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
* @return array|null
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
if (!isset($aArgs['this'])) {
|
||||
return null;
|
||||
@@ -53,7 +54,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
$sRootClass = $oHostObj->Get($sTargetClass);
|
||||
$bIncludeChildClasses = $this->GetOptional('include_child_classes_attributes', static::DEFAULT_PARAM_INCLUDE_CHILD_CLASSES_ATTRIBUTES);
|
||||
|
||||
$aExcludeDefs = array();
|
||||
$aExcludeDefs = [];
|
||||
$sAttDefExclusionList = $this->Get('attribute_definition_exclusion_list');
|
||||
if (!empty($sAttDefExclusionList)) {
|
||||
foreach (explode(',', $sAttDefExclusionList) as $sAttDefName) {
|
||||
@@ -62,7 +63,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
}
|
||||
}
|
||||
|
||||
$aAllowedDefs = array();
|
||||
$aAllowedDefs = [];
|
||||
$sAttDefList = $this->Get('attribute_definition_list');
|
||||
if (!empty($sAttDefList)) {
|
||||
foreach (explode(',', $sAttDefList) as $sAttDefName) {
|
||||
@@ -71,9 +72,9 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
}
|
||||
}
|
||||
|
||||
$aAllAttributes = array();
|
||||
$aAllAttributes = [];
|
||||
if (!empty($sRootClass)) {
|
||||
$aClasses = array($sRootClass);
|
||||
$aClasses = [$sRootClass];
|
||||
if ($bIncludeChildClasses === true) {
|
||||
$aClasses = $aClasses + MetaModel::EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_EXCLUDETOP);
|
||||
}
|
||||
@@ -94,9 +95,9 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
continue;
|
||||
}
|
||||
|
||||
$aAllAttributes[$sAttCode] = array(
|
||||
'classes' => array($sClass),
|
||||
);
|
||||
$aAllAttributes[$sAttCode] = [
|
||||
'classes' => [$sClass],
|
||||
];
|
||||
} else {
|
||||
$aAllAttributes[$sAttCode]['classes'][] = $sClass;
|
||||
}
|
||||
@@ -104,7 +105,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
}
|
||||
}
|
||||
|
||||
$aAllowedAttributes = array();
|
||||
$aAllowedAttributes = [];
|
||||
foreach ($aAllAttributes as $sAttCode => $aAttData) {
|
||||
$iAttClassesCount = count($aAttData['classes']);
|
||||
$sAttFirstClass = $aAttData['classes'][0];
|
||||
@@ -141,18 +142,18 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
public function MakeRealValue($proposedValue, $oHostObj, $bIgnoreErrors = false)
|
||||
{
|
||||
$oSet = new ormSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
|
||||
$aArgs = array();
|
||||
$aArgs = [];
|
||||
if (!empty($oHostObj)) {
|
||||
$aArgs['this'] = $oHostObj;
|
||||
}
|
||||
$aAllowedAttributes = $this->GetAllowedValues($aArgs);
|
||||
$aInvalidAttCodes = array();
|
||||
$aInvalidAttCodes = [];
|
||||
if (is_string($proposedValue) && !empty($proposedValue)) {
|
||||
$aJsonFromWidget = json_decode($proposedValue, true);
|
||||
if (is_null($aJsonFromWidget)) {
|
||||
$proposedValue = trim($proposedValue);
|
||||
$aProposedValues = $this->FromStringToArray($proposedValue);
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
foreach ($aProposedValues as $sValue) {
|
||||
$sAttCode = trim($sValue);
|
||||
if (empty($aAllowedAttributes) || isset($aAllowedAttributes[$sAttCode])) {
|
||||
@@ -194,7 +195,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
$sTargetClass = $this->Get('class_field');
|
||||
$sClass = $oHostObject->Get($sTargetClass);
|
||||
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($value as $sAttCode) {
|
||||
try {
|
||||
$sAttClass = $sClass;
|
||||
@@ -209,8 +210,7 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
|
||||
$sLabelForHtmlAttribute = utils::HtmlEntities(MetaModel::GetLabel($sAttClass, $sAttCode)." ($sAttCode)");
|
||||
$aLocalizedValues[] = '<span class="attribute-set-item" data-code="'.$sAttCode.'" data-label="'.$sLabelForHtmlAttribute.'" data-description="" data-tooltip-content="'.$sLabelForHtmlAttribute.'">'.$sAttCode.'</span>';
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// Ignore bad values
|
||||
}
|
||||
}
|
||||
@@ -226,4 +226,4 @@ class AttributeClassAttCodeSet extends AttributeSet
|
||||
{
|
||||
return (empty($proposedValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,7 +17,7 @@ use utils;
|
||||
*/
|
||||
class AttributeClassState extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -37,17 +38,17 @@ class AttributeClassState extends AttributeString
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('class_field'));
|
||||
return array_merge(parent::ListExpectedParams(), ['class_field']);
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
if (isset($aArgs['this'])) {
|
||||
$oHostObj = $aArgs['this'];
|
||||
$sTargetClass = $this->Get('class_field');
|
||||
$sClass = $oHostObj->Get($sTargetClass);
|
||||
|
||||
$aAllowedStates = array();
|
||||
$aAllowedStates = [];
|
||||
foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass) {
|
||||
$aValues = MetaModel::EnumStates($sChildClass);
|
||||
foreach (array_keys($aValues) as $sState) {
|
||||
@@ -84,4 +85,4 @@ class AttributeClassState extends AttributeString
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -21,7 +22,7 @@ use utils;
|
||||
*/
|
||||
class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -42,7 +43,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("handler_class"));
|
||||
return array_merge(parent::ListExpectedParams(), ["handler_class"]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -67,7 +68,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -198,8 +199,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
$sFormId = utils::IsNullOrEmptyString($sFormPrefix) ? 'cf_'.$this->GetCode() : $sFormPrefix.'_cf_'.$this->GetCode();
|
||||
$oHandler->BuildForm($oHostObject, $sFormId);
|
||||
$oForm = $oHandler->GetForm();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oForm = new \Combodo\iTop\Form\Form('');
|
||||
$oField = new \Combodo\iTop\Form\Field\LabelField('');
|
||||
$oField->SetLabel('Custom field error: '.$e->getMessage());
|
||||
@@ -225,8 +225,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
$oHandler = $this->GetHandler();
|
||||
$aValues = $oHandler->ReadValues($oHostObject);
|
||||
$oRet = new ormCustomFieldsValue($oHostObject, $this->GetCode(), $aValues);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oRet = new ormCustomFieldsValue($oHostObject, $this->GetCode());
|
||||
}
|
||||
|
||||
@@ -243,7 +242,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
$oValue = $oHostObject->Get($this->GetCode());
|
||||
if (!($oValue instanceof ormCustomFieldsValue)) {
|
||||
$oHandler = $this->GetHandler();
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
} else {
|
||||
// Pass the values through the form to make sure that they are correct
|
||||
$oHandler = $this->GetHandler($oValue->GetValues());
|
||||
@@ -283,8 +282,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
$oHandler = $this->GetHandler($value->GetValues());
|
||||
$oHandler->BuildForm($oHostObject, '');
|
||||
$ret = $oHandler->Validate($oHostObject);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$ret = $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -312,8 +310,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
try {
|
||||
/** @var ormCustomFieldsValue $value */
|
||||
$sRet = $value->GetAsHTML($bLocalize);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sRet = 'Custom field error: '.utils::EscapeHtml($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -324,8 +321,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
try {
|
||||
$sRet = $value->GetAsXML($bLocalize);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sRet = Str::pure2xml('Custom field error: '.$e->getMessage());
|
||||
}
|
||||
|
||||
@@ -344,16 +340,18 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
* @noinspection PhpParameterNameChangedDuringInheritanceInspection
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
$sRet = $value->GetAsCSV($sSeparator, $sTextQualifier, $bLocalize, $bConvertToPlainText);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
} catch (Exception $e) {
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, 'Custom field error: '.$e->getMessage());
|
||||
$sRet = $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
}
|
||||
@@ -385,8 +383,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
try {
|
||||
$sRet = $value->GetForTemplate($sVerb, $bLocalize);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sRet = 'Custom field error: '.$e->getMessage();
|
||||
}
|
||||
|
||||
@@ -394,10 +391,13 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
}
|
||||
|
||||
public function MakeValueFromString(
|
||||
$sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null,
|
||||
$sProposedValue,
|
||||
$bLocalizedValue = false,
|
||||
$sSepItem = null,
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -414,8 +414,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
try {
|
||||
$sRet = $value->GetForJSON();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sRet = 'Custom field error: '.$e->getMessage();
|
||||
}
|
||||
|
||||
@@ -438,8 +437,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
try {
|
||||
$bEquals = $val1->Equals($val2);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$bEquals = false;
|
||||
}
|
||||
|
||||
@@ -468,4 +466,4 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
{
|
||||
return CMDBChangeOpSetAttributeCustomFields::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ class AttributeDBField extends AttributeDBFieldVoid
|
||||
{
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("default_value", "is_null_allowed"));
|
||||
return array_merge(parent::ListExpectedParams(), ["default_value", "is_null_allowed"]);
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
@@ -29,4 +30,4 @@ class AttributeDBField extends AttributeDBFieldVoid
|
||||
{
|
||||
return $this->Get("is_null_allowed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -18,7 +19,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
{
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("allowed_values", "depends_on", "sql"));
|
||||
return array_merge(parent::ListExpectedParams(), ["allowed_values", "depends_on", "sql"]);
|
||||
}
|
||||
|
||||
// To be overriden, used in GetSQLColumns
|
||||
@@ -100,7 +101,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
|
||||
public function GetSQLExpressions($sPrefix = '')
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $this->Get("sql");
|
||||
|
||||
@@ -116,7 +117,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->Get("sql")] = $this->ScalarToSQL($value);
|
||||
|
||||
return $aValues;
|
||||
@@ -124,7 +125,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->Get("sql")] = $this->GetSQLCol($bFullSpec);
|
||||
|
||||
return $aColumns;
|
||||
@@ -132,7 +133,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array("=" => "equals", "!=" => "differs from");
|
||||
return ["=" => "equals", "!=" => "differs from"];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -152,4 +153,4 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
return $this->GetSQLExpr()." = $sQValue";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -32,8 +33,10 @@ class AttributeDashboard extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(),
|
||||
array("definition_file", "is_user_editable"));
|
||||
return array_merge(
|
||||
parent::ListExpectedParams(),
|
||||
["definition_file", "is_user_editable"]
|
||||
);
|
||||
}
|
||||
|
||||
public function GetDashboard()
|
||||
@@ -67,7 +70,7 @@ class AttributeDashboard extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -107,4 +110,4 @@ class AttributeDashboard extends AttributeDefinition
|
||||
// Always return false for now, we don't consider a custom version of a dashboard
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ use DBObject;
|
||||
*/
|
||||
class AttributeDate extends AttributeDateTime
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE;
|
||||
|
||||
public static $oDateFormat = null;
|
||||
|
||||
@@ -91,13 +92,12 @@ class AttributeDate extends AttributeDateTime
|
||||
public function GetImportColumns()
|
||||
{
|
||||
// Allow an empty string to be a valid value (synonym for "reset")
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'VARCHAR(10)'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
|
||||
return $aColumns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override to specify Field class
|
||||
*
|
||||
@@ -112,4 +112,4 @@ class AttributeDate extends AttributeDateTime
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -30,7 +31,7 @@ use VariableExpression;
|
||||
*/
|
||||
class AttributeDateTime extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE_TIME;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE_TIME;
|
||||
|
||||
public static $oFormat = null;
|
||||
|
||||
@@ -75,7 +76,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
$sTimeFormat = isset($aFormats[$sLang]['time']) ? $aFormats[$sLang]['time'] : (isset($aFormats['default']['time']) ? $aFormats['default']['time'] : 'H:i:s');
|
||||
$sDateAndTimeFormat = isset($aFormats[$sLang]['date_time']) ? $aFormats[$sLang]['date_time'] : (isset($aFormats['default']['date_time']) ? $aFormats['default']['date_time'] : '$date $time');
|
||||
|
||||
$sFullFormat = str_replace(array('$date', '$time'), array($sDateFormat, $sTimeFormat), $sDateAndTimeFormat);
|
||||
$sFullFormat = str_replace(['$date', '$time'], [$sDateFormat, $sTimeFormat], $sDateAndTimeFormat);
|
||||
|
||||
self::SetFormat(new DateTimeFormat($sFullFormat));
|
||||
AttributeDate::SetFormat(new DateTimeFormat($sDateFormat));
|
||||
@@ -123,8 +124,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
try {
|
||||
$oDateTime = $this->GetFormat()->Parse($sSearchString);
|
||||
$sSearchString = $oDateTime->format($this->GetInternalFormat());
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sFormatString = '!'.(string)AttributeDate::GetFormat(); // BEWARE: ! is needed to set non-parsed fields to zero !!!
|
||||
$oDateTime = DateTime::createFromFormat($sFormatString, $sSearchString);
|
||||
if ($oDateTime !== false) {
|
||||
@@ -164,7 +164,6 @@ class AttributeDateTime extends AttributeDBField
|
||||
}
|
||||
$oFormField->SetCurrentValue($this->GetFormat()->Format($oValue));
|
||||
|
||||
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
@@ -173,10 +172,10 @@ class AttributeDateTime extends AttributeDBField
|
||||
*/
|
||||
public function EnumTemplateVerbs()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'' => 'Formatted representation',
|
||||
'raw' => 'Not formatted representation',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +212,6 @@ class AttributeDateTime extends AttributeDBField
|
||||
return "DateTime";
|
||||
}
|
||||
|
||||
|
||||
public function GetEditValue($sValue, $oHostObj = null)
|
||||
{
|
||||
return (string)static::GetFormat()->format($sValue);
|
||||
@@ -232,7 +230,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
public function GetImportColumns()
|
||||
{
|
||||
// Allow an empty string to be a valid value (synonym for "reset")
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'VARCHAR(19)'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
|
||||
return $aColumns;
|
||||
@@ -252,12 +250,10 @@ class AttributeDateTime extends AttributeDBField
|
||||
if (utils::IsNotNullOrEmptyString($sDefaultValue)) {
|
||||
try {
|
||||
$sDefaultDate = Expression::FromOQL($sDefaultValue)->Evaluate([]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
try {
|
||||
$sDefaultDate = Expression::FromOQL('"'.$sDefaultValue.'"')->Evaluate([]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
IssueLog::Error("Invalid default value '$sDefaultValue' for field '{$this->GetCode()}' on class '{$this->GetHostClass()}', defaulting to null");
|
||||
|
||||
return $this->GetNullValue();
|
||||
@@ -265,8 +261,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
}
|
||||
try {
|
||||
$oDate = new DateTimeImmutable($sDefaultDate);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
IssueLog::Error("Invalid default value '$sDefaultValue' for field '{$this->GetCode()}' on class '{$this->GetHostClass()}', defaulting to null");
|
||||
|
||||
return $this->GetNullValue();
|
||||
@@ -285,7 +280,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
"=" => "equals",
|
||||
"!=" => "differs from",
|
||||
"<" => "before",
|
||||
@@ -299,7 +294,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
">|" => "after today + N days",
|
||||
"<|" => "before today + N days",
|
||||
"=|" => "equals today + N days",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -370,8 +365,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
try {
|
||||
$oFormat = new DateTimeFormat(static::GetInternalFormat());
|
||||
$oFormat->Parse($proposedValue);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new CoreUnexpectedValue('Wrong format for date attribute '.$this->GetCode().', expecting "'.$this->GetInternalFormat().'" and got "'.$proposedValue.'"');
|
||||
}
|
||||
|
||||
@@ -401,10 +395,13 @@ class AttributeDateTime extends AttributeDBField
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (empty($sValue) || ($sValue === '0000-00-00 00:00:00') || ($sValue === '0000-00-00')) {
|
||||
return '';
|
||||
} else {
|
||||
@@ -416,8 +413,8 @@ class AttributeDateTime extends AttributeDBField
|
||||
}
|
||||
}
|
||||
}
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
@@ -437,20 +434,22 @@ class AttributeDateTime extends AttributeDBField
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function GetSmartConditionExpression(
|
||||
$sSearchText, FieldExpression $oField, &$aParams, $bParseSearchString = false
|
||||
)
|
||||
{
|
||||
$sSearchText,
|
||||
FieldExpression $oField,
|
||||
&$aParams,
|
||||
$bParseSearchString = false
|
||||
) {
|
||||
// Possible smart patterns
|
||||
$aPatterns = array(
|
||||
'between' => array('pattern' => '/^\[(.*),(.*)\]$/', 'operator' => 'n/a'),
|
||||
'greater than or equal' => array('pattern' => '/^>=(.*)$/', 'operator' => '>='),
|
||||
'greater than' => array('pattern' => '/^>(.*)$/', 'operator' => '>'),
|
||||
'less than or equal' => array('pattern' => '/^<=(.*)$/', 'operator' => '<='),
|
||||
'less than' => array('pattern' => '/^<(.*)$/', 'operator' => '<'),
|
||||
);
|
||||
$aPatterns = [
|
||||
'between' => ['pattern' => '/^\[(.*),(.*)\]$/', 'operator' => 'n/a'],
|
||||
'greater than or equal' => ['pattern' => '/^>=(.*)$/', 'operator' => '>='],
|
||||
'greater than' => ['pattern' => '/^>(.*)$/', 'operator' => '>'],
|
||||
'less than or equal' => ['pattern' => '/^<=(.*)$/', 'operator' => '<='],
|
||||
'less than' => ['pattern' => '/^<(.*)$/', 'operator' => '<'],
|
||||
];
|
||||
|
||||
$sPatternFound = '';
|
||||
$aMatches = array();
|
||||
$aMatches = [];
|
||||
foreach ($aPatterns as $sPatName => $sPattern) {
|
||||
if (preg_match($sPattern['pattern'], $sSearchText, $aMatches)) {
|
||||
$sPatternFound = $sPatName;
|
||||
@@ -506,7 +505,6 @@ class AttributeDateTime extends AttributeDBField
|
||||
return $oNewCondition;
|
||||
}
|
||||
|
||||
|
||||
public function GetHelpOnSmartSearch()
|
||||
{
|
||||
$sDict = parent::GetHelpOnSmartSearch();
|
||||
@@ -514,6 +512,6 @@ class AttributeDateTime extends AttributeDBField
|
||||
$oFormat = static::GetFormat();
|
||||
$sExample = $oFormat->Format(new DateTime('2015-07-19 18:40:00'));
|
||||
|
||||
return vsprintf($sDict, array($oFormat->ToPlaceholder(), $sExample));
|
||||
return vsprintf($sDict, [$oFormat->ToPlaceholder(), $sExample]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -54,13 +55,13 @@ class AttributeDeadline extends AttributeDateTime
|
||||
$sDifference = Dict::Format('UI:DeadlineMissedBy_duration', self::FormatDuration(-$difference));
|
||||
}
|
||||
$sFormat = MetaModel::GetConfig()->Get('deadline_format');
|
||||
$sResult = str_replace(array('$date$', '$difference$'), array($sDate, $sDifference), $sFormat);
|
||||
$sResult = str_replace(['$date$', '$difference$'], [$sDate, $sDifference], $sFormat);
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
static function FormatDuration($duration)
|
||||
public static function FormatDuration($duration)
|
||||
{
|
||||
$days = floor($duration / 86400);
|
||||
$hours = floor(($duration - (86400 * $days)) / 3600);
|
||||
@@ -86,4 +87,4 @@ class AttributeDeadline extends AttributeDateTime
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -20,7 +21,7 @@ use utils;
|
||||
*/
|
||||
class AttributeDecimal extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -41,7 +42,7 @@ class AttributeDecimal extends AttributeDBField
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('digits', 'decimals' /* including precision */));
|
||||
return array_merge(parent::ListExpectedParams(), ['digits', 'decimals' /* including precision */]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -76,7 +77,7 @@ class AttributeDecimal extends AttributeDBField
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
"!=" => "differs from",
|
||||
"=" => "equals",
|
||||
">" => "greater (strict) than",
|
||||
@@ -84,7 +85,7 @@ class AttributeDecimal extends AttributeDBField
|
||||
"<" => "less (strict) than",
|
||||
"<=" => "less than",
|
||||
"in" => "in",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -166,4 +167,4 @@ class AttributeDecimal extends AttributeDBField
|
||||
|
||||
return $value; // null or string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -63,7 +64,6 @@ define('DEL_MOVEUP', 3);
|
||||
*/
|
||||
define('DEL_NONE', 4);
|
||||
|
||||
|
||||
/**
|
||||
* For Link sets: tracking_level
|
||||
*
|
||||
@@ -87,11 +87,9 @@ define('LINKSET_EDITWHEN_ON_HOST_EDITION', 1); // The only possible action is to
|
||||
define('LINKSET_EDITWHEN_ON_HOST_DISPLAY', 2); // Show the usual 'Actions' popup menu
|
||||
define('LINKSET_EDITWHEN_ALWAYS', 3); // Show the usual 'Actions' popup menu
|
||||
|
||||
|
||||
define('LINKSET_DISPLAY_STYLE_PROPERTY', 'property');
|
||||
define('LINKSET_DISPLAY_STYLE_TAB', 'tab');
|
||||
|
||||
|
||||
/**
|
||||
* Wiki formatting - experimental
|
||||
*
|
||||
@@ -113,22 +111,21 @@ define('WIKI_OBJECT_REGEXP', '/\[\[(.+):(.+)(\|(.+))?\]\]/U');
|
||||
*/
|
||||
abstract class AttributeDefinition
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE_RAW = 'raw';
|
||||
const SEARCH_WIDGET_TYPE_STRING = 'string';
|
||||
const SEARCH_WIDGET_TYPE_NUMERIC = 'numeric';
|
||||
const SEARCH_WIDGET_TYPE_ENUM = 'enum';
|
||||
const SEARCH_WIDGET_TYPE_EXTERNAL_KEY = 'external_key';
|
||||
const SEARCH_WIDGET_TYPE_HIERARCHICAL_KEY = 'hierarchical_key';
|
||||
const SEARCH_WIDGET_TYPE_EXTERNAL_FIELD = 'external_field';
|
||||
const SEARCH_WIDGET_TYPE_DATE_TIME = 'date_time';
|
||||
const SEARCH_WIDGET_TYPE_DATE = 'date';
|
||||
const SEARCH_WIDGET_TYPE_SET = 'set';
|
||||
const SEARCH_WIDGET_TYPE_TAG_SET = 'tag_set';
|
||||
public const SEARCH_WIDGET_TYPE_RAW = 'raw';
|
||||
public const SEARCH_WIDGET_TYPE_STRING = 'string';
|
||||
public const SEARCH_WIDGET_TYPE_NUMERIC = 'numeric';
|
||||
public const SEARCH_WIDGET_TYPE_ENUM = 'enum';
|
||||
public const SEARCH_WIDGET_TYPE_EXTERNAL_KEY = 'external_key';
|
||||
public const SEARCH_WIDGET_TYPE_HIERARCHICAL_KEY = 'hierarchical_key';
|
||||
public const SEARCH_WIDGET_TYPE_EXTERNAL_FIELD = 'external_field';
|
||||
public const SEARCH_WIDGET_TYPE_DATE_TIME = 'date_time';
|
||||
public const SEARCH_WIDGET_TYPE_DATE = 'date';
|
||||
public const SEARCH_WIDGET_TYPE_SET = 'set';
|
||||
public const SEARCH_WIDGET_TYPE_TAG_SET = 'tag_set';
|
||||
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
const INDEX_LENGTH = 95;
|
||||
public const INDEX_LENGTH = 95;
|
||||
|
||||
protected $aCSSClasses;
|
||||
|
||||
@@ -223,7 +220,7 @@ abstract class AttributeDefinition
|
||||
$this->m_sCode = $sCode;
|
||||
$this->m_aParams = $aParams;
|
||||
$this->ConsistencyCheck();
|
||||
$this->aCSSClasses = array('attribute');
|
||||
$this->aCSSClasses = ['attribute'];
|
||||
}
|
||||
|
||||
public function GetParams()
|
||||
@@ -253,7 +250,7 @@ abstract class AttributeDefinition
|
||||
*/
|
||||
public function ListSubItems()
|
||||
{
|
||||
$aSubItems = array();
|
||||
$aSubItems = [];
|
||||
foreach (MetaModel::ListAttributeDefs($this->m_sHostClass) as $sAttCode => $oAttDef) {
|
||||
if ($oAttDef instanceof AttributeSubItem) {
|
||||
if ($oAttDef->Get('target_attcode') == $this->m_sCode) {
|
||||
@@ -269,7 +266,7 @@ abstract class AttributeDefinition
|
||||
// to be overloaded
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -604,8 +601,7 @@ abstract class AttributeDefinition
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
return $this->MakeRealValue($sProposedValue, null);
|
||||
}
|
||||
|
||||
@@ -692,7 +688,7 @@ abstract class AttributeDefinition
|
||||
|
||||
public function GetHelpOnSmartSearch()
|
||||
{
|
||||
$aParents = array_merge(array(get_class($this) => get_class($this)), class_parents($this));
|
||||
$aParents = array_merge([get_class($this) => get_class($this)], class_parents($this));
|
||||
foreach ($aParents as $sClass) {
|
||||
$sHelp = Dict::S("Core:$sClass?SmartSearch", '-missing-');
|
||||
if ($sHelp != '-missing-') {
|
||||
@@ -733,7 +729,7 @@ abstract class AttributeDefinition
|
||||
|
||||
public function GetPrerequisiteAttributes($sClass = null)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetNullValue()
|
||||
@@ -783,7 +779,7 @@ abstract class AttributeDefinition
|
||||
*/
|
||||
public function GetSQLExpressions($sPrefix = '')
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -806,7 +802,7 @@ abstract class AttributeDefinition
|
||||
*/
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -816,7 +812,7 @@ abstract class AttributeDefinition
|
||||
*/
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function RequiresIndex()
|
||||
@@ -837,7 +833,7 @@ abstract class AttributeDefinition
|
||||
public function GetOrderBySQLExpressions($sClassAlias)
|
||||
{
|
||||
// Note: This is the responsibility of this function to place backticks around column aliases
|
||||
return array('`'.$sClassAlias.$this->GetCode().'`');
|
||||
return ['`'.$sClassAlias.$this->GetCode().'`'];
|
||||
}
|
||||
|
||||
public function GetOrderByHint()
|
||||
@@ -854,7 +850,7 @@ abstract class AttributeDefinition
|
||||
|
||||
public function FromImportToValue($aCols, $sPrefix = '')
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
foreach ($this->GetSQLExpressions($sPrefix) as $sAlias => $sExpr) {
|
||||
// This is working, based on the assumption that importable fields
|
||||
// are not computed fields => the expression is the name of a column
|
||||
@@ -991,10 +987,13 @@ abstract class AttributeDefinition
|
||||
* @return string
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
return (string)$sValue;
|
||||
}
|
||||
|
||||
@@ -1110,12 +1109,12 @@ abstract class AttributeDefinition
|
||||
*/
|
||||
public function EnumTemplateVerbs()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'' => 'Plain text (unlocalized) representation',
|
||||
'html' => 'HTML representation',
|
||||
'label' => 'Localized representation',
|
||||
'text' => 'Plain text representation (without any markup)',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1163,7 +1162,7 @@ abstract class AttributeDefinition
|
||||
* @throws CoreException
|
||||
* @throws OQLException
|
||||
*/
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$oValSetDef = $this->GetValuesDef();
|
||||
if (!$oValSetDef) {
|
||||
@@ -1183,7 +1182,7 @@ abstract class AttributeDefinition
|
||||
* @throws CoreException
|
||||
* @throws OQLException
|
||||
*/
|
||||
public function GetAllowedValuesForSelect($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValuesForSelect($aArgs = [], $sContains = '')
|
||||
{
|
||||
return $this->GetAllowedValues($aArgs, $sContains);
|
||||
}
|
||||
@@ -1220,13 +1219,11 @@ abstract class AttributeDefinition
|
||||
if ((($this->GetType() == 'String') || ($this->GetType() == 'Text')) &&
|
||||
(strlen($sNewValue) > strlen($sOldValue))) {
|
||||
// Check if some text was not appended to the field
|
||||
if (substr($sNewValue, 0, strlen($sOldValue)) == $sOldValue) // Text added at the end
|
||||
{
|
||||
if (substr($sNewValue, 0, strlen($sOldValue)) == $sOldValue) { // Text added at the end
|
||||
$sDelta = $this->GetAsHTML(substr($sNewValue, strlen($sOldValue)));
|
||||
$sResult = Dict::Format('Change:Text_AppendedTo_AttName', $sDelta, $sLabel);
|
||||
} else {
|
||||
if (substr($sNewValue, -strlen($sOldValue)) == $sOldValue) // Text added at the beginning
|
||||
{
|
||||
if (substr($sNewValue, -strlen($sOldValue)) == $sOldValue) { // Text added at the beginning
|
||||
$sDelta = $this->GetAsHTML(substr($sNewValue, 0, strlen($sNewValue) - strlen($sOldValue)));
|
||||
$sResult = Dict::Format('Change:Text_AppendedTo_AttName', $sDelta, $sLabel);
|
||||
} else {
|
||||
@@ -1236,8 +1233,12 @@ abstract class AttributeDefinition
|
||||
if (is_null($sNewValue)) {
|
||||
$sNewValueHtml = Dict::S('UI:UndefinedObject');
|
||||
}
|
||||
$sResult = Dict::Format('Change:AttName_SetTo_NewValue_PreviousValue_OldValue', $sLabel,
|
||||
$sNewValueHtml, $sOldValueHtml);
|
||||
$sResult = Dict::Format(
|
||||
'Change:AttName_SetTo_NewValue_PreviousValue_OldValue',
|
||||
$sLabel,
|
||||
$sNewValueHtml,
|
||||
$sOldValueHtml
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1248,8 +1249,12 @@ abstract class AttributeDefinition
|
||||
if (is_null($sNewValue)) {
|
||||
$sNewValueHtml = Dict::S('UI:UndefinedObject');
|
||||
}
|
||||
$sResult = Dict::Format('Change:AttName_SetTo_NewValue_PreviousValue_OldValue', $sLabel, $sNewValueHtml,
|
||||
$sOldValueHtml);
|
||||
$sResult = Dict::Format(
|
||||
'Change:AttName_SetTo_NewValue_PreviousValue_OldValue',
|
||||
$sLabel,
|
||||
$sNewValueHtml,
|
||||
$sOldValueHtml
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,4 +1384,4 @@ abstract class AttributeDefinition
|
||||
|
||||
return $sRenderFunction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -92,12 +93,21 @@ class AttributeDuration extends AttributeInteger
|
||||
} else {
|
||||
if ($duration < 86400) {
|
||||
// Less than 1 day, display it in hours/minutes/seconds
|
||||
$sResult = Dict::Format('Core:Duration_Hours_Minutes_Seconds', $aDuration['hours'],
|
||||
$aDuration['minutes'], $aDuration['seconds']);
|
||||
$sResult = Dict::Format(
|
||||
'Core:Duration_Hours_Minutes_Seconds',
|
||||
$aDuration['hours'],
|
||||
$aDuration['minutes'],
|
||||
$aDuration['seconds']
|
||||
);
|
||||
} else {
|
||||
// more than 1 day, display it in days/hours/minutes/seconds
|
||||
$sResult = Dict::Format('Core:Duration_Days_Hours_Minutes_Seconds', $aDuration['days'],
|
||||
$aDuration['hours'], $aDuration['minutes'], $aDuration['seconds']);
|
||||
$sResult = Dict::Format(
|
||||
'Core:Duration_Days_Hours_Minutes_Seconds',
|
||||
$aDuration['days'],
|
||||
$aDuration['hours'],
|
||||
$aDuration['minutes'],
|
||||
$aDuration['seconds']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +115,7 @@ class AttributeDuration extends AttributeInteger
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
static function SplitDuration($duration)
|
||||
public static function SplitDuration($duration)
|
||||
{
|
||||
$duration = (int)$duration;
|
||||
$days = floor($duration / 86400);
|
||||
@@ -113,7 +123,7 @@ class AttributeDuration extends AttributeInteger
|
||||
$minutes = floor(($duration - (86400 * $days + 3600 * $hours)) / 60);
|
||||
$seconds = ($duration % 60); // modulo
|
||||
|
||||
return array('days' => $days, 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $seconds);
|
||||
return ['days' => $days, 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $seconds];
|
||||
}
|
||||
|
||||
public static function GetFormFieldClass()
|
||||
@@ -137,4 +147,4 @@ class AttributeDuration extends AttributeInteger
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -52,4 +53,4 @@ class AttributeEmailAddress extends AttributeString
|
||||
|
||||
return '<a class="mailto" href="mailto:'.$sValue.'"><span class="text_decoration '.$sUrlDecorationClass.'"></span>'.parent::GetAsHTML($sValue).'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -22,7 +23,7 @@ use SimpleCrypt;
|
||||
*/
|
||||
class AttributeEncryptedString extends AttributeString implements iAttributeNoGroupBy
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
protected function GetSQLCol($bFullSpec = false)
|
||||
{
|
||||
@@ -73,7 +74,7 @@ class AttributeEncryptedString extends AttributeString implements iAttributeNoGr
|
||||
$oSimpleCrypt = new SimpleCrypt(MetaModel::GetConfig()->GetEncryptionLibrary());
|
||||
$encryptedValue = $oSimpleCrypt->Encrypt(MetaModel::GetConfig()->GetEncryptionKey(), $value);
|
||||
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->Get("sql")] = $encryptedValue;
|
||||
|
||||
return $aValues;
|
||||
@@ -92,5 +93,4 @@ class AttributeEncryptedString extends AttributeString implements iAttributeNoGr
|
||||
return CMDBChangeOpSetAttributeEncrypted::class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -22,7 +23,7 @@ use ormStyle;
|
||||
*/
|
||||
class AttributeEnum extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_ENUM;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_ENUM;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -93,9 +94,9 @@ class AttributeEnum extends AttributeString
|
||||
{
|
||||
$oValDef = $this->GetValuesDef();
|
||||
if ($oValDef) {
|
||||
$aValues = CMDBSource::Quote(array_keys($oValDef->GetValues(array(), "")), true);
|
||||
$aValues = CMDBSource::Quote(array_keys($oValDef->GetValues([], "")), true);
|
||||
} else {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
}
|
||||
|
||||
// Preserve the values already present in the database to ease migrations
|
||||
@@ -134,7 +135,7 @@ class AttributeEnum extends AttributeString
|
||||
// Right now the function is not passed the "target" SQL table, but if we improve this in the future
|
||||
// we may call $this->GetSQLColHelper(true, true, $sDBTable); to take into account the actual 'enum' values
|
||||
// in this table
|
||||
return array($this->GetCode() => $this->GetSQLColHelper(false, false));
|
||||
return [$this->GetCode() => $this->GetSQLColHelper(false, false)];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +146,7 @@ class AttributeEnum extends AttributeString
|
||||
*/
|
||||
protected function GetActualValuesInDB(string $sDBTable)
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
try {
|
||||
$sSQL = "SELECT DISTINCT `".$this->GetSQLExpr()."` AS value FROM `$sDBTable`;";
|
||||
$aValuesInDB = CMDBSource::QueryToArray($sSQL);
|
||||
@@ -154,8 +155,7 @@ class AttributeEnum extends AttributeString
|
||||
$aValues[] = $aRow['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySQLException $e) {
|
||||
} catch (MySQLException $e) {
|
||||
// Never mind, maybe the table does not exist yet (new installation from scratch)
|
||||
// It seems more efficient to try and ignore errors than to test if the table & column really exists
|
||||
}
|
||||
@@ -214,8 +214,10 @@ class AttributeEnum extends AttributeString
|
||||
{
|
||||
if (is_null($sValue)) {
|
||||
// Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
|
||||
$sLabel = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue,
|
||||
Dict::S('Enum:Undefined'));
|
||||
$sLabel = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue,
|
||||
Dict::S('Enum:Undefined')
|
||||
);
|
||||
} else {
|
||||
$sLabel = $this->SearchLabel('/Attribute:'.$this->m_sCode.'/Value:'.$sValue, null, true /*user lang*/);
|
||||
if (is_null($sLabel)) {
|
||||
@@ -232,11 +234,16 @@ class AttributeEnum extends AttributeString
|
||||
{
|
||||
if (is_null($sValue)) {
|
||||
// Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
|
||||
$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
Dict::S('Enum:Undefined'));
|
||||
$sDescription = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
Dict::S('Enum:Undefined')
|
||||
);
|
||||
} else {
|
||||
$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
'', true /* user language only */);
|
||||
$sDescription = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
'',
|
||||
true /* user language only */
|
||||
);
|
||||
if (strlen($sDescription) == 0) {
|
||||
$sParentClass = MetaModel::GetParentClass($this->m_sHostClass);
|
||||
if ($sParentClass) {
|
||||
@@ -284,10 +291,13 @@ class AttributeEnum extends AttributeString
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (is_null($sValue)) {
|
||||
$sFinalValue = '';
|
||||
} elseif ($bLocalize) {
|
||||
@@ -333,13 +343,13 @@ class AttributeEnum extends AttributeString
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$aRawValues = parent::GetAllowedValues($aArgs, $sContains);
|
||||
if (is_null($aRawValues)) {
|
||||
return null;
|
||||
}
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($aRawValues as $sKey => $sValue) {
|
||||
$aLocalizedValues[$sKey] = $this->GetValueLabel($sKey);
|
||||
}
|
||||
@@ -364,10 +374,13 @@ class AttributeEnum extends AttributeString
|
||||
* An enum can be localized
|
||||
*/
|
||||
public function MakeValueFromString(
|
||||
$sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null,
|
||||
$sProposedValue,
|
||||
$bLocalizedValue = false,
|
||||
$sSepItem = null,
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
if ($bLocalizedValue) {
|
||||
// Lookup for the value matching the input
|
||||
//
|
||||
@@ -388,8 +401,14 @@ class AttributeEnum extends AttributeString
|
||||
|
||||
return $this->MakeRealValue($sFoundValue, null);
|
||||
} else {
|
||||
return parent::MakeValueFromString($sProposedValue, $bLocalizedValue, $sSepItem, $sSepAttribute, $sSepValue,
|
||||
$sAttributeQualifier);
|
||||
return parent::MakeValueFromString(
|
||||
$sProposedValue,
|
||||
$bLocalizedValue,
|
||||
$sSepItem,
|
||||
$sSepAttribute,
|
||||
$sSepValue,
|
||||
$sAttributeQualifier
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,4 +435,4 @@ class AttributeEnum extends AttributeString
|
||||
|
||||
return Dict::Format('UI:OrderByHint_Values', implode(', ', $aValues));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,18 +17,18 @@ use ValueSetEnumPadded;
|
||||
*/
|
||||
class AttributeEnumSet extends AttributeSet
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_TAG_SET;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_TAG_SET;
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('possible_values', 'is_null_allowed', 'max_items'));
|
||||
return array_merge(parent::ListExpectedParams(), ['possible_values', 'is_null_allowed', 'max_items']);
|
||||
}
|
||||
|
||||
public function GetMaxSize()
|
||||
{
|
||||
$aRawValues = $this->GetRawPossibleValues();
|
||||
$iMaxItems = $this->GetMaxItems();
|
||||
$aLengths = array();
|
||||
$aLengths = [];
|
||||
foreach (array_keys($aRawValues) as $sKey) {
|
||||
$aLengths[] = strlen($sKey);
|
||||
}
|
||||
@@ -40,21 +41,21 @@ class AttributeEnumSet extends AttributeSet
|
||||
return max(255, $iMaxSize);
|
||||
}
|
||||
|
||||
private function GetRawPossibleValues($aArgs = array(), $sContains = '')
|
||||
private function GetRawPossibleValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
/** @var ValueSetEnumPadded $oValSetDef */
|
||||
$oValSetDef = $this->Get('possible_values');
|
||||
if (!$oValSetDef) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return $oValSetDef->GetValues($aArgs, $sContains);
|
||||
}
|
||||
|
||||
public function GetPossibleValues($aArgs = array(), $sContains = '')
|
||||
public function GetPossibleValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$aRawValues = $this->GetRawPossibleValues($aArgs, $sContains);
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($aRawValues as $sKey => $sValue) {
|
||||
$aLocalizedValues[$sKey] = $this->GetValueLabel($sKey);
|
||||
}
|
||||
@@ -75,8 +76,10 @@ class AttributeEnumSet extends AttributeSet
|
||||
|
||||
if (is_null($sValue)) {
|
||||
// Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
|
||||
$sLabel = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue,
|
||||
Dict::S('Enum:Undefined'));
|
||||
$sLabel = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue,
|
||||
Dict::S('Enum:Undefined')
|
||||
);
|
||||
} else {
|
||||
$sLabel = $this->SearchLabel('/Attribute:'.$this->m_sCode.'/Value:'.$sValue, null, true /*user lang*/);
|
||||
if (is_null($sLabel)) {
|
||||
@@ -97,11 +100,16 @@ class AttributeEnumSet extends AttributeSet
|
||||
{
|
||||
if (is_null($sValue)) {
|
||||
// Unless a specific label is defined for the null value of this enum, use a generic "undefined" label
|
||||
$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
Dict::S('Enum:Undefined'));
|
||||
$sDescription = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
Dict::S('Enum:Undefined')
|
||||
);
|
||||
} else {
|
||||
$sDescription = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
'', true /* user language only */);
|
||||
$sDescription = Dict::S(
|
||||
'Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue.'+',
|
||||
'',
|
||||
true /* user language only */
|
||||
);
|
||||
if (strlen($sDescription) == 0) {
|
||||
$sParentClass = MetaModel::GetParentClass($this->m_sHostClass);
|
||||
if ($sParentClass) {
|
||||
@@ -133,7 +141,6 @@ class AttributeEnumSet extends AttributeSet
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ormSet $value
|
||||
* @param string $sSeparator
|
||||
@@ -151,7 +158,7 @@ class AttributeEnumSet extends AttributeSet
|
||||
if (is_object($value) && ($value instanceof ormSet)) {
|
||||
$aValues = $value->GetValues();
|
||||
if ($bLocalize) {
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($aValues as $sValue) {
|
||||
$aLocalizedValues[] = $this->GetValueLabel($sValue);
|
||||
}
|
||||
@@ -184,7 +191,7 @@ class AttributeEnumSet extends AttributeSet
|
||||
// Lookup for the values matching the input
|
||||
//
|
||||
$aValues = $this->FromStringToArray($sProposedValue);
|
||||
$aFoundValues = array();
|
||||
$aFoundValues = [];
|
||||
$aRawValues = $this->GetPossibleValues();
|
||||
foreach ($aValues as $sValue) {
|
||||
$bFound = false;
|
||||
@@ -217,7 +224,7 @@ class AttributeEnumSet extends AttributeSet
|
||||
*/
|
||||
public function FromStringToArray($proposedValue, $sDefaultSepItem = ',')
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
if (!empty($proposedValue)) {
|
||||
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
|
||||
// convert also other separators
|
||||
@@ -240,4 +247,4 @@ class AttributeEnumSet extends AttributeSet
|
||||
{
|
||||
return $val1->Equals($val2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -56,14 +57,13 @@ class AttributeExternalField extends AttributeDefinition
|
||||
case ($oRemoteAtt instanceof AttributeExternalKey):
|
||||
return self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
}
|
||||
}
|
||||
catch (CoreException $e) {
|
||||
} catch (CoreException $e) {
|
||||
}
|
||||
|
||||
return self::SEARCH_WIDGET_TYPE_RAW;
|
||||
}
|
||||
|
||||
function IsSearchable()
|
||||
public function IsSearchable()
|
||||
{
|
||||
if ($this->IsFriendlyName()) {
|
||||
return true;
|
||||
@@ -74,7 +74,7 @@ class AttributeExternalField extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("extkey_attcode", "target_attcode"));
|
||||
return array_merge(parent::ListExpectedParams(), ["extkey_attcode", "target_attcode"]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -104,7 +104,7 @@ class AttributeExternalField extends AttributeDefinition
|
||||
public function GetSQLExpressions($sPrefix = '')
|
||||
{
|
||||
if ($sPrefix == '') {
|
||||
return array('' => $this->GetCode()); // Warning: Use GetCode() since AttributeExternalField does not have any 'sql' property
|
||||
return ['' => $this->GetCode()]; // Warning: Use GetCode() since AttributeExternalField does not have any 'sql' property
|
||||
} else {
|
||||
return $sPrefix;
|
||||
}
|
||||
@@ -295,10 +295,9 @@ class AttributeExternalField extends AttributeDefinition
|
||||
|
||||
public function GetPrerequisiteAttributes($sClass = null)
|
||||
{
|
||||
return array($this->Get("extkey_attcode"));
|
||||
return [$this->Get("extkey_attcode")];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return AttributeExternalField
|
||||
* @throws CoreException
|
||||
@@ -417,7 +416,6 @@ class AttributeExternalField extends AttributeDefinition
|
||||
return $oExtAttDef->ScalarToSQL($value);
|
||||
}
|
||||
|
||||
|
||||
// Do not overload GetSQLExpression here because this is handled in the joins
|
||||
//public function GetSQLExpressions($sPrefix = '') {return array();}
|
||||
|
||||
@@ -444,10 +442,13 @@ class AttributeExternalField extends AttributeDefinition
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTestQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTestQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
$oExtAttDef = $this->GetExtAttDef();
|
||||
|
||||
return $oExtAttDef->GetAsCSV($value, $sSeparator, $sTestQualifier, null, $bLocalize, $bConvertToPlainText);
|
||||
@@ -522,4 +523,4 @@ class AttributeExternalField extends AttributeDefinition
|
||||
|
||||
return 'text';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -26,7 +27,7 @@ use ValueSetObjects;
|
||||
*/
|
||||
class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -60,8 +61,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
}
|
||||
|
||||
return self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
}
|
||||
catch (CoreException $e) {
|
||||
} catch (CoreException $e) {
|
||||
}
|
||||
|
||||
return self::SEARCH_WIDGET_TYPE_RAW;
|
||||
@@ -69,7 +69,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("targetclass", "is_null_allowed", "on_target_delete"));
|
||||
return array_merge(parent::ListExpectedParams(), ["targetclass", "is_null_allowed", "on_target_delete"]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -112,7 +112,6 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $this->GetOptional('display_style', 'select');
|
||||
}
|
||||
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
{
|
||||
return 0;
|
||||
@@ -127,7 +126,6 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $this->Get("is_null_allowed");
|
||||
}
|
||||
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return parent::GetBasicFilterOperators();
|
||||
@@ -156,13 +154,12 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $oValSetDef;
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
//throw new Exception("GetAllowedValues on ext key has been deprecated");
|
||||
try {
|
||||
return parent::GetAllowedValues($aArgs, $sContains);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// Some required arguments could not be found, enlarge to any existing value
|
||||
$oValSetDef = new ValueSetObjects('SELECT '.$this->GetTargetClass());
|
||||
|
||||
@@ -170,7 +167,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAllowedValuesForSelect($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValuesForSelect($aArgs = [], $sContains = '')
|
||||
{
|
||||
//$this->GetValuesDef();
|
||||
$oValSetDef = new ValueSetObjects('SELECT '.$this->GetTargetClass());
|
||||
@@ -178,8 +175,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $oValSetDef->GetValuesForAutocomplete($aArgs, $sContains);
|
||||
}
|
||||
|
||||
|
||||
public function GetAllowedValuesAsObjectSet($aArgs = array(), $sContains = '', $iAdditionalValue = null)
|
||||
public function GetAllowedValuesAsObjectSet($aArgs = [], $sContains = '', $iAdditionalValue = null)
|
||||
{
|
||||
$oValSetDef = $this->GetValuesDef();
|
||||
$oSet = $oValSetDef->ToObjectSet($aArgs, $sContains, $iAdditionalValue);
|
||||
@@ -187,7 +183,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $oSet;
|
||||
}
|
||||
|
||||
public function GetAllowedValuesAsFilter($aArgs = array(), $sContains = '', $iAdditionalValue = null)
|
||||
public function GetAllowedValuesAsFilter($aArgs = [], $sContains = '', $iAdditionalValue = null)
|
||||
{
|
||||
return DBObjectSearch::FromOQL($this->GetValuesDef()->GetFilterExpression());
|
||||
}
|
||||
@@ -282,8 +278,10 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
if (!$oRemoteAttDef->IsLinkSet()) {
|
||||
continue;
|
||||
}
|
||||
if (!is_subclass_of($this->GetHostClass(),
|
||||
$oRemoteAttDef->GetLinkedClass()) && $oRemoteAttDef->GetLinkedClass() != $this->GetHostClass()) {
|
||||
if (!is_subclass_of(
|
||||
$this->GetHostClass(),
|
||||
$oRemoteAttDef->GetLinkedClass()
|
||||
) && $oRemoteAttDef->GetLinkedClass() != $this->GetHostClass()) {
|
||||
continue;
|
||||
}
|
||||
if ($oRemoteAttDef->GetExtKeyToMe() != $this->GetCode()) {
|
||||
@@ -328,13 +326,13 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
// We set search object only if it has not already been set (overrided)
|
||||
if ($oTmpField->GetSearch() === null) {
|
||||
$oSearch = DBSearch::FromOQL($oTmpAttDef->GetValuesDef()->GetFilterExpression());
|
||||
$oSearch->SetInternalParams(array('this' => $oObject));
|
||||
$oSearch->SetInternalParams(['this' => $oObject]);
|
||||
$oTmpField->SetSearch($oSearch);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$oSearch = DBSearch::FromOQL($this->GetValuesDef()->GetFilterExpression());
|
||||
$oSearch->SetInternalParams(array('this' => $oObject));
|
||||
$oSearch->SetInternalParams(['this' => $oObject]);
|
||||
$oFormField->SetSearch($oSearch);
|
||||
}
|
||||
|
||||
@@ -351,4 +349,4 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
|
||||
return DBObject::MakeHyperLink($this->GetTargetClass(), $sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ use Str;
|
||||
*/
|
||||
class AttributeFinalClass extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public $m_sValue;
|
||||
|
||||
public function __construct($sCode, $aParams)
|
||||
@@ -81,10 +82,13 @@ class AttributeFinalClass extends AttributeString
|
||||
* @throws OQLException
|
||||
*/
|
||||
public function MakeValueFromString(
|
||||
$sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null,
|
||||
$sProposedValue,
|
||||
$bLocalizedValue = false,
|
||||
$sSepItem = null,
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
if ($bLocalizedValue) {
|
||||
// Lookup for the value matching the input
|
||||
//
|
||||
@@ -104,12 +108,17 @@ class AttributeFinalClass extends AttributeString
|
||||
|
||||
return $this->MakeRealValue($sFoundValue, null);
|
||||
} else {
|
||||
return parent::MakeValueFromString($sProposedValue, $bLocalizedValue, $sSepItem, $sSepAttribute, $sSepValue,
|
||||
$sAttributeQualifier);
|
||||
return parent::MakeValueFromString(
|
||||
$sProposedValue,
|
||||
$bLocalizedValue,
|
||||
$sSepItem,
|
||||
$sSepAttribute,
|
||||
$sSepValue,
|
||||
$sAttributeQualifier
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Because this is sometimes used to get a localized/string version of an attribute...
|
||||
public function GetEditValue($sValue, $oHostObj = null)
|
||||
{
|
||||
@@ -139,10 +148,13 @@ class AttributeFinalClass extends AttributeString
|
||||
* @throws DictExceptionMissingString
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if ($bLocalize && $value != '') {
|
||||
$sRawValue = MetaModel::GetName($value);
|
||||
} else {
|
||||
@@ -180,10 +192,10 @@ class AttributeFinalClass extends AttributeString
|
||||
return MetaModel::GetName($sValue);
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$aRawValues = MetaModel::EnumChildClasses($this->GetHostClass(), ENUM_CHILD_CLASSES_ALL);
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($aRawValues as $sClass) {
|
||||
$aLocalizedValues[$sClass] = MetaModel::GetName($sClass);
|
||||
}
|
||||
@@ -205,4 +217,4 @@ class AttributeFinalClass extends AttributeString
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,13 +20,13 @@ use Str;
|
||||
*/
|
||||
class AttributeFriendlyName extends AttributeDefinition
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public $m_sValue;
|
||||
|
||||
public function __construct($sCode)
|
||||
{
|
||||
$this->m_sCode = $sCode;
|
||||
$aParams = array();
|
||||
$aParams = [];
|
||||
$aParams["default_value"] = '';
|
||||
parent::__construct($sCode, $aParams);
|
||||
|
||||
@@ -45,7 +46,7 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
public function GetPrerequisiteAttributes($sClass = null)
|
||||
{
|
||||
// Code duplicated with AttributeObsolescenceFlag
|
||||
$aAttributes = $this->GetOptional("depends_on", array());
|
||||
$aAttributes = $this->GetOptional("depends_on", []);
|
||||
$oExpression = $this->GetOQLExpression();
|
||||
foreach ($oExpression->ListRequiredFields() as $sAttCode) {
|
||||
if (!in_array($sAttCode, $aAttributes)) {
|
||||
@@ -72,7 +73,7 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
$sPrefix = $this->GetCode(); // Warning AttributeComputedFieldVoid does not have any sql property
|
||||
}
|
||||
|
||||
return array('' => $sPrefix);
|
||||
return ['' => $sPrefix];
|
||||
}
|
||||
|
||||
public static function IsBasedOnOQLExpression()
|
||||
@@ -143,18 +144,21 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
) {
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
}
|
||||
|
||||
static function GetFormFieldClass()
|
||||
public static function GetFormFieldClass()
|
||||
{
|
||||
return '\\Combodo\\iTop\\Form\\Field\\StringField';
|
||||
}
|
||||
@@ -179,7 +183,7 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array("=" => "equals", "!=" => "differs from");
|
||||
return ["=" => "equals", "!=" => "differs from"];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -208,4 +212,4 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -32,7 +33,7 @@ class AttributeHTML extends AttributeLongText
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->Get('sql')] = $this->GetSQLCol();
|
||||
if ($this->GetOptional('format', null) != null) {
|
||||
// Add the extra column only if the property 'format' is specified for the attribute
|
||||
@@ -54,4 +55,4 @@ class AttributeHTML extends AttributeLongText
|
||||
{
|
||||
return $this->GetOptional('format', 'html'); // Defaults to HTML
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -13,7 +14,7 @@ use DBObjectSearch;
|
||||
*/
|
||||
class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_HIERARCHICAL_KEY;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_HIERARCHICAL_KEY;
|
||||
|
||||
protected $m_sTargetClass;
|
||||
|
||||
@@ -98,7 +99,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'INT(11)'.($bFullSpec ? ' DEFAULT 0' : '');
|
||||
$aColumns[$this->GetSQLLeft()] = 'INT(11)'.($bFullSpec ? ' DEFAULT 0' : '');
|
||||
$aColumns[$this->GetSQLRight()] = 'INT(11)'.($bFullSpec ? ' DEFAULT 0' : '');
|
||||
@@ -121,7 +122,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
if (!is_array($value)) {
|
||||
$aValues[$this->GetCode()] = $value;
|
||||
} else {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode()] = $value[$this->GetCode()];
|
||||
$aValues[$this->GetSQLRight()] = $value[$this->GetSQLRight()];
|
||||
$aValues[$this->GetSQLLeft()] = $value[$this->GetSQLLeft()];
|
||||
@@ -130,7 +131,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
return $aValues;
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$oFilter = $this->GetHierachicalFilter($aArgs, $sContains);
|
||||
if ($oFilter) {
|
||||
@@ -143,7 +144,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAllowedValuesAsObjectSet($aArgs = array(), $sContains = '', $iAdditionalValue = null)
|
||||
public function GetAllowedValuesAsObjectSet($aArgs = [], $sContains = '', $iAdditionalValue = null)
|
||||
{
|
||||
$oValSetDef = $this->GetValuesDef();
|
||||
$oFilter = $this->GetHierachicalFilter($aArgs, $sContains, $iAdditionalValue);
|
||||
@@ -155,7 +156,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
return $oSet;
|
||||
}
|
||||
|
||||
public function GetAllowedValuesAsFilter($aArgs = array(), $sContains = '', $iAdditionalValue = null)
|
||||
public function GetAllowedValuesAsFilter($aArgs = [], $sContains = '', $iAdditionalValue = null)
|
||||
{
|
||||
$oFilter = $this->GetHierachicalFilter($aArgs, $sContains, $iAdditionalValue);
|
||||
if ($oFilter) {
|
||||
@@ -165,14 +166,13 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
return parent::GetAllowedValuesAsFilter($aArgs, $sContains, $iAdditionalValue);
|
||||
}
|
||||
|
||||
private function GetHierachicalFilter($aArgs = array(), $sContains = '', $iAdditionalValue = null)
|
||||
private function GetHierachicalFilter($aArgs = [], $sContains = '', $iAdditionalValue = null)
|
||||
{
|
||||
if (array_key_exists('this', $aArgs)) {
|
||||
// Hierarchical keys have one more constraint: the "parent value" cannot be
|
||||
// "under" themselves
|
||||
$iRootId = $aArgs['this']->GetKey();
|
||||
if ($iRootId > 0) // ignore objects that do no exist in the database...
|
||||
{
|
||||
if ($iRootId > 0) { // ignore objects that do no exist in the database...
|
||||
$sClass = $this->m_sTargetClass;
|
||||
|
||||
return DBObjectSearch::FromOQL("SELECT $sClass AS node JOIN $sClass AS root ON node.".$this->GetCode()." NOT BELOW root.id WHERE root.id = $iRootId");
|
||||
@@ -191,4 +191,4 @@ class AttributeHierarchicalKey extends AttributeExternalKey
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -40,6 +41,6 @@ class AttributeIPAddress extends AttributeString
|
||||
public function GetOrderBySQLExpressions($sClassAlias)
|
||||
{
|
||||
// Note: This is the responsibility of this function to place backticks around column aliases
|
||||
return array('INET_ATON(`'.$sClassAlias.$this->GetCode().'`)');
|
||||
return ['INET_ATON(`'.$sClassAlias.$this->GetCode().'`)'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -204,4 +205,4 @@ class AttributeImage extends AttributeBlob
|
||||
|
||||
return $oFormField;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ use utils;
|
||||
*/
|
||||
class AttributeInteger extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -59,7 +60,7 @@ class AttributeInteger extends AttributeDBField
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
"!=" => "differs from",
|
||||
"=" => "equals",
|
||||
">" => "greater (strict) than",
|
||||
@@ -67,7 +68,7 @@ class AttributeInteger extends AttributeDBField
|
||||
"<" => "less (strict) than",
|
||||
"<=" => "less than",
|
||||
"in" => "in",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -145,4 +146,4 @@ class AttributeInteger extends AttributeDBField
|
||||
|
||||
return $value; // supposed to be an int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -51,8 +52,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(),
|
||||
array("allowed_values", "depends_on", "linked_class", "ext_key_to_me", "count_min", "count_max"));
|
||||
return array_merge(
|
||||
parent::ListExpectedParams(),
|
||||
["allowed_values", "depends_on", "linked_class", "ext_key_to_me", "count_min", "count_max"]
|
||||
);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -228,7 +231,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -255,10 +258,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
{
|
||||
if (is_object($sValue) && ($sValue instanceof ormLinkSet)) {
|
||||
$sValue->Rewind();
|
||||
$aItems = array();
|
||||
$aItems = [];
|
||||
while ($oObj = $sValue->Fetch()) {
|
||||
// Show only relevant information (hide the external key to the current object)
|
||||
$aAttributes = array();
|
||||
$aAttributes = [];
|
||||
foreach (MetaModel::ListAttributeDefs($this->GetLinkedClass()) as $sAttCode => $oAttDef) {
|
||||
if ($sAttCode == $this->GetExtKeyToMe()) {
|
||||
continue;
|
||||
@@ -293,8 +296,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
$oLinkSetBlock = new BlockLinkSetDisplayAsProperty($this->GetCode(), $this, $sValue);
|
||||
|
||||
return ConsoleBlockRenderer::RenderBlockTemplates($oLinkSetBlock);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sMessage = "Error while displaying attribute {$this->GetCode()}";
|
||||
IssueLog::Error($sMessage, IssueLog::CHANNEL_DEFAULT, [
|
||||
'host_object_class' => $this->GetHostClass(),
|
||||
@@ -375,10 +377,13 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
$sSepItem = MetaModel::GetConfig()->Get('link_set_item_separator');
|
||||
$sSepAttribute = MetaModel::GetConfig()->Get('link_set_attribute_separator');
|
||||
$sSepValue = MetaModel::GetConfig()->Get('link_set_value_separator');
|
||||
@@ -386,11 +391,11 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
|
||||
if (is_object($sValue) && ($sValue instanceof ormLinkSet)) {
|
||||
$sValue->Rewind();
|
||||
$aItems = array();
|
||||
$aItems = [];
|
||||
while ($oObj = $sValue->Fetch()) {
|
||||
$sObjClass = get_class($oObj);
|
||||
// Show only relevant information (hide the external key to the current object)
|
||||
$aAttributes = array();
|
||||
$aAttributes = [];
|
||||
foreach (MetaModel::ListAttributeDefs($sObjClass) as $sAttCode => $oAttDef) {
|
||||
if ($sAttCode == 'finalclass') {
|
||||
if ($sObjClass == $this->GetLinkedClass()) {
|
||||
@@ -412,8 +417,11 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
}
|
||||
$sAttValue = $oObj->GetAsCSV($sAttCode, $sSepValue, '', $bLocalize);
|
||||
if (strlen($sAttValue) > 0) {
|
||||
$sAttributeData = str_replace($sAttributeQualifier, $sAttributeQualifier.$sAttributeQualifier,
|
||||
$sAttCode.$sSepValue.$sAttValue);
|
||||
$sAttributeData = str_replace(
|
||||
$sAttributeQualifier,
|
||||
$sAttributeQualifier.$sAttributeQualifier,
|
||||
$sAttCode.$sSepValue.$sAttValue
|
||||
);
|
||||
$aAttributes[] = $sAttributeQualifier.$sAttributeData.$sAttributeQualifier;
|
||||
}
|
||||
}
|
||||
@@ -435,10 +443,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
*/
|
||||
public function EnumTemplateVerbs()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'' => 'Plain text (unlocalized) representation',
|
||||
'html' => 'HTML representation (unordered list)',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +469,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
$oLinkSet = clone $value; // Workaround/Safety net for Trac #887
|
||||
$iLimit = MetaModel::GetConfig()->Get('max_linkset_output');
|
||||
$iCount = 0;
|
||||
$aNames = array();
|
||||
$aNames = [];
|
||||
foreach ($oLinkSet as $oItem) {
|
||||
if (($iLimit > 0) && ($iCount == $iLimit)) {
|
||||
$iTotal = $oLinkSet->Count();
|
||||
@@ -491,7 +499,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
|
||||
public function GetImportColumns()
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'MEDIUMTEXT'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
|
||||
return $aColumns;
|
||||
@@ -515,10 +523,13 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
* @throws Exception
|
||||
*/
|
||||
public function MakeValueFromString(
|
||||
$sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null,
|
||||
$sProposedValue,
|
||||
$bLocalizedValue = false,
|
||||
$sSepItem = null,
|
||||
$sSepAttribute = null,
|
||||
$sSepValue = null,
|
||||
$sAttributeQualifier = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (is_null($sSepItem) || empty($sSepItem)) {
|
||||
$sSepItem = MetaModel::GetConfig()->Get('link_set_item_separator');
|
||||
}
|
||||
@@ -539,16 +550,16 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
|
||||
$aInput = $oCSVParser->ToArray(0 /* do not skip lines */);
|
||||
|
||||
$aLinks = array();
|
||||
$aLinks = [];
|
||||
foreach ($aInput as $aRow) {
|
||||
// 1st - get the values, split the extkey->searchkey specs, and eventually get the finalclass value
|
||||
$aExtKeys = array();
|
||||
$aValues = array();
|
||||
$aExtKeys = [];
|
||||
$aValues = [];
|
||||
foreach ($aRow as $sCell) {
|
||||
$iSepPos = strpos($sCell, $sSepValue);
|
||||
if ($iSepPos === false) {
|
||||
// Houston...
|
||||
throw new CoreException('Wrong format for link attribute specification', array('value' => $sCell));
|
||||
throw new CoreException('Wrong format for link attribute specification', ['value' => $sCell]);
|
||||
}
|
||||
|
||||
$sAttCode = trim(substr($sCell, 0, $iSepPos));
|
||||
@@ -559,24 +570,36 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
$sRemoteAttCode = $aMatches[2];
|
||||
$aExtKeys[$sKeyAttCode][$sRemoteAttCode] = $sValue;
|
||||
if (!MetaModel::IsValidAttCode($sTargetClass, $sKeyAttCode)) {
|
||||
throw new CoreException('Wrong attribute code for link attribute specification',
|
||||
array('class' => $sTargetClass, 'attcode' => $sKeyAttCode));
|
||||
throw new CoreException(
|
||||
'Wrong attribute code for link attribute specification',
|
||||
['class' => $sTargetClass, 'attcode' => $sKeyAttCode]
|
||||
);
|
||||
}
|
||||
/** @var \AttributeExternalKey $oKeyAttDef */
|
||||
$oKeyAttDef = MetaModel::GetAttributeDef($sTargetClass, $sKeyAttCode);
|
||||
$sRemoteClass = $oKeyAttDef->GetTargetClass();
|
||||
if (!MetaModel::IsValidAttCode($sRemoteClass, $sRemoteAttCode)) {
|
||||
throw new CoreException('Wrong attribute code for link attribute specification',
|
||||
array('class' => $sRemoteClass, 'attcode' => $sRemoteAttCode));
|
||||
throw new CoreException(
|
||||
'Wrong attribute code for link attribute specification',
|
||||
['class' => $sRemoteClass, 'attcode' => $sRemoteAttCode]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!MetaModel::IsValidAttCode($sTargetClass, $sAttCode)) {
|
||||
throw new CoreException('Wrong attribute code for link attribute specification',
|
||||
array('class' => $sTargetClass, 'attcode' => $sAttCode));
|
||||
throw new CoreException(
|
||||
'Wrong attribute code for link attribute specification',
|
||||
['class' => $sTargetClass, 'attcode' => $sAttCode]
|
||||
);
|
||||
}
|
||||
$oAttDef = MetaModel::GetAttributeDef($sTargetClass, $sAttCode);
|
||||
$aValues[$sAttCode] = $oAttDef->MakeValueFromString($sValue, $bLocalizedValue, $sSepItem,
|
||||
$sSepAttribute, $sSepValue, $sAttributeQualifier);
|
||||
$aValues[$sAttCode] = $oAttDef->MakeValueFromString(
|
||||
$sValue,
|
||||
$bLocalizedValue,
|
||||
$sSepItem,
|
||||
$sSepAttribute,
|
||||
$sSepValue,
|
||||
$sAttributeQualifier
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,8 +607,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
if (isset($aValues['finalclass'])) {
|
||||
$sLinkClass = $aValues['finalclass'];
|
||||
if (!is_subclass_of($sLinkClass, $sTargetClass)) {
|
||||
throw new CoreException('Wrong class for link attribute specification',
|
||||
array('requested_class' => $sLinkClass, 'expected_class' => $sTargetClass));
|
||||
throw new CoreException(
|
||||
'Wrong class for link attribute specification',
|
||||
['requested_class' => $sLinkClass, 'expected_class' => $sTargetClass]
|
||||
);
|
||||
}
|
||||
} elseif (MetaModel::IsAbstract($sTargetClass)) {
|
||||
throw new CoreException('Missing finalclass for link attribute specification');
|
||||
@@ -603,7 +628,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
$oKeyAttDef = MetaModel::GetAttributeDef($sTargetClass, $sKeyAttCode);
|
||||
$sKeyClass = $oKeyAttDef->GetTargetClass();
|
||||
$oExtKeyFilter = new DBObjectSearch($sKeyClass);
|
||||
$aReconciliationDesc = array();
|
||||
$aReconciliationDesc = [];
|
||||
foreach ($aReconciliation as $sRemoteAttCode => $sValue) {
|
||||
$oExtKeyFilter->AddCondition($sRemoteAttCode, $sValue, '=');
|
||||
$aReconciliationDesc[] = "$sRemoteAttCode=$sValue";
|
||||
@@ -612,8 +637,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
switch ($oExtKeySet->Count()) {
|
||||
case 0:
|
||||
$sReconciliationDesc = implode(', ', $aReconciliationDesc);
|
||||
throw new CoreException("Found no match",
|
||||
array('ext_key' => $sKeyAttCode, 'reconciliation' => $sReconciliationDesc));
|
||||
throw new CoreException(
|
||||
"Found no match",
|
||||
['ext_key' => $sKeyAttCode, 'reconciliation' => $sReconciliationDesc]
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
$oRemoteObj = $oExtKeySet->Fetch();
|
||||
@@ -621,19 +648,23 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
break;
|
||||
default:
|
||||
$sReconciliationDesc = implode(', ', $aReconciliationDesc);
|
||||
throw new CoreException("Found several matches",
|
||||
array('ext_key' => $sKeyAttCode, 'reconciliation' => $sReconciliationDesc));
|
||||
// Found several matches, ambiguous
|
||||
throw new CoreException(
|
||||
"Found several matches",
|
||||
['ext_key' => $sKeyAttCode, 'reconciliation' => $sReconciliationDesc]
|
||||
);
|
||||
// Found several matches, ambiguous
|
||||
}
|
||||
}
|
||||
|
||||
// Check (roughly) if such a link is valid
|
||||
$aErrors = array();
|
||||
$aErrors = [];
|
||||
foreach (MetaModel::ListAttributeDefs($sTargetClass) as $sAttCode => $oAttDef) {
|
||||
if ($oAttDef->IsExternalKey()) {
|
||||
/** @var \AttributeExternalKey $oAttDef */
|
||||
if (($oAttDef->GetTargetClass() == $this->GetHostClass()) || (is_subclass_of($this->GetHostClass(),
|
||||
$oAttDef->GetTargetClass()))) {
|
||||
if (($oAttDef->GetTargetClass() == $this->GetHostClass()) || (is_subclass_of(
|
||||
$this->GetHostClass(),
|
||||
$oAttDef->GetTargetClass()
|
||||
))) {
|
||||
continue; // Don't check the key to self
|
||||
}
|
||||
}
|
||||
@@ -660,13 +691,13 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
*/
|
||||
public function GetForJSON($value)
|
||||
{
|
||||
$aRet = array();
|
||||
$aRet = [];
|
||||
if (is_object($value) && ($value instanceof ormLinkSet)) {
|
||||
$value->Rewind();
|
||||
while ($oObj = $value->Fetch()) {
|
||||
$sObjClass = get_class($oObj);
|
||||
// Show only relevant information (hide the external key to the current object)
|
||||
$aAttributes = array();
|
||||
$aAttributes = [];
|
||||
foreach (MetaModel::ListAttributeDefs($sObjClass) as $sAttCode => $oAttDef) {
|
||||
if ($sAttCode == 'finalclass') {
|
||||
if ($sObjClass == $this->GetLinkedClass()) {
|
||||
@@ -708,13 +739,15 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
{
|
||||
$sTargetClass = $this->Get('linked_class');
|
||||
|
||||
$aLinks = array();
|
||||
$aLinks = [];
|
||||
foreach ($json as $aValues) {
|
||||
if (isset($aValues['finalclass'])) {
|
||||
$sLinkClass = $aValues['finalclass'];
|
||||
if (!is_subclass_of($sLinkClass, $sTargetClass)) {
|
||||
throw new CoreException('Wrong class for link attribute specification',
|
||||
array('requested_class' => $sLinkClass, 'expected_class' => $sTargetClass));
|
||||
throw new CoreException(
|
||||
'Wrong class for link attribute specification',
|
||||
['requested_class' => $sLinkClass, 'expected_class' => $sTargetClass]
|
||||
);
|
||||
}
|
||||
} elseif (MetaModel::IsAbstract($sTargetClass)) {
|
||||
throw new CoreException('Missing finalclass for link attribute specification');
|
||||
@@ -728,12 +761,14 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
}
|
||||
|
||||
// Check (roughly) if such a link is valid
|
||||
$aErrors = array();
|
||||
$aErrors = [];
|
||||
foreach (MetaModel::ListAttributeDefs($sTargetClass) as $sAttCode => $oAttDef) {
|
||||
if ($oAttDef->IsExternalKey()) {
|
||||
/** @var AttributeExternalKey $oAttDef */
|
||||
if (($oAttDef->GetTargetClass() == $this->GetHostClass()) || (is_subclass_of($this->GetHostClass(),
|
||||
$oAttDef->GetTargetClass()))) {
|
||||
if (($oAttDef->GetTargetClass() == $this->GetHostClass()) || (is_subclass_of(
|
||||
$this->GetHostClass(),
|
||||
$oAttDef->GetTargetClass()
|
||||
))) {
|
||||
continue; // Don't check the key to self
|
||||
}
|
||||
}
|
||||
@@ -764,7 +799,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
{
|
||||
if ($proposedValue === null) {
|
||||
$sLinkedClass = $this->GetLinkedClass();
|
||||
$aLinkedObjectsArray = array();
|
||||
$aLinkedObjectsArray = [];
|
||||
$oSet = DBObjectSet::FromArray($sLinkedClass, $aLinkedObjectsArray);
|
||||
|
||||
return new ormLinkSet(
|
||||
@@ -848,10 +883,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
// - Adding friendlyname attribute to the list is not already in it
|
||||
$sTitleAttCode = MetaModel::GetFriendlyNameAttributeCode($sTargetClass);
|
||||
if (($sTitleAttCode !== null) && !in_array($sTitleAttCode, $aAttCodesToDisplay)) {
|
||||
$aAttCodesToDisplay = array_merge(array($sTitleAttCode), $aAttCodesToDisplay);
|
||||
$aAttCodesToDisplay = array_merge([$sTitleAttCode], $aAttCodesToDisplay);
|
||||
}
|
||||
// - Adding attribute properties
|
||||
$aAttributesToDisplay = array();
|
||||
$aAttributesToDisplay = [];
|
||||
foreach ($aAttCodesToDisplay as $sAttCodeToDisplay) {
|
||||
$oAttDefToDisplay = MetaModel::GetAttributeDef($sTargetClass, $sAttCodeToDisplay);
|
||||
$aAttributesToDisplay[$sAttCodeToDisplay] = [
|
||||
@@ -864,7 +899,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
// Append lnk attributes (filtered from zlist)
|
||||
if ($this->IsIndirect()) {
|
||||
$aLnkAttDefToDisplay = MetaModel::GetZListAttDefsFilteredForIndirectLinkClass($this->m_sHostClass, $this->m_sCode);
|
||||
$aLnkAttributesToDisplay = array();
|
||||
$aLnkAttributesToDisplay = [];
|
||||
foreach ($aLnkAttDefToDisplay as $oLnkAttDefToDisplay) {
|
||||
$aLnkAttributesToDisplay[$oLnkAttDefToDisplay->GetCode()] = [
|
||||
'att_code' => $oLnkAttDefToDisplay->GetCode(),
|
||||
@@ -930,11 +965,10 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
} else {
|
||||
return $sDefault;
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
ExceptionLog::LogException($e);
|
||||
|
||||
return $sDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -36,7 +37,7 @@ class AttributeLinkedSetIndirect extends AttributeLinkedSet
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("ext_key_to_remote"));
|
||||
return array_merge(parent::ListExpectedParams(), ["ext_key_to_remote"]);
|
||||
}
|
||||
|
||||
public function IsIndirect()
|
||||
@@ -61,8 +62,10 @@ class AttributeLinkedSetIndirect extends AttributeLinkedSet
|
||||
|
||||
public function GetTrackingLevel()
|
||||
{
|
||||
return $this->GetOptional('tracking_level',
|
||||
MetaModel::GetConfig()->Get('tracking_level_linked_set_indirect_default'));
|
||||
return $this->GetOptional(
|
||||
'tracking_level',
|
||||
MetaModel::GetConfig()->Get('tracking_level_linked_set_indirect_default')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,4 +106,4 @@ class AttributeLinkedSetIndirect extends AttributeLinkedSet
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -53,4 +54,4 @@ class AttributeLongText extends AttributeText
|
||||
? CMDBChangeOpSetAttributeHTML::class
|
||||
: CMDBChangeOpSetAttributeLongText::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -37,7 +38,7 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array('allowed_values', 'sql', 'default_value', 'mapping');
|
||||
return ['allowed_values', 'sql', 'default_value', 'mapping'];
|
||||
}
|
||||
|
||||
public function IsNullAllowed()
|
||||
@@ -62,9 +63,9 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
}
|
||||
$aMappingData = $this->GetMapRule($sClass);
|
||||
if ($aMappingData == null) {
|
||||
$aRet = array();
|
||||
$aRet = [];
|
||||
} else {
|
||||
$aRet = array($aMappingData['attcode']);
|
||||
$aRet = [$aMappingData['attcode']];
|
||||
}
|
||||
|
||||
return $aRet;
|
||||
@@ -78,7 +79,7 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$oValSetDef = $this->GetValuesDef();
|
||||
if (!$oValSetDef) {
|
||||
@@ -89,7 +90,7 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
if (is_null($aRawValues)) {
|
||||
return null;
|
||||
}
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($aRawValues as $sKey => $sValue) {
|
||||
$aLocalizedValues[$sKey] = $this->GetValueLabel($sKey);
|
||||
}
|
||||
@@ -119,8 +120,10 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
} elseif ($this->GetDefaultValue() != '') {
|
||||
$sRet = $this->GetDefaultValue();
|
||||
} else {
|
||||
throw new Exception('AttributeMetaEnum::MapValue(): mapping not found for value "'.$value.'" in '.get_class($oObject).', on attribute '.MetaModel::GetAttributeOrigin($this->GetHostClass(),
|
||||
$this->GetCode()).'::'.$this->GetCode());
|
||||
throw new Exception('AttributeMetaEnum::MapValue(): mapping not found for value "'.$value.'" in '.get_class($oObject).', on attribute '.MetaModel::GetAttributeOrigin(
|
||||
$this->GetHostClass(),
|
||||
$this->GetCode()
|
||||
).'::'.$this->GetCode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,4 +146,4 @@ class AttributeMetaEnum extends AttributeEnum
|
||||
|
||||
return $aMappingData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Exception;
|
||||
*/
|
||||
class AttributeOQL extends AttributeText
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -38,4 +39,4 @@ class AttributeOQL extends AttributeText
|
||||
{
|
||||
return "OQLExpression";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ use MetaModel;
|
||||
*/
|
||||
class AttributeObjectKey extends AttributeDBFieldVoid
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_EXTERNAL_KEY;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -38,7 +39,7 @@ class AttributeObjectKey extends AttributeDBFieldVoid
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('class_attcode', 'is_null_allowed'));
|
||||
return array_merge(parent::ListExpectedParams(), ['class_attcode', 'is_null_allowed']);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -61,7 +62,6 @@ class AttributeObjectKey extends AttributeDBFieldVoid
|
||||
return $this->Get("is_null_allowed");
|
||||
}
|
||||
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return parent::GetBasicFilterOperators();
|
||||
@@ -114,4 +114,4 @@ class AttributeObjectKey extends AttributeDBFieldVoid
|
||||
|
||||
return (int)$proposedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -41,4 +42,4 @@ class AttributeObsolescenceDate extends AttributeDate
|
||||
|
||||
return parent::GetDescription($sDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -14,13 +15,13 @@ class AttributeObsolescenceFlag extends AttributeBoolean
|
||||
{
|
||||
public function __construct($sCode)
|
||||
{
|
||||
parent::__construct($sCode, array(
|
||||
parent::__construct($sCode, [
|
||||
"allowed_values" => null,
|
||||
"sql" => $sCode,
|
||||
"default_value" => "",
|
||||
"is_null_allowed" => false,
|
||||
"depends_on" => array(),
|
||||
));
|
||||
"depends_on" => [],
|
||||
]);
|
||||
}
|
||||
|
||||
public function IsWritable()
|
||||
@@ -56,17 +57,17 @@ class AttributeObsolescenceFlag extends AttributeBoolean
|
||||
|
||||
public function GetSQLExpressions($sPrefix = '')
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
} // returns column/spec pairs (1 in most of the cases), for STRUCTURING (DB creation)
|
||||
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
} // returns column/value pairs (1 in most of the cases), for WRITING (Insert, Update)
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -82,7 +83,7 @@ class AttributeObsolescenceFlag extends AttributeBoolean
|
||||
public function GetPrerequisiteAttributes($sClass = null)
|
||||
{
|
||||
// Code duplicated with AttributeFriendlyName
|
||||
$aAttributes = $this->GetOptional("depends_on", array());
|
||||
$aAttributes = $this->GetOptional("depends_on", []);
|
||||
$oExpression = $this->GetOQLExpression();
|
||||
foreach ($oExpression->ListRequiredFields() as $sClass => $sAttCode) {
|
||||
if (!in_array($sAttCode, $aAttributes)) {
|
||||
@@ -131,4 +132,4 @@ class AttributeObsolescenceFlag extends AttributeBoolean
|
||||
|
||||
return parent::GetDescription($sDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,7 +20,7 @@ use utils;
|
||||
*/
|
||||
class AttributeOneWayPassword extends AttributeDefinition implements iAttributeNoGroupBy
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -40,7 +41,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array("depends_on"));
|
||||
return array_merge(parent::ListExpectedParams(), ["depends_on"]);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -92,7 +93,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
if ($sPrefix == '') {
|
||||
$sPrefix = $this->GetCode(); // Warning: AttributeOneWayPassword does not have any sql property so code = sql !
|
||||
}
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $sPrefix.'_hash';
|
||||
$aColumns['_salt'] = $sPrefix.'_salt';
|
||||
@@ -128,11 +129,11 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
// We will have to remove the blobs from the list of attributes when doing the select
|
||||
// then the use of Get() should finalize the load
|
||||
if ($value instanceof ormPassword) {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode().'_hash'] = $value->GetHash();
|
||||
$aValues[$this->GetCode().'_salt'] = $value->GetSalt();
|
||||
} else {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode().'_hash'] = '';
|
||||
$aValues[$this->GetCode().'_salt'] = '';
|
||||
}
|
||||
@@ -142,7 +143,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode().'_hash'] = 'TINYBLOB';
|
||||
$aColumns[$this->GetCode().'_salt'] = 'TINYBLOB';
|
||||
|
||||
@@ -151,7 +152,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
|
||||
public function GetImportColumns()
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode()] = 'TINYTEXT'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
|
||||
return $aColumns;
|
||||
@@ -173,7 +174,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -196,10 +197,13 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ''; // Not exportable in CSV
|
||||
}
|
||||
|
||||
@@ -244,4 +248,4 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
{
|
||||
return CMDBChangeOpSetAttributeOneWayPassword::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,7 +18,7 @@ use utils;
|
||||
*/
|
||||
class AttributePassword extends AttributeString implements iAttributeNoGroupBy
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -72,4 +73,4 @@ class AttributePassword extends AttributeString implements iAttributeNoGroupBy
|
||||
{
|
||||
return false;
|
||||
} // Cannot reliably compare two encrypted passwords since the same password will be encrypted in diffferent manners depending on the random 'salt'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Exception;
|
||||
*/
|
||||
class AttributePercentage extends AttributeInteger
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_NUMERIC;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -58,4 +59,4 @@ class AttributePercentage extends AttributeInteger
|
||||
|
||||
return "<div style=\"width:{$iWidth}em;-moz-border-radius: 3px;-webkit-border-radius: 3px;border-radius: 3px;display:inline-block;border: 1px #ccc solid;\"><div style=\"width:{$iPercentWidth}em; display:inline-block;background-color:$sColor;\"> </div></div> $sValue %";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -35,8 +36,10 @@ class AttributePhoneNumber extends AttributeString
|
||||
|
||||
public function GetValidationPattern()
|
||||
{
|
||||
return $this->GetOptional('validation_pattern',
|
||||
'^'.utils::GetConfig()->Get('phone_number_validation_pattern').'$');
|
||||
return $this->GetOptional(
|
||||
'validation_pattern',
|
||||
'^'.utils::GetConfig()->Get('phone_number_validation_pattern').'$'
|
||||
);
|
||||
}
|
||||
|
||||
public static function GetFormFieldClass()
|
||||
@@ -57,4 +60,4 @@ class AttributePhoneNumber extends AttributeString
|
||||
return '<a class="tel" href="'.$sUrl.'"><span class="text_decoration '.$sUrlDecorationClass.'"></span>'.parent::GetAsHTML($sValue).'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -38,7 +39,7 @@ class AttributePropertySet extends AttributeTable
|
||||
public function MakeRealValue($proposedValue, $oHostObj)
|
||||
{
|
||||
if (!is_array($proposedValue)) {
|
||||
return array('?' => (string)$proposedValue);
|
||||
return ['?' => (string)$proposedValue];
|
||||
}
|
||||
|
||||
return $proposedValue;
|
||||
@@ -47,7 +48,7 @@ class AttributePropertySet extends AttributeTable
|
||||
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
throw new CoreException('Expecting an array', array('found' => get_class($value)));
|
||||
throw new CoreException('Expecting an array', ['found' => get_class($value)]);
|
||||
}
|
||||
if (count($value) == 0) {
|
||||
return "";
|
||||
@@ -71,27 +72,30 @@ class AttributePropertySet extends AttributeTable
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
if (!is_array($value) || count($value) == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$aRes = array();
|
||||
$aRes = [];
|
||||
foreach ($value as $sProperty => $sValue) {
|
||||
if ($sProperty == 'auth_pwd') {
|
||||
$sValue = '*****';
|
||||
}
|
||||
$sFrom = array(',', '=');
|
||||
$sTo = array('\,', '\=');
|
||||
$sFrom = [',', '='];
|
||||
$sTo = ['\,', '\='];
|
||||
$aRes[] = $sProperty.'='.str_replace($sFrom, $sTo, (string)$sValue);
|
||||
}
|
||||
$sRaw = implode(',', $aRes);
|
||||
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, $sRaw);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
@@ -115,4 +119,4 @@ class AttributePropertySet extends AttributeTable
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,7 +20,7 @@ use utils;
|
||||
|
||||
class AttributeQueryAttCodeSet extends AttributeSet
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
public function __construct($sCode, array $aParams)
|
||||
{
|
||||
@@ -29,7 +30,7 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('query_field'));
|
||||
return array_merge(parent::ListExpectedParams(), ['query_field']);
|
||||
}
|
||||
|
||||
protected function GetSQLCol($bFullSpec = false)
|
||||
@@ -55,28 +56,27 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
$sQueryField = $this->Get('query_field');
|
||||
$sQuery = $oHostObj->Get($sQueryField);
|
||||
if (empty($sQuery)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
$oFilter = DBSearch::FromOQL($sQuery);
|
||||
|
||||
return $oFilter->GetSelectedClasses();
|
||||
|
||||
}
|
||||
catch (OQLException $e) {
|
||||
} catch (OQLException $e) {
|
||||
IssueLog::Warning($e->getMessage());
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
if (isset($aArgs['this'])) {
|
||||
$oHostObj = $aArgs['this'];
|
||||
$aClasses = $this->GetClassList($oHostObj);
|
||||
|
||||
$aAllowedAttributes = array();
|
||||
$aAllAttributes = array();
|
||||
$aAllowedAttributes = [];
|
||||
$aAllAttributes = [];
|
||||
|
||||
if ((count($aClasses) == 1) && (array_keys($aClasses)[0] == array_values($aClasses)[0])) {
|
||||
$sClass = reset($aClasses);
|
||||
@@ -90,7 +90,7 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
foreach ($aClasses as $sAlias => $sClass) {
|
||||
$aAttributes = MetaModel::GetAttributesList($sClass);
|
||||
foreach ($aAttributes as $sAttCode) {
|
||||
$aAllAttributes[] = array('alias' => $sAlias, 'class' => $sClass, 'att_code' => $sAttCode);
|
||||
$aAllAttributes[] = ['alias' => $sAlias, 'class' => $sClass, 'att_code' => $sAttCode];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,16 +125,16 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
public function MakeRealValue($proposedValue, $oHostObj, $bIgnoreErrors = false)
|
||||
{
|
||||
$oSet = new ormSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
|
||||
$aArgs = array();
|
||||
$aArgs = [];
|
||||
if (!empty($oHostObj)) {
|
||||
$aArgs['this'] = $oHostObj;
|
||||
}
|
||||
$aAllowedAttributes = $this->GetAllowedValues($aArgs);
|
||||
$aInvalidAttCodes = array();
|
||||
$aInvalidAttCodes = [];
|
||||
if (is_string($proposedValue) && !empty($proposedValue)) {
|
||||
$proposedValue = trim($proposedValue);
|
||||
$aProposedValues = $this->FromStringToArray($proposedValue);
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
foreach ($aProposedValues as $sValue) {
|
||||
$sAttCode = trim($sValue);
|
||||
if (empty($aAllowedAttributes) || isset($aAllowedAttributes[$sAttCode])) {
|
||||
@@ -174,7 +174,7 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
$aArgs['this'] = $oHostObject;
|
||||
$aAllowedAttributes = $this->GetAllowedValues($aArgs);
|
||||
|
||||
$aLocalizedValues = array();
|
||||
$aLocalizedValues = [];
|
||||
foreach ($value as $sAttCode) {
|
||||
if (isset($aAllowedAttributes[$sAttCode])) {
|
||||
$sLabelForHtmlAttribute = utils::HtmlEntities($aAllowedAttributes[$sAttCode]);
|
||||
@@ -188,4 +188,4 @@ class AttributeQueryAttCodeSet extends AttributeSet
|
||||
|
||||
return '<span class="'.implode(' ', $this->aCSSClasses).'">'.$value.'</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -26,7 +27,7 @@ use utils;
|
||||
*/
|
||||
class AttributeRedundancySettings extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -47,7 +48,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'sql',
|
||||
'relation_code',
|
||||
'from_class',
|
||||
@@ -57,7 +58,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
'min_up',
|
||||
'min_up_type',
|
||||
'min_up_mode',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function GetValuesDef()
|
||||
@@ -67,7 +68,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
|
||||
public function GetPrerequisiteAttributes($sClass = null)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -82,7 +83,6 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
.($bFullSpec ? $this->GetSQLColSpec() : '');
|
||||
}
|
||||
|
||||
|
||||
public function GetValidationPattern()
|
||||
{
|
||||
return "^[0-9]{1,3}|[0-9]{1,2}%|disabled$";
|
||||
@@ -99,8 +99,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
if ($this->Get('enabled')) {
|
||||
if ($this->Get('min_up_type') == 'count') {
|
||||
$sRet = (string)$this->Get('min_up');
|
||||
} else // percent
|
||||
{
|
||||
} else { // percent
|
||||
$sRet = $this->Get('min_up').'%';
|
||||
}
|
||||
}
|
||||
@@ -135,12 +134,12 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
public function ScalarToSQL($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
throw new CoreException('Expected the attribute value to be a string', array(
|
||||
throw new CoreException('Expected the attribute value to be a string', [
|
||||
'found_type' => gettype($value),
|
||||
'value' => $value,
|
||||
'class' => $this->GetHostClass(),
|
||||
'attribute' => $this->GetCode(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -148,8 +147,11 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
|
||||
public function GetRelationQueryData()
|
||||
{
|
||||
foreach (MetaModel::EnumRelationQueries($this->GetHostClass(), $this->Get('relation_code'),
|
||||
false) as $sDummy => $aQueryInfo) {
|
||||
foreach (MetaModel::EnumRelationQueries(
|
||||
$this->GetHostClass(),
|
||||
$this->Get('relation_code'),
|
||||
false
|
||||
) as $sDummy => $aQueryInfo) {
|
||||
if ($aQueryInfo['sFromClass'] == $this->Get('from_class')) {
|
||||
if ($aQueryInfo['sNeighbour'] == $this->Get('neighbour_id')) {
|
||||
return $aQueryInfo;
|
||||
@@ -157,7 +159,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,17 +202,23 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
$sCurrentOption = $this->GetCurrentOption($sValue);
|
||||
$sClass = $oHostObject ? get_class($oHostObject) : $this->m_sHostClass;
|
||||
|
||||
return sprintf($this->GetUserOptionFormat($sCurrentOption), $this->GetMinUpValue($sValue),
|
||||
MetaModel::GetName($sClass));
|
||||
return sprintf(
|
||||
$this->GetUserOptionFormat($sCurrentOption),
|
||||
$this->GetMinUpValue($sValue),
|
||||
MetaModel::GetName($sClass)
|
||||
);
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
) {
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
@@ -305,24 +313,30 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
foreach ($aUserOptions as $sUserOption) {
|
||||
$bSelected = ($sUserOption == $sCurrentOption);
|
||||
$sRet .= '<div>';
|
||||
$sRet .= $this->GetDisplayOption($sCurrentValue, $oPage, $sFormPrefix, $bEditOption, $sUserOption,
|
||||
$bSelected);
|
||||
$sRet .= $this->GetDisplayOption(
|
||||
$sCurrentValue,
|
||||
$oPage,
|
||||
$sFormPrefix,
|
||||
$bEditOption,
|
||||
$sUserOption,
|
||||
$bSelected
|
||||
);
|
||||
$sRet .= '</div>';
|
||||
}
|
||||
|
||||
return $sRet;
|
||||
}
|
||||
|
||||
const USER_OPTION_DISABLED = 'disabled';
|
||||
const USER_OPTION_ENABLED_COUNT = 'count';
|
||||
const USER_OPTION_ENABLED_PERCENT = 'percent';
|
||||
public const USER_OPTION_DISABLED = 'disabled';
|
||||
public const USER_OPTION_ENABLED_COUNT = 'count';
|
||||
public const USER_OPTION_ENABLED_PERCENT = 'percent';
|
||||
|
||||
/**
|
||||
* Depending on the xxx_mode parameters, build the list of options that are allowed to the end-user
|
||||
*/
|
||||
protected function GetUserOptions($sValue)
|
||||
{
|
||||
$aRet = array();
|
||||
$aRet = [];
|
||||
if ($this->Get('enabled_mode') == 'user') {
|
||||
$aRet[] = self::USER_OPTION_DISABLED;
|
||||
}
|
||||
@@ -374,9 +388,13 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function GetDisplayOption(
|
||||
$sCurrentValue, $oPage, $sFormPrefix, $bEditMode, $sUserOption, $bSelected = true
|
||||
)
|
||||
{
|
||||
$sCurrentValue,
|
||||
$oPage,
|
||||
$sFormPrefix,
|
||||
$bEditMode,
|
||||
$sUserOption,
|
||||
$bSelected = true
|
||||
) {
|
||||
$sRet = '';
|
||||
|
||||
$iCurrentValue = $this->GetMinUpValue($sCurrentValue);
|
||||
@@ -412,8 +430,11 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
}
|
||||
break;
|
||||
}
|
||||
$sLabel = sprintf($this->GetUserOptionFormat($sUserOption), $sValue,
|
||||
MetaModel::GetName($this->GetHostClass()));
|
||||
$sLabel = sprintf(
|
||||
$this->GetUserOptionFormat($sUserOption),
|
||||
$sValue,
|
||||
MetaModel::GetName($this->GetHostClass())
|
||||
);
|
||||
|
||||
$sOptionName = $sHtmlNamesPrefix.'_user_option';
|
||||
$sOptionId = $sOptionName.'_'.$sUserOption;
|
||||
@@ -422,8 +443,11 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
} else {
|
||||
// Read-only: display only the currently selected option
|
||||
if ($bSelected) {
|
||||
$sRet = sprintf($this->GetUserOptionFormat($sUserOption), $iCurrentValue,
|
||||
MetaModel::GetName($this->GetHostClass()));
|
||||
$sRet = sprintf(
|
||||
$this->GetUserOptionFormat($sUserOption),
|
||||
$iCurrentValue,
|
||||
MetaModel::GetName($this->GetHostClass())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,4 +481,4 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
|
||||
return $sRet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -27,8 +28,8 @@ use utils;
|
||||
*/
|
||||
abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
const EDITABLE_INPUT_ID_SUFFIX = '-setwidget-values'; // used client side, see js/jquery.itop-set-widget.js
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const EDITABLE_INPUT_ID_SUFFIX = '-setwidget-values'; // used client side, see js/jquery.itop-set-widget.js
|
||||
protected $bDisplayLink; // Display search link in readonly mode
|
||||
|
||||
public function __construct($sCode, array $aParams)
|
||||
@@ -48,7 +49,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('is_null_allowed', 'max_items'));
|
||||
return array_merge(parent::ListExpectedParams(), ['is_null_allowed', 'max_items']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function GetPossibleValues($aArgs = array(), $sContains = '')
|
||||
public function GetPossibleValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
return $this->GetAllowedValues($aArgs, $sContains);
|
||||
}
|
||||
@@ -75,13 +76,13 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function GetJsonForWidget($oValue, $aArgs = array())
|
||||
public function GetJsonForWidget($oValue, $aArgs = [])
|
||||
{
|
||||
$aJson = array();
|
||||
$aJson = [];
|
||||
|
||||
// possible_values
|
||||
$aAllowedValues = $this->GetPossibleValues($aArgs);
|
||||
$aSetKeyValData = array();
|
||||
$aSetKeyValData = [];
|
||||
foreach ($aAllowedValues as $sCode => $sLabel) {
|
||||
$aSetKeyValData[] = [
|
||||
'code' => $sCode,
|
||||
@@ -89,10 +90,10 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
];
|
||||
}
|
||||
$aJson['possible_values'] = $aSetKeyValData;
|
||||
$aRemoved = array();
|
||||
$aRemoved = [];
|
||||
if (is_null($oValue)) {
|
||||
$aJson['partial_values'] = array();
|
||||
$aJson['orig_value'] = array();
|
||||
$aJson['partial_values'] = [];
|
||||
$aJson['orig_value'] = [];
|
||||
} else {
|
||||
$aPartialValues = $oValue->GetModified();
|
||||
foreach ($aPartialValues as $key => $value) {
|
||||
@@ -111,7 +112,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
}
|
||||
$aJson['orig_value'] = array_values($aOrigValues);
|
||||
}
|
||||
$aJson['added'] = array();
|
||||
$aJson['added'] = [];
|
||||
$aJson['removed'] = $aRemoved;
|
||||
|
||||
$iMaxTags = $this->GetMaxItems();
|
||||
@@ -176,7 +177,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
|
||||
public function FromStringToArray($proposedValue, $sDefaultSepItem = ',')
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
if (!empty($proposedValue)) {
|
||||
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
|
||||
// convert also , separated strings
|
||||
@@ -466,7 +467,8 @@ HTML;
|
||||
{
|
||||
/** @var \ormSet $original */
|
||||
/** @var \ormSet $value */
|
||||
parent::RecordAttChange($oObject,
|
||||
parent::RecordAttChange(
|
||||
$oObject,
|
||||
implode(' ', $original->GetValues()),
|
||||
implode(' ', $value->GetValues())
|
||||
);
|
||||
@@ -476,4 +478,4 @@ HTML;
|
||||
{
|
||||
return CMDBChangeOpSetAttributeTagSet::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -23,7 +24,7 @@ use Str;
|
||||
*/
|
||||
class AttributeStopWatch extends AttributeDefinition
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -45,8 +46,10 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
// The list of thresholds must be an array of iPercent => array of 'option' => value
|
||||
return array_merge(parent::ListExpectedParams(),
|
||||
array("states", "goal_computing", "working_time_computing", "thresholds"));
|
||||
return array_merge(
|
||||
parent::ListExpectedParams(),
|
||||
["states", "goal_computing", "working_time_computing", "thresholds"]
|
||||
);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
@@ -124,7 +127,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
if ($sPrefix == '') {
|
||||
$sPrefix = $this->GetCode(); // Warning: a stopwatch does not have any 'sql' property, so its SQL column is equal to its attribute code !!
|
||||
}
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $sPrefix.'_timespent';
|
||||
$aColumns['_started'] = $sPrefix.'_started';
|
||||
@@ -163,7 +166,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
|
||||
public function FromSQLToValue($aCols, $sPrefix = '')
|
||||
{
|
||||
$aExpectedCols = array($sPrefix, $sPrefix.'_started', $sPrefix.'_laststart', $sPrefix.'_stopped');
|
||||
$aExpectedCols = [$sPrefix, $sPrefix.'_started', $sPrefix.'_laststart', $sPrefix.'_stopped'];
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo) {
|
||||
$sThPrefix = '_'.$iThreshold;
|
||||
$aExpectedCols[] = $sPrefix.$sThPrefix.'_deadline';
|
||||
@@ -203,7 +206,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
if ($value instanceof ormStopWatch) {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode().'_timespent'] = $value->GetTimeSpent();
|
||||
$aValues[$this->GetCode().'_started'] = self::SecondsToDate($value->GetStartDate());
|
||||
$aValues[$this->GetCode().'_laststart'] = self::SecondsToDate($value->GetLastStartDate());
|
||||
@@ -217,7 +220,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
$aValues[$sPrefix.'_overrun'] = $value->GetOverrun($iThreshold);
|
||||
}
|
||||
} else {
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->GetCode().'_timespent'] = '';
|
||||
$aValues[$this->GetCode().'_started'] = '';
|
||||
$aValues[$this->GetCode().'_laststart'] = '';
|
||||
@@ -229,7 +232,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->GetCode().'_timespent'] = 'INT(11) UNSIGNED';
|
||||
$aColumns[$this->GetCode().'_started'] = 'DATETIME';
|
||||
$aColumns[$this->GetCode().'_laststart'] = 'DATETIME';
|
||||
@@ -265,7 +268,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -305,10 +308,13 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
* @return string
|
||||
*/
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
return $value->GetTimeSpent();
|
||||
}
|
||||
|
||||
@@ -353,13 +359,13 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
$sPrefix = $this->GetCode();
|
||||
switch ($sItemCode) {
|
||||
case 'timespent':
|
||||
return array('' => $sPrefix.'_timespent');
|
||||
return ['' => $sPrefix.'_timespent'];
|
||||
case 'started':
|
||||
return array('' => $sPrefix.'_started');
|
||||
return ['' => $sPrefix.'_started'];
|
||||
case 'laststart':
|
||||
return array('' => $sPrefix.'_laststart');
|
||||
return ['' => $sPrefix.'_laststart'];
|
||||
case 'stopped':
|
||||
return array('' => $sPrefix.'_stopped');
|
||||
return ['' => $sPrefix.'_stopped'];
|
||||
}
|
||||
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo) {
|
||||
@@ -369,13 +375,13 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
$sThresholdCode = substr($sItemCode, strlen($sThPrefix));
|
||||
switch ($sThresholdCode) {
|
||||
case 'deadline':
|
||||
return array('' => $sPrefix.'_'.$iThreshold.'_deadline');
|
||||
return ['' => $sPrefix.'_'.$iThreshold.'_deadline'];
|
||||
case 'passed':
|
||||
return array('' => $sPrefix.'_'.$iThreshold.'_passed');
|
||||
return ['' => $sPrefix.'_'.$iThreshold.'_passed'];
|
||||
case 'triggered':
|
||||
return array('' => $sPrefix.'_'.$iThreshold.'_triggered');
|
||||
return ['' => $sPrefix.'_'.$iThreshold.'_triggered'];
|
||||
case 'overrun':
|
||||
return array('' => $sPrefix.'_'.$iThreshold.'_overrun');
|
||||
return ['' => $sPrefix.'_'.$iThreshold.'_overrun'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,7 +431,6 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
throw new CoreException("Unknown item code '$sItemCode' for attribute ".$this->GetHostClass().'::'.$this->GetCode());
|
||||
}
|
||||
|
||||
|
||||
public function GetSubItemSearchType($sItemCode)
|
||||
{
|
||||
switch ($sItemCode) {
|
||||
@@ -457,7 +462,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
return static::SEARCH_WIDGET_TYPE_RAW;
|
||||
}
|
||||
|
||||
public function GetSubItemAllowedValues($sItemCode, $aArgs = array(), $sContains = '')
|
||||
public function GetSubItemAllowedValues($sItemCode, $aArgs = [], $sContains = '')
|
||||
{
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo) {
|
||||
$sThPrefix = $iThreshold.'_';
|
||||
@@ -467,10 +472,10 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
switch ($sThresholdCode) {
|
||||
case 'passed':
|
||||
case 'triggered':
|
||||
return array(
|
||||
return [
|
||||
0 => $this->GetBooleanLabel(0),
|
||||
1 => $this->GetBooleanLabel(1),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,8 +529,10 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
$sThresholdCode = substr($sItemCode, strlen($sThPrefix));
|
||||
switch ($sThresholdCode) {
|
||||
case 'deadline':
|
||||
$sHtml = (int)$sValue ? date((string)AttributeDateTime::GetFormat(),
|
||||
(int)$sValue) : null;
|
||||
$sHtml = (int)$sValue ? date(
|
||||
(string)AttributeDateTime::GetFormat(),
|
||||
(int)$sValue
|
||||
) : null;
|
||||
break;
|
||||
case 'passed':
|
||||
case 'triggered':
|
||||
@@ -648,11 +655,14 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
}
|
||||
|
||||
public function GetSubItemAsCSV(
|
||||
$sItemCode, $value, $sSeparator = ',', $sTextQualifier = '"', $bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sItemCode,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$bConvertToPlainText = false
|
||||
) {
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$value);
|
||||
$sRet = $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
|
||||
@@ -821,4 +831,4 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,7 +20,7 @@ use utils;
|
||||
*/
|
||||
class AttributeString extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -85,7 +86,7 @@ class AttributeString extends AttributeDBField
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
"=" => "equals",
|
||||
"!=" => "differs from",
|
||||
"Like" => "equals (no case)",
|
||||
@@ -93,7 +94,7 @@ class AttributeString extends AttributeDBField
|
||||
"Contains" => "contains",
|
||||
"Begins with" => "begins with",
|
||||
"Finishes with" => "finishes with",
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -152,24 +153,27 @@ class AttributeString extends AttributeDBField
|
||||
public function ScalarToSQL($value)
|
||||
{
|
||||
if (!is_string($value) && !is_null($value)) {
|
||||
throw new CoreWarning('Expected the attribute value to be a string', array(
|
||||
throw new CoreWarning('Expected the attribute value to be a string', [
|
||||
'found_type' => gettype($value),
|
||||
'value' => $value,
|
||||
'class' => $this->GetHostClass(),
|
||||
'attribute' => $this->GetCode(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
) {
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
@@ -196,4 +200,4 @@ class AttributeString extends AttributeDBField
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -52,7 +53,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
return $oParent->GetSubItemSearchType($this->Get('item_code'));
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
/** @var AttributeStopWatch $oParent */
|
||||
$oParent = $this->GetTargetAttDef();
|
||||
@@ -72,7 +73,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('target_attcode', 'item_code'));
|
||||
return array_merge(parent::ListExpectedParams(), ['target_attcode', 'item_code']);
|
||||
}
|
||||
|
||||
public function GetParentAttCode()
|
||||
@@ -121,7 +122,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
return null;
|
||||
}
|
||||
|
||||
// public function IsNullAllowed() {return false;}
|
||||
// public function IsNullAllowed() {return false;}
|
||||
|
||||
public static function LoadInObject()
|
||||
{
|
||||
@@ -147,7 +148,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
}
|
||||
|
||||
//
|
||||
// protected function ScalarToSQL($value) {return $value;} // format value as a valuable SQL literal (quoted outside)
|
||||
// protected function ScalarToSQL($value) {return $value;} // format value as a valuable SQL literal (quoted outside)
|
||||
|
||||
public function FromSQLToValue($aCols, $sPrefix = '')
|
||||
{
|
||||
@@ -155,12 +156,12 @@ class AttributeSubItem extends AttributeDefinition
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function GetBasicFilterLooseOperator()
|
||||
@@ -214,13 +215,21 @@ class AttributeSubItem extends AttributeDefinition
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$value,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
$oParent = $this->GetTargetAttDef();
|
||||
$res = $oParent->GetSubItemAsCSV($this->Get('item_code'), $value, $sSeparator, $sTextQualifier,
|
||||
$bConvertToPlainText);
|
||||
$res = $oParent->GetSubItemAsCSV(
|
||||
$this->Get('item_code'),
|
||||
$value,
|
||||
$sSeparator,
|
||||
$sTextQualifier,
|
||||
$bConvertToPlainText
|
||||
);
|
||||
|
||||
return $res;
|
||||
}
|
||||
@@ -270,4 +279,4 @@ class AttributeSubItem extends AttributeDefinition
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -13,7 +14,7 @@ use Str;
|
||||
|
||||
class AttributeTable extends AttributeDBField
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_RAW;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -49,7 +50,7 @@ class AttributeTable extends AttributeDBField
|
||||
|
||||
public function GetNullValue()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function IsNull($proposedValue)
|
||||
@@ -65,7 +66,6 @@ class AttributeTable extends AttributeDBField
|
||||
return count($proposedValue) > 0;
|
||||
}
|
||||
|
||||
|
||||
public function GetEditValue($sValue, $oHostObj = null)
|
||||
{
|
||||
return '';
|
||||
@@ -75,10 +75,10 @@ class AttributeTable extends AttributeDBField
|
||||
public function MakeRealValue($proposedValue, $oHostObj)
|
||||
{
|
||||
if (is_null($proposedValue)) {
|
||||
return array();
|
||||
return [];
|
||||
} else {
|
||||
if (!is_array($proposedValue)) {
|
||||
return array(0 => array(0 => $proposedValue));
|
||||
return [0 => [0 => $proposedValue]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,7 @@ class AttributeTable extends AttributeDBField
|
||||
if ($value === false) {
|
||||
$value = $this->MakeRealValue($aCols[$sPrefix.''], null);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$value = $this->MakeRealValue($aCols[$sPrefix.''], null);
|
||||
}
|
||||
|
||||
@@ -108,11 +107,10 @@ class AttributeTable extends AttributeDBField
|
||||
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
try {
|
||||
$sSerializedValue = serialize($value);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sSerializedValue = json_encode($value);
|
||||
}
|
||||
$aValues[$this->Get("sql")] = $sSerializedValue;
|
||||
@@ -123,7 +121,7 @@ class AttributeTable extends AttributeDBField
|
||||
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
throw new CoreException('Expecting an array', array('found' => get_class($value)));
|
||||
throw new CoreException('Expecting an array', ['found' => get_class($value)]);
|
||||
}
|
||||
if (count($value) == 0) {
|
||||
return "";
|
||||
@@ -148,10 +146,13 @@ class AttributeTable extends AttributeDBField
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
// Not implemented
|
||||
return '';
|
||||
}
|
||||
@@ -174,4 +175,4 @@ class AttributeTable extends AttributeDBField
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -27,7 +28,7 @@ use utils;
|
||||
*/
|
||||
class AttributeTagSet extends AttributeSet
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_TAG_SET;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_TAG_SET;
|
||||
|
||||
public function __construct($sCode, array $aParams)
|
||||
{
|
||||
@@ -42,7 +43,7 @@ class AttributeTagSet extends AttributeSet
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return array_merge(parent::ListExpectedParams(), array('tag_code_max_len'));
|
||||
return array_merge(parent::ListExpectedParams(), ['tag_code_max_len']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,13 +53,13 @@ class AttributeTagSet extends AttributeSet
|
||||
*
|
||||
* @return string JSON to be used in the itop.tagset_widget JQuery widget
|
||||
*/
|
||||
public function GetJsonForWidget($oValue, $aArgs = array())
|
||||
public function GetJsonForWidget($oValue, $aArgs = [])
|
||||
{
|
||||
$aJson = array();
|
||||
$aJson = [];
|
||||
|
||||
// possible_values
|
||||
$aTagSetObjectData = $this->GetAllowedValues($aArgs);
|
||||
$aTagSetKeyValData = array();
|
||||
$aTagSetKeyValData = [];
|
||||
foreach ($aTagSetObjectData as $sTagCode => $sTagLabel) {
|
||||
$aTagSetKeyValData[] = [
|
||||
'code' => $sTagCode,
|
||||
@@ -68,10 +69,10 @@ class AttributeTagSet extends AttributeSet
|
||||
$aJson['possible_values'] = $aTagSetKeyValData;
|
||||
|
||||
if (is_null($oValue)) {
|
||||
$aJson['partial_values'] = array();
|
||||
$aJson['orig_value'] = array();
|
||||
$aJson['added'] = array();
|
||||
$aJson['removed'] = array();
|
||||
$aJson['partial_values'] = [];
|
||||
$aJson['orig_value'] = [];
|
||||
$aJson['added'] = [];
|
||||
$aJson['removed'] = [];
|
||||
} else {
|
||||
$aJson['orig_value'] = array_merge($oValue->GetValues(), $oValue->GetModified());
|
||||
$aJson['added'] = $oValue->GetAdded();
|
||||
@@ -82,11 +83,10 @@ class AttributeTagSet extends AttributeSet
|
||||
$aJson['partial_values'] = $oValue->GetModified();
|
||||
} else {
|
||||
// For simple updates
|
||||
$aJson['partial_values'] = array();
|
||||
$aJson['partial_values'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$iMaxTags = $this->GetMaxItems();
|
||||
$aJson['max_items_allowed'] = $iMaxTags;
|
||||
|
||||
@@ -95,7 +95,7 @@ class AttributeTagSet extends AttributeSet
|
||||
|
||||
public function FromStringToArray($proposedValue, $sDefaultSepItem = ',')
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
if (!empty($proposedValue)) {
|
||||
foreach (explode(' ', $proposedValue) as $sCode) {
|
||||
$sValue = trim($sCode);
|
||||
@@ -126,7 +126,7 @@ class AttributeTagSet extends AttributeSet
|
||||
} else {
|
||||
$oTagSet = new ormTagSet($sClass, $sAttCode, $this->GetMaxItems());
|
||||
}
|
||||
$aGoodTags = array();
|
||||
$aGoodTags = [];
|
||||
foreach ($aTagCodes as $sTagCode) {
|
||||
if ($sTagCode === '') {
|
||||
continue;
|
||||
@@ -177,12 +177,12 @@ class AttributeTagSet extends AttributeSet
|
||||
return ($val1 == $val2);
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sContains = '')
|
||||
public function GetAllowedValues($aArgs = [], $sContains = '')
|
||||
{
|
||||
$sAttCode = $this->GetCode();
|
||||
$sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $sAttCode);
|
||||
$aAllowedTags = TagSetFieldData::GetAllowedValues($sClass, $sAttCode);
|
||||
$aAllowedValues = array();
|
||||
$aAllowedValues = [];
|
||||
foreach ($aAllowedTags as $oAllowedTag) {
|
||||
$aAllowedValues[$oAllowedTag->Get('code')] = $oAllowedTag->Get('label');
|
||||
}
|
||||
@@ -253,10 +253,13 @@ class AttributeTagSet extends AttributeSet
|
||||
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
|
||||
}
|
||||
if (!empty($sProposedValue)) {
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()),
|
||||
$this->GetCode(), $this->GetMaxItems());
|
||||
$oTagSet = new ormTagSet(
|
||||
MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()),
|
||||
$this->GetCode(),
|
||||
$this->GetMaxItems()
|
||||
);
|
||||
$aLabels = explode($sSepItem, $sProposedValue);
|
||||
$aCodes = array();
|
||||
$aCodes = [];
|
||||
foreach ($aLabels as $sTagLabel) {
|
||||
if (!empty($sTagLabel)) {
|
||||
$aCodes[] = ($bLocalizedValue) ? $oTagSet->GetTagFromLabel($sTagLabel) : $sTagLabel;
|
||||
@@ -313,12 +316,12 @@ class AttributeTagSet extends AttributeSet
|
||||
|
||||
return implode(', ', $aValues);
|
||||
}
|
||||
throw new CoreWarning('Expected the attribute value to be a TagSet', array(
|
||||
throw new CoreWarning('Expected the attribute value to be a TagSet', [
|
||||
'found_type' => gettype($sValue),
|
||||
'value' => $sValue,
|
||||
'class' => $this->GetHostClass(),
|
||||
'attribute' => $this->GetCode(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,12 +340,12 @@ class AttributeTagSet extends AttributeSet
|
||||
|
||||
return implode(' ', $aValues);
|
||||
}
|
||||
throw new CoreWarning('Expected the attribute value to be a TagSet', array(
|
||||
throw new CoreWarning('Expected the attribute value to be a TagSet', [
|
||||
'found_type' => gettype($value),
|
||||
'value' => $value,
|
||||
'class' => $this->GetHostClass(),
|
||||
'attribute' => $this->GetCode(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,19 +377,20 @@ class AttributeTagSet extends AttributeSet
|
||||
$oValue = $this->MakeRealValue($value, $oHostObject);
|
||||
|
||||
return $this->GetAsHTML($oValue, $oHostObject, $bLocalize);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// unknown tags are present display the code instead
|
||||
}
|
||||
$aTagCodes = $this->FromStringToArray($value);
|
||||
$aValues = array();
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()),
|
||||
$this->GetCode(), $this->GetMaxItems());
|
||||
$aValues = [];
|
||||
$oTagSet = new ormTagSet(
|
||||
MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()),
|
||||
$this->GetCode(),
|
||||
$this->GetMaxItems()
|
||||
);
|
||||
foreach ($aTagCodes as $sTagCode) {
|
||||
try {
|
||||
$oTagSet->Add($sTagCode);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$aValues[] = $sTagCode;
|
||||
}
|
||||
}
|
||||
@@ -419,7 +423,7 @@ class AttributeTagSet extends AttributeSet
|
||||
$aAllowedTags = TagSetFieldData::GetAllowedValues(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode());
|
||||
|
||||
if (!empty($aDelta['removed'])) {
|
||||
$aRemoved = array();
|
||||
$aRemoved = [];
|
||||
foreach ($aDelta['removed'] as $idx => $sTagCode) {
|
||||
if (empty($sTagCode)) {
|
||||
continue;
|
||||
@@ -444,7 +448,7 @@ class AttributeTagSet extends AttributeSet
|
||||
$sResult .= ', ';
|
||||
}
|
||||
|
||||
$aAdded = array();
|
||||
$aAdded = [];
|
||||
foreach ($aDelta['added'] as $idx => $sTagCode) {
|
||||
if (empty($sTagCode)) {
|
||||
continue;
|
||||
@@ -562,10 +566,10 @@ HTML;
|
||||
*/
|
||||
public function EnumTemplateVerbs()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'' => 'Plain text representation',
|
||||
'html' => 'HTML representation (unordered list)',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,7 +617,7 @@ HTML;
|
||||
*/
|
||||
public function GetForJSON($value)
|
||||
{
|
||||
$aRet = array();
|
||||
$aRet = [];
|
||||
if (is_object($value) && ($value instanceof ormTagSet)) {
|
||||
$aRet = $value->GetValues();
|
||||
}
|
||||
@@ -659,4 +663,4 @@ HTML;
|
||||
{
|
||||
return '\\Combodo\\iTop\\Form\\Field\\TagSetField';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Exception;
|
||||
*/
|
||||
class AttributeTemplateHTML extends AttributeText
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -36,7 +37,7 @@ class AttributeTemplateHTML extends AttributeText
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->Get('sql')] = $this->GetSQLCol();
|
||||
if ($this->GetOptional('format', null) != null) {
|
||||
// Add the extra column only if the property 'format' is specified for the attribute
|
||||
@@ -58,4 +59,4 @@ class AttributeTemplateHTML extends AttributeText
|
||||
{
|
||||
return $this->GetOptional('format', 'html'); // Defaults to HTML
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Exception;
|
||||
*/
|
||||
class AttributeTemplateString extends AttributeString
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -33,4 +34,4 @@ class AttributeTemplateString extends AttributeString
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Exception;
|
||||
*/
|
||||
class AttributeTemplateText extends AttributeText
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
public const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_STRING;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
@@ -33,4 +34,4 @@ class AttributeTemplateText extends AttributeText
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -58,7 +59,7 @@ class AttributeText extends AttributeString
|
||||
|
||||
public function GetSQLColumns($bFullSpec = false)
|
||||
{
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
$aColumns[$this->Get('sql')] = $this->GetSQLCol($bFullSpec);
|
||||
if ($this->GetOptional('format', null) != null) {
|
||||
// Add the extra column only if the property 'format' is specified for the attribute
|
||||
@@ -76,7 +77,7 @@ class AttributeText extends AttributeString
|
||||
if ($sPrefix == '') {
|
||||
$sPrefix = $this->Get('sql');
|
||||
}
|
||||
$aColumns = array();
|
||||
$aColumns = [];
|
||||
// Note: to optimize things, the existence of the attribute is determined by the existence of one column with an empty suffix
|
||||
$aColumns[''] = $sPrefix;
|
||||
if ($this->GetOptional('format', null) != null) {
|
||||
@@ -98,8 +99,12 @@ class AttributeText extends AttributeString
|
||||
{
|
||||
if (!$bWikiOnly) {
|
||||
$sPattern = '/'.str_replace('/', '\/', utils::GetConfig()->Get('url_validation_pattern')).'/i';
|
||||
if (preg_match_all($sPattern, $sText, $aAllMatches,
|
||||
PREG_SET_ORDER /* important !*/ | PREG_OFFSET_CAPTURE /* important ! */)) {
|
||||
if (preg_match_all(
|
||||
$sPattern,
|
||||
$sText,
|
||||
$aAllMatches,
|
||||
PREG_SET_ORDER /* important !*/ | PREG_OFFSET_CAPTURE /* important ! */
|
||||
)) {
|
||||
$i = count($aAllMatches);
|
||||
// Replace the URLs by an actual hyperlink <a href="...">...</a>
|
||||
// Let's do it backwards so that the initial positions are not modified by the replacement
|
||||
@@ -153,7 +158,7 @@ class AttributeText extends AttributeString
|
||||
|
||||
public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
$aStyles = array();
|
||||
$aStyles = [];
|
||||
if ($this->GetWidth() != '') {
|
||||
$aStyles[] = 'width:'.$this->GetWidth();
|
||||
}
|
||||
@@ -356,7 +361,7 @@ class AttributeText extends AttributeString
|
||||
|
||||
public function GetSQLValues($value)
|
||||
{
|
||||
$aValues = array();
|
||||
$aValues = [];
|
||||
$aValues[$this->Get("sql")] = $this->ScalarToSQL($value);
|
||||
if ($this->GetOptional('format', null) != null) {
|
||||
// Add the extra column only if the property 'format' is specified for the attribute
|
||||
@@ -367,17 +372,20 @@ class AttributeText extends AttributeString
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$sValue,
|
||||
$sSeparator = ',',
|
||||
$sTextQualifier = '"',
|
||||
$oHostObject = null,
|
||||
$bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
switch ($this->GetFormat()) {
|
||||
case 'html':
|
||||
if ($bConvertToPlainText) {
|
||||
$sValue = utils::HtmlToText((string)$sValue);
|
||||
}
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sFrom = ["\r\n", $sTextQualifier];
|
||||
$sTo = ["\n", $sTextQualifier.$sTextQualifier];
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
@@ -385,8 +393,14 @@ class AttributeText extends AttributeString
|
||||
|
||||
case 'text':
|
||||
default:
|
||||
return parent::GetAsCSV($sValue, $sSeparator, $sTextQualifier, $oHostObject, $bLocalize,
|
||||
$bConvertToPlainText);
|
||||
return parent::GetAsCSV(
|
||||
$sValue,
|
||||
$sSeparator,
|
||||
$sTextQualifier,
|
||||
$oHostObject,
|
||||
$bLocalize,
|
||||
$bConvertToPlainText
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,4 +419,4 @@ class AttributeText extends AttributeString
|
||||
? CMDBChangeOpSetAttributeHTML::class
|
||||
: CMDBChangeOpSetAttributeText::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -53,7 +54,7 @@ class AttributeURL extends AttributeString
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
//return parent::ListExpectedParams();
|
||||
return array_merge(parent::ListExpectedParams(), array("target"));
|
||||
return array_merge(parent::ListExpectedParams(), ["target"]);
|
||||
}
|
||||
|
||||
protected function GetSQLCol($bFullSpec = false)
|
||||
@@ -122,4 +123,4 @@ class AttributeURL extends AttributeString
|
||||
{
|
||||
return CMDBChangeOpSetAttributeURL::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,4 +16,4 @@ use Exception;
|
||||
*/
|
||||
class MissingColumnException extends Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -14,4 +15,4 @@ namespace Combodo\iTop\Core\AttributeDefinition;
|
||||
interface iAttributeNoGroupBy
|
||||
{
|
||||
//no method, just a contract on implement
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -8,120 +9,120 @@ namespace Combodo\iTop\Core\Kpi;
|
||||
|
||||
class KpiLogData
|
||||
{
|
||||
const TYPE_REPORT = 'report';
|
||||
const TYPE_STATS = 'stats';
|
||||
const TYPE_REQUEST = 'request';
|
||||
public const TYPE_REPORT = 'report';
|
||||
public const TYPE_STATS = 'stats';
|
||||
public const TYPE_REQUEST = 'request';
|
||||
|
||||
/** @var string */
|
||||
public $sType;
|
||||
/** @var string */
|
||||
public $sOperation;
|
||||
/** @var string */
|
||||
public $sArguments;
|
||||
/** @var float */
|
||||
public $fStartTime;
|
||||
/** @var float */
|
||||
public $fStopTime;
|
||||
/** @var string */
|
||||
public $sExtension;
|
||||
/** @var int */
|
||||
public $iInitialMemory;
|
||||
/** @var int */
|
||||
public $iCurrentMemory;
|
||||
/** @var int */
|
||||
public $iPeakMemory;
|
||||
/** @var array */
|
||||
public $aData;
|
||||
/** @var string */
|
||||
public $sType;
|
||||
/** @var string */
|
||||
public $sOperation;
|
||||
/** @var string */
|
||||
public $sArguments;
|
||||
/** @var float */
|
||||
public $fStartTime;
|
||||
/** @var float */
|
||||
public $fStopTime;
|
||||
/** @var string */
|
||||
public $sExtension;
|
||||
/** @var int */
|
||||
public $iInitialMemory;
|
||||
/** @var int */
|
||||
public $iCurrentMemory;
|
||||
/** @var int */
|
||||
public $iPeakMemory;
|
||||
/** @var array */
|
||||
public $aData;
|
||||
// Computed
|
||||
public float $fDuration;
|
||||
|
||||
/**
|
||||
* @param string $sType
|
||||
* @param string $sOperation
|
||||
* @param string $sArguments
|
||||
* @param float $fStartTime
|
||||
* @param float $fStopTime
|
||||
* @param string $sExtension
|
||||
* @param int $iInitialMemory
|
||||
* @param int $iCurrentMemory
|
||||
* @param array $aData
|
||||
*/
|
||||
public function __construct($sType, $sOperation, $sArguments, $fStartTime, $fStopTime, $sExtension, $iInitialMemory = 0, $iCurrentMemory = 0, $iPeakMemory = 0, $aData = [])
|
||||
{
|
||||
$this->sType = $sType;
|
||||
$this->sOperation = $sOperation;
|
||||
$this->sArguments = @iconv(mb_detect_encoding($sArguments, mb_detect_order(), true), 'UTF-8', $sArguments);
|
||||
$this->fStartTime = $fStartTime;
|
||||
$this->fStopTime = $fStopTime;
|
||||
$this->sExtension = $sExtension;
|
||||
$this->iInitialMemory = $iInitialMemory;
|
||||
$this->iCurrentMemory = $iCurrentMemory;
|
||||
$this->iPeakMemory = $iPeakMemory;
|
||||
$this->aData = $aData;
|
||||
$this->fDuration = sprintf('%01.4f', $this->fStopTime - $this->fStartTime);
|
||||
}
|
||||
/**
|
||||
* @param string $sType
|
||||
* @param string $sOperation
|
||||
* @param string $sArguments
|
||||
* @param float $fStartTime
|
||||
* @param float $fStopTime
|
||||
* @param string $sExtension
|
||||
* @param int $iInitialMemory
|
||||
* @param int $iCurrentMemory
|
||||
* @param array $aData
|
||||
*/
|
||||
public function __construct($sType, $sOperation, $sArguments, $fStartTime, $fStopTime, $sExtension, $iInitialMemory = 0, $iCurrentMemory = 0, $iPeakMemory = 0, $aData = [])
|
||||
{
|
||||
$this->sType = $sType;
|
||||
$this->sOperation = $sOperation;
|
||||
$this->sArguments = @iconv(mb_detect_encoding($sArguments, mb_detect_order(), true), 'UTF-8', $sArguments);
|
||||
$this->fStartTime = $fStartTime;
|
||||
$this->fStopTime = $fStopTime;
|
||||
$this->sExtension = $sExtension;
|
||||
$this->iInitialMemory = $iInitialMemory;
|
||||
$this->iCurrentMemory = $iCurrentMemory;
|
||||
$this->iPeakMemory = $iPeakMemory;
|
||||
$this->aData = $aData;
|
||||
$this->fDuration = sprintf('%01.4f', $this->fStopTime - $this->fStartTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the CSV Header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetCSVHeader()
|
||||
{
|
||||
return "Type,Operation,Arguments,StartTime,StopTime,Duration,Extension,InitialMemory,CurrentMemory,PeakMemory";
|
||||
}
|
||||
/**
|
||||
* Return the CSV Header
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetCSVHeader()
|
||||
{
|
||||
return "Type,Operation,Arguments,StartTime,StopTime,Duration,Extension,InitialMemory,CurrentMemory,PeakMemory";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the CSV line for the values
|
||||
* @return string
|
||||
*/
|
||||
public function GetCSV()
|
||||
{
|
||||
$sType = $this->RemoveQuotes($this->sType);
|
||||
$sOperation = $this->RemoveQuotes($this->sOperation);
|
||||
$sArguments = $this->RemoveQuotes($this->sArguments);
|
||||
$sExtension = $this->RemoveQuotes($this->sExtension);
|
||||
return "\"$sType\",\"$sOperation\",\"$sArguments\",$this->fStartTime,$this->fStopTime,$this->fDuration,\"$sExtension\",$this->iInitialMemory,$this->iCurrentMemory,$this->iPeakMemory";
|
||||
}
|
||||
/**
|
||||
* Return the CSV line for the values
|
||||
* @return string
|
||||
*/
|
||||
public function GetCSV()
|
||||
{
|
||||
$sType = $this->RemoveQuotes($this->sType);
|
||||
$sOperation = $this->RemoveQuotes($this->sOperation);
|
||||
$sArguments = $this->RemoveQuotes($this->sArguments);
|
||||
$sExtension = $this->RemoveQuotes($this->sExtension);
|
||||
return "\"$sType\",\"$sOperation\",\"$sArguments\",$this->fStartTime,$this->fStopTime,$this->fDuration,\"$sExtension\",$this->iInitialMemory,$this->iCurrentMemory,$this->iPeakMemory";
|
||||
}
|
||||
|
||||
private function RemoveQuotes(string $sEntry): string
|
||||
{
|
||||
return str_replace('"', "'", $sEntry);
|
||||
}
|
||||
private function RemoveQuotes(string $sEntry): string
|
||||
{
|
||||
return str_replace('"', "'", $sEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Combodo\iTop\Core\Kpi\KpiLogData $oOther
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function Compare(KpiLogData $oOther): float
|
||||
{
|
||||
if ($oOther->fStartTime > $this->fStartTime) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/**
|
||||
* @param \Combodo\iTop\Core\Kpi\KpiLogData $oOther
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function Compare(KpiLogData $oOther): float
|
||||
{
|
||||
if ($oOther->fStartTime > $this->fStartTime) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function Contains(KpiLogData $oOther): bool
|
||||
{
|
||||
if ($oOther->fStartTime < $this->fStartTime) {
|
||||
return false;
|
||||
}
|
||||
public function Contains(KpiLogData $oOther): bool
|
||||
{
|
||||
if ($oOther->fStartTime < $this->fStartTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($oOther->fStartTime > $this->fStopTime) {
|
||||
return false;
|
||||
}
|
||||
if ($oOther->fStartTime > $this->fStopTime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->sType:$this->sOperation:$this->sArguments";
|
||||
}
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->sType:$this->sOperation:$this->sArguments";
|
||||
}
|
||||
|
||||
public function GetUUID(): string
|
||||
{
|
||||
return sha1($this->__toString());
|
||||
}
|
||||
}
|
||||
public function GetUUID(): string
|
||||
{
|
||||
return sha1($this->__toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user