{% extends "admin/change_form.html" %}
{% load i18n admin_static admin_modify cms_admin %}
{% load url from future %}

{% block title %}{% trans "Change a page" %}{% endblock %}

{% block extrahead %}
{{ block.super }}
<script type="text/javascript" src="{% static "admin/js/urlify.js" %}"></script>
<script type="text/javascript" src="{% static "cms/js/plugins/cms.base.js" %}"></script>
<script type="text/javascript" src="{% static "cms/js/plugins/cms.changeform.js" %}"></script>
{% endblock %}

{% block breadcrumbs %}
{% if not is_popup %}
<div class="breadcrumbs">
	<a href="../../../">{% trans "Home" %}</a> &rsaquo;
	<a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
	{% if can_change %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
	{% if add %}{% trans "Add" %} {{ opts.verbose_name }}{% else %}{{ original.get_title|truncatewords:"18" }}{% endif %}
</div>
{% endif %}
{% endblock %}

{% block content %}
<div id="content-main">

{% block object-tools %}{% endblock %}

<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="?language={{ language }}{%if request.GET.target %}&amp;target={{ request.GET.target }}{% endif %}&amp;{%if request.GET.target %}position={{ request.GET.position }}{% endif %}" method="post" id="page_form">
{% csrf_token %}
{% block form_top %}{% endblock %}
{{ adminForm.fields.parent }}

<div style="display: none;"><input type="hidden" name="language" value="{{language}}" id="id_language"/></div>

{% if show_language_tabs and not show_permissions %}
<div id="page_form_lang_tabs">
	{% for lang_code, lang_name in language_tabs %}
		<input type="button" onclick="CMS.API.changeLanguage('./?language={{lang_code}}');"
			class="language_button {% ifequal lang_code language %}selected{% else %}{% if not lang_code in filled_languages %} notfilled{% endif %}{% endifequal %}"
			id="debutton" name="{{lang_code}}" value="{{lang_name}}" />
	{% endfor %}
	<div class="lang_tabs_line"></div>
</div>
{% endif %}

<div id="lang_tab_content">
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if save_on_top %}{% submit_row %}{% endif %}
{% if errors %}
<p class="errornote">
{% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
</p>
<ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}

{% for fieldset in adminform %}
	{% include "admin/cms/page/includes/fieldset.html" %}
{% endfor %}

{% for inline_admin_formset in inline_admin_formsets %}
	{% include inline_admin_formset.opts.template %}
{% endfor %}

{% if show_permissions %}
	{% if CMS_PERMISSION and can_change_permissions %}
	<div class="inline-group">
		<div class="tabular inline-related">
			<fieldset id="inherited_permissions" class="module aligned collapse">
			  <h2>{% trans 'All permissions' %}</h2>
			  <div class="loading" rel="../permissions/">{% trans 'Loading...' %}</div>
			</fieldset>
		</div>
	</div>
	{% endif %}
	<div class="inline-group">
		<div class="tabular inline-related">
			<fieldset id="page_states" class="module aligned collapse">
			  <h2 class="load_remote">{% trans 'Page states' %}</h2>
			  <div class="loading" rel="../moderation-states/">{% trans 'Loading...' %}</div>
			</fieldset>
		</div>
	</div>
{% endif %}

{% block after_related_objects %}{% endblock %}

{% if add %}
	<div class="submit-row"{% if is_popup %} style="overflow: auto;"{% endif %}>
		<input type="submit" name="_save" class="default" value="{% trans 'Save' %}" {{ onclick_attrib }}/>
		<input type="submit" name="_continue" value="{% trans 'Save and continue editing' %}" {{ onclick_attrib }}/>
	</div>
{% else %}
	{% page_submit_row %}
{% endif %}
</div>
</form>
</div>

{% for url in unihandecode_urls %}<script type="text/javascript" src="{{ url }}"></script>{% endfor %}
{% if unihandecode_urls %}
<script type="text/javascript">
	var UNIHANDECODER = unihandecode.Unihan('{{ unihandecode_lang }}');
</script>
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

{% endblock %}