
{% extends mode == 'user' ? "user.twig" : "admin.twig" %}

{% set title %}
{% if mode == 'user' -%}
    {{ 'CoreAdminHome_PersonalPluginSettings'|translate }}
{%- else -%}
    {{ 'CoreAdminHome_SystemPluginSettings'|translate }}
{% endif %}
{% endset %}

{% block content %}

    {% import 'macros.twig' as piwik %}
    {% import 'ajaxMacros.twig' as ajax %}
    {% import 'settingsMacros.twig' as settingsMacro %}

    <h2 piwik-enriched-headline>{{ title }}</h2>

    <input type="hidden" name="setpluginsettingsnonce" value="{{ nonce }}">

    <p>
        {{ 'CoreAdminHome_PluginSettingsIntro'|translate }}
        {% for pluginName, settings in pluginsSettings %}
            <a href="#{{ pluginName|e('html_attr') }}">{{ pluginName }}</a>{% if not loop.last %}, {% endif %}
        {% endfor %}
    </p>

    {% for pluginName, pluginSettings in pluginsSettings %}

        <h2 id="{{ pluginName|e('html_attr') }}">{{ pluginName }}</h2>

        {% if pluginSettings.introduction %}
            <p class="pluginIntroduction">
                {{ pluginSettings.introduction }}
            </p>
        {% endif %}

        <div id="pluginSettings" data-pluginname="{{ pluginName|e('html_attr') }}">

            {% for name, setting in pluginSettings.settings %}
                {{ settingsMacro.singleSetting(setting, loop.index) }}
            {% endfor %}

        </div>

    {% endfor %}

    <hr/>

    {{ ajax.errorDiv('ajaxErrorPluginSettings') }}
    {{ ajax.loadingDiv('ajaxLoadingPluginSettings') }}

    <input type="submit" value="{{ 'General_Save'|translate }}" class="pluginsSettingsSubmit submit"/>

{% endblock %}