{#
Custom options page of this theme. Activated by custom
in config.xml: LimeSurvey then renders THIS file inside the "Simple options" tab
of themeOptions/update (instead of the core options_core.php partial) and
auto-registers options/options.js next to it.
All options are rendered GENERICALLY from config.xml via aOptionAttributes (the
same structure the core renderer uses, see TemplateManifest::getOptionAttributes()),
grouped by category. Adding an ' %}{% endif %}
{% set imageOptions = imageOptions ~ '' %}{% endif %}
{# If this is a survey-specific (or survey-group) settings page, offer full inheritance of the parent template #}
{% if bInherit %}
{% endif %}
{# Every tab pane ends with the Respondage footer. The logo uses a dedicated file
name (not logo.png) on purpose: variants may ship their own files/logo.png as
client logo, and imageSrc() resolves './files/...' in the variant first — with
this name it falls through to the mother theme, so the footer always shows the
Respondage logo. #}
{% set respondageLogo = imageSrc('./files/respondage-logo.png') %}
{# Options that make up the TOP OF THE PAGE (everything in the header, plus the
progress bar which sits in/just under the header): the menu (navbar text color),
the left/center/right logos, the header background color, and the progress bar
position + colors. These keys are pulled out of their original config.xml
categories (Colors / Images / Progress) into a dedicated FIRST tab below.
Values are stored per option key, so moving them here does not change any stored
value. The order of this list is the order shown in the tab. #}
{% set aTopOfPageKeys = [
'headerbackgroundcolor', 'navbarfontcolor',
'headersticky', 'headerstickycomputer', 'headerstickytablet', 'headerstickymobile',
'brandlogo', 'brandlogofile', 'brandlogohideonsmall',
'centerlogo', 'centerlogofile', 'centerlogohideonsmall',
'rightlogo', 'rightlogofile', 'rightlogohideonsmall',
'logotopmargin',
'progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'
] %}
{# Tab list: FIRST the "Fonts" tab (where the default/base font is chosen and the
per-element font overrides live), then the "Top of the page" tab (keys =
aTopOfPageKeys), then one tab per remaining category from config.xml like the
core options page (keys = null: all options of that category, except the
top-of-page keys). Category tab ids are slugs of the category name, so they
stay stable regardless of the tab order. #}
{% set aTabs = [] %}
{% if 'Fonts' in aOptionAttributes.categories %}
{% set aTabs = [{ 'id': 'category-fonts', 'label': 'Fonts', 'category': 'Fonts', 'keys': null }] %}
{% endif %}
{% set aTabs = aTabs|merge([{ 'id': 'top-of-page', 'label': 'Top of the page', 'category': 'Top of the page', 'keys': aTopOfPageKeys }]) %}
{% for category in aOptionAttributes.categories %}
{% if category != 'Fonts' and category != 'Top of the page' %}
{% set aTabs = aTabs|merge([{ 'id': 'category-' ~ category|lower|replace({' ': '-'}), 'label': category, 'category': category, 'keys': null }]) %}
{% endif %}
{% endfor %}
{% for tab in aTabs %}
{% endfor %}
{% for tab in aTabs %}
{# Resolve which option keys this tab shows: the top-of-page tab uses the fixed
order of aTopOfPageKeys; a category tab shows its config.xml options (in
config.xml order) minus the top-of-page keys. #}
{% set aTabKeys = tab.keys %}
{% if aTabKeys is null %}
{% set aTabKeys = [] %}
{% for key, attr in aOptionAttributes.optionAttributes %}
{% if key != 'ajaxmode' and attr.category == tab.category and key not in aTopOfPageKeys %}
{% set aTabKeys = aTabKeys|merge([key]) %}
{% endif %}
{% endfor %}
{% else %}
{# the top-of-page tab also picks up options that literally carry the
category "Top of the page" (so config.xml may use it after a reset) #}
{% for key, attr in aOptionAttributes.optionAttributes %}
{% if key != 'ajaxmode' and attr.category == 'Top of the page' and key not in aTabKeys %}
{% set aTabKeys = aTabKeys|merge([key]) %}
{% endif %}
{% endfor %}
{% endif %}
{% for key in aTabKeys %}
{% set attr = aOptionAttributes.optionAttributes[key] ?? null %}
{% if attr is not null %}
{# server-side current value for this option (checked/selected/value) #}
{% set currentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[key] is defined ? aCurrentOptions[key] : (oParentOptions[key] is defined ? oParentOptions[key] : '')) %}
{# parent != '': this field is only visible when the parent option is "on"
(options.js toggles .option-visibility via data-show-if-parent);
the field itself is additionally disabled via data-parent/selector_radio_childfield #}
{% if attr.type != 'checkbox' %}
{% endif %}
{% if attr.type == 'buttons' %}
{# buttons type: one radio per value of options="a|b", labels from optionlabels="A|B" #}
{% set optValues = attr.options|split('|') %}
{% set optLabels = attr.optionlabels|split('|') %}
{% for optValue in optValues %}
{% endfor %}
{% if bInherit %}
{% endif %}
{% elseif attr.type == 'checkbox' %}
{# checkbox: checked = "on", unchecked = "off". The label is inline
(form-check-label), so the generic label above is skipped for this
type. With survey-level inherit, an untouched box keeps the value
"inherit" (options.js: data was-inherit). Children of a parent
switch get selector_radio_childfield + data-parent like the rest. #}
{% elseif attr.type == 'dropdown' %}
{% set ddClasses = 'form-select selector_option_value_field' %}
{% if attr.parent != '' %}{% set ddClasses = ddClasses ~ ' selector_radio_childfield' %}{% endif %}
{% if tab.category == 'Images' %}{% set ddClasses = ddClasses ~ ' selector_image_selector' %}{% endif %}
{% if key == 'font' %}{% set ddClasses = ddClasses ~ ' selector_fontselect' %}{% endif %}
{% elseif attr.type == 'fontselect' %}
{# fontselect (per-element font override): the SAME font choices as the
base "font" dropdown — the optgroups are shared, so bundled and
variant-custom fonts appear here automatically — plus a first option
"Same as base font" (value "base": the views then put no extra class
on the element, it inherits the body font). options.js collects the
packages of ALL .selector_fontselect selects into packages_to_load. #}
{% set fontAttr = aOptionAttributes.optionAttributes['font'] ?? null %}
{% elseif attr.type == 'imagefile' %}
{% elseif attr.type == 'colorpicker' %}
{% if tab.category == 'Images' %}
{# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #}
0%
{% endif %}
{# Footer at the bottom of every tab: "Proudly developed by [Respondage logo]",
linking to https://www.respondage.nl #}
{% if respondageLogo %}
{% endif %}
{% endfor %}
{# Lightbox modal for the image preview buttons #}