<xf:if is="$phrase.isInsert()">
	<xf:title>{{ phrase('add_phrase') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_phrase:') }} {$phrase.title}</xf:title>
</xf:if>

<xf:page option="breadcrumbPath" value="languages" />
<xf:breadcrumb href="{{ link('languages/phrases', $language) }}">{$language.title} - {{ phrase('phrases') }}</xf:breadcrumb>

<xf:pageaction if="$phrase.isUpdate() AND $phrase.language_id == $language.language_id">
	<xf:if is="$language.language_id">
		<xf:button href="{{ link('phrases/delete', $phrase, {'_xfRedirect': $redirect}) }}" overlay="true">{{ phrase('revert') }}</xf:button>
	<xf:else />
		<xf:button href="{{ link('phrases/delete', $phrase, {'_xfRedirect': $redirect}) }}" icon="delete" overlay="true" />
	</xf:if>
</xf:pageaction>

<xf:form action="{{ link('phrases/save', $phrase) }}" ajax="true" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:formrow label="{{ phrase('language') }}">
				{$language.title}
				<xf:hiddenval name="language_id">{$language.language_id}</xf:hiddenval>
			</xf:formrow>

			<xf:textboxrow name="title" value="{$phrase}"
				label="{{ phrase('title') }}"
				hint="{{ phrase('must_be_unique') }}"
				autofocus="autofocus"
				autocomplete="off"
				dir="ltr" />

			<xf:if is="$phrase.isUpdate() AND $language.language_id > 0 AND $phrase.Master.phrase_text">
				<xf:formrow label="{{ phrase('master_value') }}">
					<div class="u-ltr">
						{{ $phrase.language_id == 0 ? $phrase.phrase_text|nl2br : $phrase.Master.phrase_text|nl2br }}
					</div>
				</xf:formrow>
			</xf:if>

			<xf:textarearow name="phrase_text" value="{$phrase}"
				dir="{$language.text_direction}" autosize="true"
				label="{{ phrase('phrase_text') }}"
				explain="{{ phrase('phrase_text_explain') }}" />

			<xf:if is="!$language.language_id">
				<xf:macro id="addon_macros::addon_edit" arg-addOnId="{$phrase.addon_id}" />
			<xf:else />
				<xf:hiddenval name="addon_id">{$phrase.addon_id}</xf:hiddenval>
			</xf:if>

			<xf:if is="!$language.language_id">
				<xf:checkboxrow>
					<xf:option name="global_cache" selected="{$phrase.global_cache}">{{ phrase('cache_this_phrase_globally') }}</xf:option>
				</xf:checkboxrow>
			</xf:if>
		</div>
		<xf:submitrow sticky="true" icon="save">
			<xf:html>
				<xf:button type="submit" icon="save" name="exit">{{ phrase('save_and_exit') }}</xf:button>
				<input type="hidden" name="_page" value="{$_page}" />
			</xf:html>
		</xf:submitrow>
	</div>
	<xf:redirect />
</xf:form>