update 2024-04-17 10:40:23

This commit is contained in:
Robot 2024-04-17 10:40:24 +02:00
parent 41aa3a166c
commit 4bbcb6c3d6
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
3 changed files with 104 additions and 2 deletions

View File

@ -61,6 +61,7 @@ class Builders << (F,LightGreen) >> #RoyalBlue {
# CMSApplication $app
+ __construct(Config $config, Power $power, ...)
+ set(string $langLabel, string $langView, ...) : void
- normalizeDatabaseValues(string $nameSingleCode, string $name) : ?array
}
note right of Builders::__construct
@ -138,6 +139,15 @@ note right of Builders::set
?array $custom = null
?array $options = null
end note
note right of Builders::normalizeDatabaseValues
Normalizes database values by adjusting the 'length' and 'default' fields based on specific conditions.
This function modifies the database values by replacing placeholder texts and appending specifications
to types based on the 'length' field. It removes unnecessary fields from the result array.
since: 3.2.1
return: ?array
end note
@enduml
```

View File

@ -1300,10 +1300,56 @@ final class Builders
'title' => (is_string($title_) && $name === $title_) ? true : false,
'list' => $nameListCode,
'store' => (isset($field['store'])) ? $field['store'] : null,
'tab_name' => $tabName
'tab_name' => $tabName,
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name)
]
);
}
}
/**
* Normalizes database values by adjusting the 'length' and 'default' fields based on specific conditions.
* This function modifies the database values by replacing placeholder texts and appending specifications
* to types based on the 'length' field. It removes unnecessary fields from the result array.
*
* @param string $nameSingleCode The code for naming single entries.
* @param string $name The name of the database entry.
*
* @return array|null Returns the modified database values array or null if no values are found.
* @since 3.2.1
*/
private function normalizeDatabaseValues($nameSingleCode, $name): ?array
{
$db_values = $this->databasetables->get($nameSingleCode . '.' . $name, null);
if ($db_values === null)
{
return null;
}
if (isset($db_values['lenght']))
{
if ($db_values['lenght'] === 'Other' && isset($db_values['lenght_other']))
{
$db_values['lenght'] = $db_values['lenght_other'];
}
$db_values['lenght'] = trim($db_values['lenght']);
if (strlen($db_values['lenght']))
{
$db_values['type'] .= '(' . $db_values['lenght'] . ')';
}
}
if (isset($db_values['default']))
{
if ($db_values['default'] === 'Other' && isset($db_values['other']))
{
$db_values['default'] = $db_values['other'];
}
}
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
return $db_values;
}
}

View File

@ -1223,8 +1223,54 @@
'title' => (is_string($title_) && $name === $title_) ? true : false,
'list' => $nameListCode,
'store' => (isset($field['store'])) ? $field['store'] : null,
'tab_name' => $tabName
'tab_name' => $tabName,
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name)
]
);
}
}
/**
* Normalizes database values by adjusting the 'length' and 'default' fields based on specific conditions.
* This function modifies the database values by replacing placeholder texts and appending specifications
* to types based on the 'length' field. It removes unnecessary fields from the result array.
*
* @param string $nameSingleCode The code for naming single entries.
* @param string $name The name of the database entry.
*
* @return array|null Returns the modified database values array or null if no values are found.
* @since 3.2.1
*/
private function normalizeDatabaseValues($nameSingleCode, $name): ?array
{
$db_values = $this->databasetables->get($nameSingleCode . '.' . $name, null);
if ($db_values === null)
{
return null;
}
if (isset($db_values['lenght']))
{
if ($db_values['lenght'] === 'Other' && isset($db_values['lenght_other']))
{
$db_values['lenght'] = $db_values['lenght_other'];
}
$db_values['lenght'] = trim($db_values['lenght']);
if (strlen($db_values['lenght']))
{
$db_values['type'] .= '(' . $db_values['lenght'] . ')';
}
}
if (isset($db_values['default']))
{
if ($db_values['default'] === 'Other' && isset($db_values['other']))
{
$db_values['default'] = $db_values['other'];
}
}
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
return $db_values;
}