mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 14:38:47 +02:00
N°8699 - attributedef.class.inc.php to PSR4 [3-PSR4]
- Add namespaces - Add use statements - reformat code
This commit is contained in:
committed by
Benjamin Dalsass
parent
f0adbbba29
commit
3fa500c9c1
@@ -1,4 +1,14 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Core\AttributeDefinition;
|
||||
|
||||
use CMDBSource;
|
||||
use DateTimeFormat;
|
||||
use DBObject;
|
||||
|
||||
/**
|
||||
* Map a date+time column to an attribute
|
||||
@@ -7,99 +17,99 @@
|
||||
*/
|
||||
class AttributeDate extends AttributeDateTime
|
||||
{
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE;
|
||||
const SEARCH_WIDGET_TYPE = self::SEARCH_WIDGET_TYPE_DATE;
|
||||
|
||||
public static $oDateFormat = null;
|
||||
public static $oDateFormat = null;
|
||||
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
*
|
||||
* @see https://www.php.net/manual/fr/language.oop5.decon.php states that child constructor can be ommited
|
||||
* @see https://bugs.php.net/bug.php?id=79010 bug solved in PHP 7.4.9
|
||||
*
|
||||
* @param string $sCode
|
||||
* @param array $aParams
|
||||
*
|
||||
* @throws \Exception
|
||||
* @noinspection SenselessProxyMethodInspection
|
||||
*/
|
||||
public function __construct($sCode, $aParams)
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
*
|
||||
* @see https://www.php.net/manual/fr/language.oop5.decon.php states that child constructor can be ommited
|
||||
* @see https://bugs.php.net/bug.php?id=79010 bug solved in PHP 7.4.9
|
||||
*
|
||||
* @param string $sCode
|
||||
* @param array $aParams
|
||||
*
|
||||
* @throws Exception
|
||||
* @noinspection SenselessProxyMethodInspection
|
||||
*/
|
||||
public function __construct($sCode, $aParams)
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
|
||||
public static function GetFormat()
|
||||
{
|
||||
if (self::$oDateFormat == null) {
|
||||
AttributeDateTime::LoadFormatFromConfig();
|
||||
}
|
||||
public static function GetFormat()
|
||||
{
|
||||
if (self::$oDateFormat == null) {
|
||||
AttributeDateTime::LoadFormatFromConfig();
|
||||
}
|
||||
|
||||
return self::$oDateFormat;
|
||||
}
|
||||
return self::$oDateFormat;
|
||||
}
|
||||
|
||||
public static function SetFormat(DateTimeFormat $oDateFormat)
|
||||
{
|
||||
self::$oDateFormat = $oDateFormat;
|
||||
}
|
||||
public static function SetFormat(DateTimeFormat $oDateFormat)
|
||||
{
|
||||
self::$oDateFormat = $oDateFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format string used for the date & time stored in memory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetInternalFormat()
|
||||
{
|
||||
return 'Y-m-d';
|
||||
}
|
||||
/**
|
||||
* Returns the format string used for the date & time stored in memory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetInternalFormat()
|
||||
{
|
||||
return 'Y-m-d';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format string used for the date & time written to MySQL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetSQLFormat()
|
||||
{
|
||||
return 'Y-m-d';
|
||||
}
|
||||
/**
|
||||
* Returns the format string used for the date & time written to MySQL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetSQLFormat()
|
||||
{
|
||||
return 'Y-m-d';
|
||||
}
|
||||
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return parent::ListExpectedParams();
|
||||
//return array_merge(parent::ListExpectedParams(), array());
|
||||
}
|
||||
public static function ListExpectedParams()
|
||||
{
|
||||
return parent::ListExpectedParams();
|
||||
//return array_merge(parent::ListExpectedParams(), array());
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
{
|
||||
return "Date";
|
||||
}
|
||||
public function GetEditClass()
|
||||
{
|
||||
return "Date";
|
||||
}
|
||||
|
||||
protected function GetSQLCol($bFullSpec = false)
|
||||
{
|
||||
return "DATE";
|
||||
}
|
||||
protected function GetSQLCol($bFullSpec = false)
|
||||
{
|
||||
return "DATE";
|
||||
}
|
||||
|
||||
public function GetImportColumns()
|
||||
{
|
||||
// Allow an empty string to be a valid value (synonym for "reset")
|
||||
$aColumns = array();
|
||||
$aColumns[$this->GetCode()] = 'VARCHAR(10)' . CMDBSource::GetSqlStringColumnDefinition();
|
||||
public function GetImportColumns()
|
||||
{
|
||||
// Allow an empty string to be a valid value (synonym for "reset")
|
||||
$aColumns = array();
|
||||
$aColumns[$this->GetCode()] = 'VARCHAR(10)'.CMDBSource::GetSqlStringColumnDefinition();
|
||||
|
||||
return $aColumns;
|
||||
}
|
||||
return $aColumns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override to specify Field class
|
||||
*
|
||||
* When called first, $oFormField is null and will be created (eg. Make). Then when the ::parent is called and the
|
||||
* $oFormField is passed, MakeFormField behave more like a Prepare.
|
||||
*/
|
||||
public function MakeFormField(DBObject $oObject, $oFormField = null)
|
||||
{
|
||||
$oFormField = parent::MakeFormField($oObject, $oFormField);
|
||||
$oFormField->SetDateOnly(true);
|
||||
/**
|
||||
* Override to specify Field class
|
||||
*
|
||||
* When called first, $oFormField is null and will be created (eg. Make). Then when the ::parent is called and the
|
||||
* $oFormField is passed, MakeFormField behave more like a Prepare.
|
||||
*/
|
||||
public function MakeFormField(DBObject $oObject, $oFormField = null)
|
||||
{
|
||||
$oFormField = parent::MakeFormField($oObject, $oFormField);
|
||||
$oFormField->SetDateOnly(true);
|
||||
|
||||
return $oFormField;
|
||||
}
|
||||
return $oFormField;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user