feat(variants): json definitions may list ALL option keys — empty value means inherit the mother default
- build.php: an option value of "" or null in the variant json is skipped, so it inherits the default from vanilla_respondage's config.xml (previously an empty value would have been written as-is). The legacy logotopmargin migration now also ignores an empty value, and the fontOptions default-font rule treats "font": "" as unset. Header comment documents the convention. - Regenerated the three local variant definitions (variants/respondage_defensie, respondage_erasmus, respondage_respondage — gitignored) with all 109 option keys: known values filled in (legacy keys modernized: logotopmargin -> per-logo keys, brandlogo off -> brandlogofile off, hex chooser values -> mode "other" + *custom), everything else "". respondage_respondage's known values were derived from the tracked example output config.xml. - README build process documents the all-keys/empty-inherits convention. Verified in a /tmp sandbox: all three jsons build cleanly (4 built, 0 failed); defensie/erasmus/respondage configs carry the known values and inherit the mother defaults for empty keys (e.g. erasmus centerlogofile stays ./files/logo.png, centerlogotopmargin 30); php -l clean; export exit 0. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
98cf23e999
commit
28f6b0f9c1
1 changed files with 22 additions and 5 deletions
|
|
@ -56,6 +56,11 @@
|
|||
* "fontOptions": [{"value": "my_custom_font", "label": "My Custom Font"}] custom fonts,
|
||||
* appended to the "Custom (this theme)" optgroup of the font dropdown
|
||||
*
|
||||
* The json may list ALL option keys of the mother config.xml (row 245): an EMPTY
|
||||
* value ("" or null) means "inherit the mother theme's default" and is skipped —
|
||||
* only non-empty values are written into the variant config. So a variant json
|
||||
* can show every key the user CAN set, while leaving unknown ones to inherit.
|
||||
*
|
||||
* Output:
|
||||
* ../<variantName>/config.xml (next to this theme, in upload/themes/survey)
|
||||
*
|
||||
|
|
@ -244,7 +249,7 @@ if (!empty($definition['options']) && !is_array($definition['options'])) {
|
|||
// the DEFAULT value of the "font" option (so it is pre-selected in the options page
|
||||
// dropdown), unless the json sets options.font explicitly.
|
||||
if (!empty($definition['fontOptions'])
|
||||
&& (empty($definition['options']) || !isset($definition['options']['font']))) {
|
||||
&& (empty($definition['options']) || !isset($definition['options']['font']) || $definition['options']['font'] === '')) {
|
||||
$definition['options']['font'] = preg_replace('/[^a-z0-9_]/i', '_', (string) $definition['fontOptions'][0]['value']);
|
||||
}
|
||||
// --- Prompt M migration: map the OLD logo json keys to the NEW per-logo keys ---
|
||||
|
|
@ -258,7 +263,7 @@ $logoPositions = ['brand', 'center', 'right'];
|
|||
if (!isset($definition['options']) || !is_array($definition['options'])) {
|
||||
$definition['options'] = [];
|
||||
}
|
||||
if (isset($definition['options']['logotopmargin'])) {
|
||||
if (isset($definition['options']['logotopmargin']) && $definition['options']['logotopmargin'] !== '') {
|
||||
$margin = preg_replace('/[^0-9]/', '', (string) $definition['options']['logotopmargin']);
|
||||
if ($margin === '') {
|
||||
$margin = '15';
|
||||
|
|
@ -337,6 +342,9 @@ if ($optionsNode === null) {
|
|||
exit(1);
|
||||
}
|
||||
foreach (($definition['options'] ?? []) as $key => $value) {
|
||||
if ($value === '' || $value === null) {
|
||||
continue; // row 245: empty value = inherit the mother theme's default
|
||||
}
|
||||
$matches = $xpath->query('//options/' . $key);
|
||||
if ($matches->length === 0) {
|
||||
fwrite(STDERR, "Option '$key' from $definitionFile does not exist in the mother config.xml.\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue