puphpet/puphpet

View on GitHub
src/PuphpetBundle/Resources/views/apache/filesmatch.html.twig

Summary

Maintainability
Test Coverage
{% set uniqid = uniqid ?? uniqid('filesmatch_') %}
{% set idBase = "apache-vhosts-#{vhostId}-directories-#{uniqid}" %}
{% set nameBase = "apache[vhosts][#{vhostId}][directories][#{uniqid}]" %}
{% set custom_fragment = (directory.custom_fragment is defined) ? directory.custom_fragment : [] %}

{% set setenvs = (directory.setenv is defined) ? directory.setenv : [] %}

<div id="{{ idBase }}" data-uniqid="{{ uniqid }}" data-name="{{ nameBase }}"
     class="tab-pane {{ active is defined and active ? 'active' }}">
    <input type="hidden" name="{{ nameBase }}[provider]"
           value="{{ directory.provider }}" />

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-path">
            Path
        </label>
        <input type="text" id="{{ idBase }}-path"
               name="{{ nameBase }}[path]"
               placeholder="\.php$" class="form-control"
               value="{{ directory.path }}" />
        <div class="help-block">
            Regex allowed.
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-sethandler">
            Set Handler
        </label>
        <input type="text" id="{{ idBase }}-sethandler"
               name="{{ nameBase }}[sethandler]"
               placeholder="proxy:fcgi://127.0.0.1:9000" class="form-control"
               value="{{ directory.sethandler }}" />
        <div class="help-block">
            Regex allowed.
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-setenv">
            Environment Variables
        </label>
        <select id="{{ idBase }}-setenv"
                name="{{ nameBase }}[setenv][]"
                multiple class="form-control select-tags-editable">
            {% for setenv in setenvs %}
                <option selected value="{{ setenv }}">{{ setenv }}</option>
            {% endfor %}
        </select>
        <div class="help-block">
            <code>name value</code>, separated by comma.
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-custom_fragment">
            Additional Settings
        </label>
        <select id="{{ idBase }}-custom_fragment"
                name="{{ nameBase }}[custom_fragment][]"
                multiple class="form-control select-tags-editable">
            {% for option in custom_fragment %}
                <option selected value="{{ option }}">{{ option }}</option>
            {% endfor %}
        </select>
        <div class="help-block">
            Additional rules to append to FilesMatch block. Separated by comma.
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="panel panel-success">
        <div class="panel-heading">Rewrites</div>
        <div class="panel-body">
            <ul class="nav nav-tabs nested-tabs sortable">
                <li class="add">
                    <a href="{{ path('puphpet.apache.rewrite', {'vhostId': vhostId, 'directiveId': uniqid}) }}"
                       data-toggle="add-block">
                        <i class="fa fa-plus"></i> Add</a>
                </li>
                {% for index, rewrite in rewrites %}
                    {% set blockId = "#{idBase}-rewrites-#{index}" %}
                    {% set blockName = "#{nameBase}[rewrites][#{index}]" %}
                    <li class="{{ loop.first ? 'active' }}">
                        <a href="#" data-target="#{{ blockId }}"
                           data-toggle="tab">{{ index }}</a>
                        <div class="btn-group">
                            <button type="button" class="btn btn-default"
                                    data-toggle="delete-block"
                                    data-target="#{{ blockId }}">
                                <i class="fa fa-close"></i></button>
                        </div>
                        <input type="hidden" name="{{ blockName }}" value="1" />
                    </li>
                {% endfor %}
            </ul>

            <div class="tab-content">
                <div class="empty-tabs">
                    <i class="fa fa-share fa-rotate-270" aria-hidden="true"></i>
                    Click to add a rewrite rule
                </div>
                {% for index, rewrite in rewrites %}
                    {% include "PuphpetBundle:apache:rewrite.html.twig" with {
                        'vhostId': vhostId,
                        'directiveId': uniqid,
                        'uniqid': index,
                        'active': loop.first ? true : false,
                    } %}
                {% endfor %}
            </div>
        </div>
    </div>

    <div class="clearfix"></div>
</div>