{% load i18n admin_static %}
{% if result_hidden_fields %}
    <div class="hiddenfields">{# DIV for HTML validation #}
        {% for item in result_hidden_fields %}{{ item }}{% endfor %}
    </div>
{% endif %}

<div class="results">
    <table id="result_list">
    <thead>
        <tr>
            {% for header in result_headers %}
                <th scope="col" {{ header.class_attrib }}>
                   {% if header.sortable %}
                     {% if header.sort_priority > 0 %}
                       <div class="sortoptions">
                         {% if num_sorted_fields > 1 %}<span class="sortpriority" title="{% blocktrans with priority_number=header.sort_priority %}Sorting priority: {{ priority_number }}{% endblocktrans %}">{{ header.sort_priority }}</span>{% endif %}
                         <a class="sortremove" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"><span class="icon-cross"></span> </a>
                         <a href="{{ header.url_toggle }}" class="toggle {% if header.ascending %}ascending{% else %}descending{% endif %}" title="{% trans "Toggle sorting" %}"></a>
                       </div>
                     {% endif %}
                   {% endif %}
                   <div class="text">{% if header.sortable %}<a href="{{ header.url_primary }}">{{ header.text|capfirst }}</a>{% else %}<span>{{ header.text|capfirst }}</span>{% endif %}</div>
                   <div class="clear"></div>
                </th>
            {% endfor %}
        </tr>
    </thead>
    <tbody>
        {% if cl.result_count == 0 %}
            <tr><td colspan="{{ result_headers|length }}" style="text-align: center;">
                <strong>{{ cl.result_count }}</strong> {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name }}{% else %}{{ cl.opts.verbose_name_plural }}{% endifequal %}

                {% if cl.result_count != cl.full_result_count %}
                    (<a href="?{% if cl.is_popup %}{{ POPUP_VAR }}=1{% endif %}">{% trans 'try to reset filters' %}</a>)
                {% endif %}
            </td></tr>
        {% endif %}
        {% for result in results %}
            {% if result.form.non_field_errors %}
                <tr><td colspan="{{ result|length }}">{{ result.form.non_field_errors }}</td></tr>
            {% endif %}
            <tr class="{% cycle 'row1' 'row2' %}">{% for item in result %}{{ item }}{% endfor %}</tr>
        {% endfor %}
    </tbody>
    </table>
</div>
