{% extends "wagtailadmin/base.html" %}
{% load wagtailadmin_tags %}
{% load gravatar %}
{% load i18n %}
{% block titletag %}{% blocktrans with title=page.title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}menu-explorer page-editor model-{{ content_type.model }}{% endblock %}

{% block content %}
    {% page_permissions page as page_perms %}
    <header class="merged tab-merged nice-padding">
        {% include "wagtailadmin/shared/breadcrumb.html" with page=page %}

        <div class="row row-flush">
            <div class="left col9">
                <h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page.title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }} <span>{{ title }}</span>{% endblocktrans %}</h1>
            </div>
            <div class="right col3">
                {% trans "Status" %}
                {% if page.live %}
                    <a href="{{ page.url }}" class="status-tag {% if page.live %}primary{% endif %}">{{ page.status_string }}</a>
                {% else %}
                    <span class="status-tag">{{ page.status_string }}</span>
                {% endif %}

                {% include "wagtailadmin/pages/_privacy_switch.html" with page=page page_perms=page_perms only %}
                {% include "wagtailadmin/pages/_lock_switch.html" %}
            </div>
        </div>
    </header>

    <form id="page-edit-form" action="{% url 'wagtailadmin_pages_edit' page.id %}" method="POST">
        {% csrf_token %}
        {{ edit_handler.render_form_content }}

        <footer>
            <ul>
                <li class="actions">
                    <div class="dropdown dropup dropdown-button match-width">
                        <input type="submit" value="{% if page.locked %}{% trans 'Page locked' %}{% else %}{% trans 'Save draft' %}{% endif %}" class="button" {% if page.locked %}disabled {% endif %} />
                        
                        {% if not page.locked %}
                            <div class="dropdown-toggle icon icon-arrow-up"></div>
                            <ul role="menu">
                                {% if page_perms.can_unpublish %}
                                    <li><a href="{% url 'wagtailadmin_pages_unpublish' page.id %}">{% trans 'Unpublish' %}</a></li>
                                {% endif %}
                                {% if page_perms.can_delete %}
                                    <li><a href="{% url 'wagtailadmin_pages_delete' page.id %}" class="shortcut">{% trans 'Delete' %}</a></li>
                                {% endif %}
                                {% if page_perms.can_publish %}
                                    <li><input type="submit" name="action-publish" value="{% trans 'Publish' %}" class="button" /></li>
                                {% endif %}
                                <li><input type="submit" name="action-submit" value="{% trans 'Submit for moderation' %}" class="button" /></li>
                            </ul>
                        {% endif %}
                    </div>
                </li>

                <li class="actions preview">
                    {% trans 'Preview' as preview_label %}
                    {% if preview_modes|length > 1 %}
                        <div class="dropdown dropup dropdown-button match-width">
                            {% include "wagtailadmin/pages/_preview_button_on_edit.html" with label=preview_label icon=1 %}
                            <div class="dropdown-toggle icon icon-arrow-up"></div>
                            <ul role="menu">
                                {% for mode_name, mode_display_name in preview_modes %}
                                    <li>
                                        {% include "wagtailadmin/pages/_preview_button_on_edit.html" with mode=mode_name label=mode_display_name %}
                                    </li>
                                {% endfor %}
                            </ul>
                        </div>
                    {% else %}
                        {% include "wagtailadmin/pages/_preview_button_on_edit.html" with label=preview_label icon=1 %}
                    {% endif %}
                </li>

                <li class="meta">
                    <p class="modified">
                        {% if page.get_latest_revision %}
                            {% blocktrans with last_mod=page.get_latest_revision.created_at %}Last modified: {{ last_mod }}{% endblocktrans %}
                            {% if page.get_latest_revision.user %}
                                {% blocktrans with modified_by=page.get_latest_revision.user.get_full_name|default:page.get_latest_revision.user.get_username %}by {{ modified_by }}{% endblocktrans %}
                                {% if page.get_latest_revision.user.email %}
                                    <span class="avatar small icon icon-user"><img src="{% gravatar_url page.get_latest_revision.user.email 25 %}" /></span>
                                {% endif %}
                            {% endif %}
                        {% endif %}
                    </p>
                </li>
            </ul>
        </footer>
    </form>

{% endblock %}

{% block extra_css %}
    {% include "wagtailadmin/pages/_editor_css.html" %}
{% endblock %}
{% block extra_js %}
    {% include "wagtailadmin/pages/_editor_js.html" %}
{% endblock %}
