{% load pages_tags i18n adminmedia cache %}

{% if has_permission %}
    <tr id="page-row-{{ page.id }}" class="child-of-{{ page.parent_id }}">
        <th class="title-cell">
            <div class="title-cell-container" style="margin-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="{{ url }}{{ page.id }}/" class="title changelink">{% show_content page "slug" %}</a>
                
                <div class="actions">
                    <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" id="add-link-{{ page.id }}" href="#" title="{% trans "insert a new page here" %}"></a>
                    <a class="deletelink" href="{{ page.id }}/delete/" title="{% trans "delete this page" %}"></a>
                    <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" title="{% trans "insert above" %}"></a>
                    <a href="#" class="move-target right" title="{% trans "insert below" %}"></a>
                    <a href="#" class="move-target first-child" 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 %}
                            <a href="{{ url }}{{ page.id }}/?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 }}/?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="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 }}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 "In navigation" %}</option>
                <option value="3" {% ifequal page.status page.HIDDEN %}selected="selected"{% endifequal %}>{% trans "Hidden" %}</option>
            </select>
        </td>
        <td class="template-cell">
            {{ page.get_template_name }}
        </td>
        <td class="author-cell">
            {% cache 10000 page_author page.author_id %}
                {% firstof page.author.get_full_name page.author.first_name page.author.username %}
            {% endcache %}
        </td>
    </tr>
{% endif %}

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