N°931: Import/Export separator defined in configuration

This commit is contained in:
Eric
2018-09-18 12:04:08 +02:00
parent c3c1897258
commit 9fbd27f3a8
2 changed files with 16 additions and 3 deletions

View File

@@ -6052,10 +6052,14 @@ class AttributeTagSet extends AttributeDBFieldVoid
*/
public function MakeValueFromString($sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null, $sAttributeQualifier = null)
{
if (is_null($sSepItem) || empty($sSepItem))
{
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
}
if ($bLocalizedValue && !empty($sProposedValue))
{
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode());
$aLabels = explode('|', $sProposedValue);
$aLabels = explode($sSepItem, $sProposedValue);
$aCodes = array();
foreach($aLabels as $sTagLabel)
{
@@ -6277,6 +6281,7 @@ class AttributeTagSet extends AttributeDBFieldVoid
*/
public function GetAsCSV($value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true, $bConvertToPlainText = false)
{
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
if (is_object($value) && ($value instanceof ormTagSet))
{
if ($bLocalize)
@@ -6287,13 +6292,13 @@ class AttributeTagSet extends AttributeDBFieldVoid
{
$aValues = $value->GetValue();
}
$sRes = implode('|', $aValues);
$sRes = implode($sSepItem, $aValues);
}
else
{
$sRes = '';
}
return $sRes;
return "{$sTextQualifier}{$sRes}{$sTextQualifier}";
}
/**

View File

@@ -408,6 +408,14 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'tag_set_item_separator' => array(
'type' => 'string',
'description' => 'Tag set from string: tag label separator',
'default' => '|',
'value' => '|',
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'cron_max_execution_time' => array(
'type' => 'integer',
'description' => 'Duration (seconds) of the page cron.php, must be shorter than php setting max_execution_time and shorter than the web server response timeout',