SVN:trunk[5976]
This commit is contained in:
Guillaume Lajarige
2018-07-25 07:55:39 +00:00
parent 3126af94ac
commit eb0403945b
2 changed files with 195 additions and 60 deletions

View File

@@ -186,6 +186,14 @@ abstract class AttributeDefinition
}
}
/**
* AttributeDefinition constructor.
*
* @param string $sCode
* @param array $aParams
*
* @throws \Exception
*/
public function __construct($sCode, $aParams)
{
$this->m_sCode = $sCode;
@@ -212,6 +220,11 @@ abstract class AttributeDefinition
return $this->m_sHostClass;
}
/**
* @return array
*
* @throws \CoreException
*/
public function ListSubItems()
{
$aSubItems = array();
@@ -235,6 +248,9 @@ abstract class AttributeDefinition
return array();
}
/**
* @throws \Exception
*/
private function ConsistencyCheck()
{
// Check that any mandatory param has been specified
@@ -255,7 +271,7 @@ abstract class AttributeDefinition
/**
* Check the validity of the given value
*
* @param DBObject $oHostObject
* @param \DBObject $oHostObject
* @param string An error if any, null otherwise
*
* @return bool
@@ -370,6 +386,8 @@ abstract class AttributeDefinition
/**
* Helper to browse the hierarchy of classes, searching for a label
*
* @throws \Exception
*/
protected function SearchLabel($sDictEntrySuffix, $sDefault, $bUserLanguageOnly)
{
@@ -392,6 +410,13 @@ abstract class AttributeDefinition
return $sLabel;
}
/**
* @param string|null $sDefault
*
* @return string
*
* @throws \Exception
*/
public function GetLabel($sDefault = null)
{
$sLabel = $this->SearchLabel('/Attribute:'.$this->m_sCode, null, true /*user lang*/);
@@ -435,6 +460,12 @@ abstract class AttributeDefinition
{
return $sSearchString;
}
/**
* @return string
*
* @throws \Exception
*/
public function GetLabel_Obsolete()
{
// Written for compatibility with a data model written prior to version 0.9.1
@@ -448,6 +479,13 @@ abstract class AttributeDefinition
}
}
/**
* @param string|null $sDefault
*
* @return string
*
* @throws \Exception
*/
public function GetDescription($sDefault = null)
{
$sLabel = $this->SearchLabel('/Attribute:'.$this->m_sCode.'+', null, true /*user lang*/);
@@ -464,6 +502,13 @@ abstract class AttributeDefinition
return $sLabel;
}
/**
* @param string|null $sDefault
*
* @return string
*
* @throws \Exception
*/
public function GetHelpOnEdition($sDefault = null)
{
$sLabel = $this->SearchLabel('/Attribute:'.$this->m_sCode.'?', null, true /*user lang*/);
@@ -494,6 +539,11 @@ abstract class AttributeDefinition
return '';
}
/**
* @return string
*
* @throws \Exception
*/
public function GetDescription_Obsolete()
{
// Written for compatibility with a data model written prior to version 0.9.1
@@ -679,6 +729,8 @@ abstract class AttributeDefinition
* 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.
*
* @throws \Exception
*/
public function MakeFormField(DBObject $oObject, $oFormField = null)
{
@@ -741,12 +793,13 @@ abstract class AttributeDefinition
/**
* Get various representations of the value, for insertion into a template (e.g. in Notifications)
*
* @param $value mixed The current value of the field
* @param $sVerb string The verb specifying the representation of the value
* @param $oHostObject DBObject The object
* @param $bLocalize bool Whether or not to localize the value
* @param mixed $value mixed The current value of the field
* @param string $sVerb string The verb specifying the representation of the value
* @param \DBObject $oHostObject DBObject The object
* @param bool $bLocalize bool Whether or not to localize the value
*
* @return mixed|null|string
*
* @throws \Exception
*/
public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true)
@@ -784,6 +837,8 @@ abstract class AttributeDefinition
/**
* Explain the change of the attribute (history)
*
* @throws \Exception
*/
public function DescribeChangeAsHTML($sOldValue, $sNewValue, $sLabel = null)
{
@@ -854,10 +909,14 @@ abstract class AttributeDefinition
* Parses a string to find some smart search patterns and build the corresponding search/OQL condition
* Each derived class is reponsible for defining and processing their own smart patterns, the base class
* does nothing special, and just calls the default (loose) operator
*
* @param string $sSearchText The search string to analyze for smart patterns
* @param FieldExpression The FieldExpression representing the atttribute code in this OQL query
* @param \FieldExpression $oField
* @param array $aParams Values of the query parameters
* @return Expression The search condition to be added (AND) to the current search
*
* @return \Expression The search condition to be added (AND) to the current search
*
* @throws \CoreException
*/
public function GetSmartConditionExpression($sSearchText, FieldExpression $oField, &$aParams)
{
@@ -921,6 +980,16 @@ class AttributeLinkedSet extends AttributeDefinition
public function GetValuesDef() {return $this->Get("allowed_values");}
public function GetPrerequisiteAttributes($sClass = null) {return $this->Get("depends_on");}
/**
* @param \DBObject|null $oHostObject
*
* @return \ormLinkSet
*
* @throws \Exception
* @throws \CoreException
* @throws \CoreWarning
*/
public function GetDefaultValue(DBObject $oHostObject = null)
{
$sLinkClass = $this->GetLinkedClass();
@@ -973,6 +1042,15 @@ class AttributeLinkedSet extends AttributeDefinition
public function GetBasicFilterLooseOperator() {return '';}
public function GetBasicFilterSQLExpr($sOpCode, $value) {return '';}
/**
* @param string $sValue
* @param \DBObject $oHostObject
* @param bool $bLocalize
*
* @return string|null
*
* @throws \CoreException
*/
public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)
{
if (is_object($sValue) && ($sValue instanceof ormLinkSet))
@@ -1001,6 +1079,15 @@ class AttributeLinkedSet extends AttributeDefinition
return null;
}
/**
* @param string $sValue
* @param \DBObject $oHostObject
* @param bool $bLocalize
*
* @return string
*
* @throws \CoreException
*/
public function GetAsXML($sValue, $oHostObject = null, $bLocalize = true)
{
if (is_object($sValue) && ($sValue instanceof ormLinkSet))

View File

@@ -1184,6 +1184,11 @@ class Config
}
/**
* @param string $sPropCode
*
* @return mixed
*/
public function Get($sPropCode)
{
return $this->m_aSettings[$sPropCode]['value'];
@@ -1252,6 +1257,15 @@ class Config
*/
protected $m_aCharsets;
/**
* Config constructor.
*
* @param string|null $sConfigFile
* @param bool $bLoadConfig
*
* @throws \ConfigException
* @throws \CoreException
*/
public function __construct($sConfigFile = null, $bLoadConfig = true)
{
$this->m_sFile = $sConfigFile;
@@ -1310,6 +1324,12 @@ class Config
*/
}
/**
* @param string $sPurpose
* @param string $sFileName
*
* @throws \ConfigException
*/
protected function CheckFile($sPurpose, $sFileName)
{
if (!file_exists($sFileName))
@@ -1446,6 +1466,13 @@ class Config
return $this->GetModuleParameter($sModule, $sProperty, $defaultvalue);
}
/**
* @param string $sModule
* @param string $sProperty
* @param mixed|null $defaultvalue
*
* @return mixed|null
*/
public function GetModuleParameter($sModule, $sProperty, $defaultvalue = null)
{
$ret = $defaultvalue;
@@ -1478,6 +1505,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6
* @see Config::Get() as a replacement
*/
@@ -1488,6 +1516,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6
* @see Config::Get() as a replacement
*/
@@ -1498,6 +1527,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6
* @see Config::Get() as a replacement
*/
@@ -1508,6 +1538,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6 #1001 utf8mb4 switch
* @see Config::DEFAULT_CHARACTER_SET
*/
@@ -1518,6 +1549,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6 #1001 utf8mb4 switch
* @see Config::DEFAULT_COLLATION
*/
@@ -1528,6 +1560,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6
* @see Config::Get() as a replacement
*/
@@ -1538,6 +1571,7 @@ class Config
/**
* @return string
*
* @deprecated 2.5 will be removed in 2.6
* @see Config::Get() as a replacement
*/
@@ -1760,9 +1794,11 @@ class Config
* Write the configuration to a file (php format) that can be reloaded later
* By default write to the same file that was specified when constructing the object
*
* @param $sFileName string Name of the file to write to (emtpy to write to the same file)
* @param string $sFileName string Name of the file to write to (emtpy to write to the same file)
*
* @return boolean True otherwise throws an Exception
*
* @throws \ConfigException
*/
public function WriteToFile($sFileName = '')
{
@@ -1912,6 +1948,13 @@ class Config
/**
* Helper function to initialize a configuration from the page arguments
*
* @param array $aParamValues
* @param string|null $sModulesDir
* @param bool $bPreserveModuleSettings
*
* @throws \Exception
* @throws \CoreException
*/
public function UpdateFromParams($aParamValues, $sModulesDir = null, $bPreserveModuleSettings = false)
{
@@ -2044,6 +2087,10 @@ class Config
/**
* Helper: for an array of string, change the prefix when found
*
* @param array $aStrings
* @param string $sSearchPrefix
* @param string $sNewPrefix
*/
protected static function ChangePrefix(&$aStrings, $sSearchPrefix, $sNewPrefix)
{
@@ -2059,6 +2106,9 @@ class Config
/**
* Obsolete: kept only for backward compatibility of the Toolkit
* Quick and dirty way to clone a config file into another environment
*
* @param string $sSourceEnv
* @param string $sTargetEnv
*/
public function ChangeModulesPath($sSourceEnv, $sTargetEnv)
{
@@ -2096,5 +2146,3 @@ class Config
}
}
?>