{% load pages_tags i18n cache %}

<tr id="page-row-{{ page.id }}"
    class="child-of-{{ page.parent_id }} draggable"
    data-mptt-left="{{ page.lft }}"
    data-mptt-right="{{ page.rght }}"
    data-mptt-tree-id="{{ page.tree_id }}"
    >
    <td class="selection-cell action-checkbox-column"><input class="action-select" type="checkbox" name="_selected_action" value="{{ page.id }}"/></td>
    <th class="title-cell">
        <div class="title-cell-container" style="margin-{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ page.margin_level }}em">
            {% if page.children.count %}
                <a href="#" class="expand-collapse {% if expanded %}expanded{% endif %}" id="c{{ page.id }}">
                    <span class="expand">+</span>
                    <span class="collapse">-</span>
                    <img class="expand-loading" src="{{ PAGES_MEDIA_URL }}images/loading.gif" alt="loading" />
                </a>
            {% endif %}
            <a href="{{ page.id }}/" class="title changelink
            {% if page.pagelink_broken or page.externallink_broken %}broken{% endif %}">
            {% get_content page "slug" as slug %}
            {% if slug %}
                {{ slug }}
            {% else %}
                {% trans "undefined" %}
            {% endif %}
            {% if page.redirect_to or page.redirect_to_url %}
            <img class="redirected" src="{{ PAGES_MEDIA_URL }}images/icons/redirect.gif" alt="redirected" />{% endif %}</a>

            <span class="message"></span>

            <div class="actions-pages">
                <a class="viewlink" href="{% show_absolute_url page %}" target="_blank" title="{% trans "view this page" %}"></a>
                <a class="movelink" id="move-link-{{ page.id }}" href="#" title="{% trans "move this page" %}"></a>
                <a class="addlink gpr-addlink" id="add-link-{{ page.id }}" href="#" title="{% trans "insert a new page here" %}"></a>
                {% if not page.children.count %}
                <a class="deletelink" href="{{ page.id }}/delete/" title="{% trans "delete this page" %}"></a>
                {% else %}
                <a></a>
                {% endif %}
                <a class="cancellink" href="#" title="{% trans "don&#x27;t move this page" %}">{% trans "cancel" %}</a>
            </div>

            <div id="move-target-{{ page.id }}" class="insert container">
                <a class="cancellink" href="#" title="{% trans "don&#x27;t insert a new page here" %}">{% trans "cancel" %}</a>
                <a href="#" class="move-target left button" title="{% trans "insert above" %}"></a>
                <a href="#" class="move-target right button" title="{% trans "insert below" %}"></a>
                <a href="#" class="move-target first-child button" title="{% trans "insert as child" %}"></a>
            </div>
        </div>
    </th>
    <td class="language-cell">
        <ul>
            {% for lang in PAGE_LANGUAGES %}
                <li>
                    {% if page|has_content_in:lang.0 %}
                        {% if not page|language_content_up_to_date:lang.0 %}
                            →
                        {% endif %}
                        <a href="{{ url }}{{ page.id }}/change/?language={{ lang.0 }}" class="changelink"
                            title="{% blocktrans with lang.1|lower as lang %}edit {{ lang }} translation{% endblocktrans %}">{{ lang.0 }}</a>
                    {% else %}
                        <a href="{{ url }}{{ page.id }}/change/?language={{ lang.0 }}" class="changelink addlang"
                            title="{% blocktrans with lang.1|lower as lang %}create {{ lang }} translation{% endblocktrans %}">{{ lang.0 }}</a>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    </td>
    <td class="last-modification-cell">
        {{ page.last_modification_date|date:_("DATETIME_FORMAT") }}
    </td>
    {% if can_publish %}
        <td class="publish-cell">
            {% ifequal page.status page.DRAFT %}
                <img src="{{ PAGES_MEDIA_URL }}images/icons/draft.gif" alt="draft" />
            {% else %}{% ifequal page.status page.PUBLISHED %}
                <img src="{{ PAGES_MEDIA_URL }}images/icons/published.gif" alt="published" />
            {% else %}
                <img src="{{ PAGES_MEDIA_URL }}images/icons/hidden.gif" alt="hidden"/>
            {% endifequal %}{% endifequal %}
            &nbsp;
            <select class="publish-select" name="select-status-{{ page.id }}">
                <option value="0" {% ifequal page.status page.DRAFT %}selected="selected"{% endifequal %}>{% trans "Draft" %}</option>
                <option value="1" {% ifequal page.status page.PUBLISHED %}selected="selected"{% endifequal %}>{% trans "Published" %}</option>
                <option value="3" {% ifequal page.status page.HIDDEN %}selected="selected"{% endifequal %}>{% trans "Hidden" %}</option>
            </select>
        </td>
    {% else %}
        <td>
            {% ifequal page.status page.DRAFT %}{% trans "Draft" %}{% endifequal %}
            {% ifequal page.status page.PUBLISHED %}{% trans "In navigation" %}{% endifequal %}
            {% ifequal page.status page.HIDDEN %}{% trans "Hidden" %}{% endifequal %}
        </td>
    {% endif %}
    <td class="template-cell">
        {{ page.get_template_name }}
    </td>
    <td class="author-cell">
        {% cache 10000 page_author page.author_id %}
            {% firstof page.author.user page.author.get_full_name page.author.first_name page.author.username %}
        {% endcache %}
    </td>
</tr>

{% if expanded %}
    {% for child in page.children.all %}
        {% pages_admin_menu child %}
    {% endfor %}
{% endif %}
