<xf:if is="$site.isInsert()">
	<xf:title>{{ phrase('add_bb_code_media_site') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_bb_code_media_site:') }} {$site.site_title}</xf:title>
</xf:if>

<xf:pageaction if="$site.isUpdate() AND $site.canEdit()">
	<xf:button href="{{ link('bb-code-media-sites/delete', $site) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:if is="!$site.canEdit()">
	<div class="blockMessage blockMessage--important blockMessage--iconic">
		{{ phrase('only_limited_fields_in_item_may_be_edited') }}
	</div>
</xf:if>

<xf:form action="{{ link('bb-code-media-sites/save', $site) }}" ajax="true" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:textboxrow name="media_site_id" value="{$site}"
				readonly="{{ $site.exists() ? true : false }}"
				label="{{ phrase('media_site_id') }}"
				explain="{{ phrase('this_will_be_used_to_identify_media_site_to_load_in_bb_code') }}"
				dir="ltr" />

			<xf:macro id="addon_macros::addon_edit" arg-addOnId="{$site.addon_id}" />

			<hr class="formRowSep" />

			<xf:textboxrow name="site_title" value="{$site}"
				readonly="{{ !$site.canEdit() }}"
				label="{{ phrase('site_title') }}" />

			<xf:textboxrow name="site_url" value="{$site}"
				readonly="{{ !$site.canEdit() }}"
				label="{{ phrase('site_url') }}"
				dir="ltr" />

			<xf:checkboxrow>
				<xf:option name="supported" value="1" selected="$site.supported">
					{{ phrase('show_this_site_on_list_of_supported_sites_shown_to_visitors') }}
				</xf:option>
			</xf:checkboxrow>

			<xf:checkboxrow>
				<xf:option name="active" value="1" selected="$site.active"
					hint="{{ ($xf.development AND $site.addon_id) ? phrase('field_value_maintained_addon_upgrade_explain') : '' }}">
					{{ phrase('enabled') }}
				</xf:option>
			</xf:checkboxrow>

			<hr class="formRowSep" />

			<xf:textarearow name="match_urls" value="{$site}" autosize="true" code="true"
				readonly="{{ !$site.canEdit() }}"
				label="{{ phrase('match_urls') }}"
				explain="{{ phrase('you_may_use_star_as_wildcard_and_id_to_point_to_media_id') }}"
				dir="ltr" />

			<xf:codeeditorrow name="embed_html" value="{{ $site.exists() ? $site.MasterTemplate.template : '' }}"
				mode="html"
				readonly="{{ !$site.canEdit() }}"
				hint="{{ $site.isUpdate() ? $site.getTemplateName() : '' }}"
				class="codeEditor--short"
				label="{{ phrase('embed_template') }}">
				<xf:explain>
					{{ phrase('enter_id_where_you_want_user_entered_media_id_to_be_used') }}<br />
					<br />
					<xf:if is="$site.canEdit()">
						{{ phrase('editing_master_embed_html_explain') }}
					<xf:else />
						{{ phrase('unable_edit_master_embed_html_explain') }}
					</xf:if>
				</xf:explain>
			</xf:codeeditorrow>
		</div>

		<h3 class="block-formSectionHeader">
			<span class="collapseTrigger collapseTrigger--block" data-xf-click="toggle" data-target="< :up:next">
				<span class="block-formSectionHeader-aligner">{{ phrase('oembed_options') }}</span>
			</span>
		</h3>
		<div class="block-body block-body--collapsible">
			<xf:checkboxrow explain="{{ phrase('oembed_explain') }}" readonly="{{ !$site.canEdit() }}">
				<xf:option name="oembed_enabled" selected="{$site.oembed_enabled}">{{ phrase('use_oembed') }}</xf:option>
			</xf:checkboxrow>

			<xf:textboxrow name="oembed_api_endpoint" value="{$site}"
				readonly="{{ !$site.canEdit() }}"
				label="{{ phrase('oembed_api_endpoint') }}"
				dir="ltr" />

			<xf:textboxrow name="oembed_url_scheme" value="{$site}"
				label="{{ phrase('oembed_url_scheme') }}"
				readonly="{{ !$site.canEdit() }}"
				explain="{{ phrase('oembed_url_scheme_explain') }}"
				dir="ltr" />

			<xf:checkboxrow
				explain="{{ phrase('oembed_retain_scripts_explain') }}">
				<xf:option name="oembed_retain_scripts" selected="{$site.oembed_retain_scripts}"
					readonly="{{ !$site.canEdit() }}"
					label="{{ phrase('oembed_retain_scripts') }}" />
			</xf:checkboxrow>
		</div>

		<h3 class="block-formSectionHeader">
			<span class="collapseTrigger collapseTrigger--block" data-xf-click="toggle" data-target="< :up:next">
				<span class="block-formSectionHeader-aligner">{{ phrase('advanced_options') }}</span>
			</span>
		</h3>
		<div class="block-body block-body--collapsible">
			<xf:checkboxrow label="{{ phrase('regular_expression_matching') }}" readonly="{{ !$site.canEdit() }}">
				<xf:option name="match_is_regex" selected="$site.match_is_regex"
					label="{{ phrase('match_urls_are_regex') }}" />
				<xf:explain>{{ phrase('match_urls_are_regex_explain') }}</xf:explain>
			</xf:checkboxrow>

			<hr class="formRowSep" />

			<xf:formrow rowtype="input"
				label="{{ phrase('match_url_callback') }}"
				explain="{{ phrase('match_url_callback_explain') }}">
				<xf:macro id="helper_callback_fields::callback_fields"
					arg-namePrefix="match_callback"
					arg-data="{$site}"
					arg-readOnly="{{ !$site.canEdit() }}"/>
			</xf:formrow>

			<hr class="formRowSep" />

			<xf:formrow rowtype="input"
				label="{{ phrase('embed_html_callback') }}"
				explain="{{ phrase('embed_html_callback_explain') }}">
				<xf:macro id="helper_callback_fields::callback_fields"
					arg-namePrefix="embed_html_callback"
					arg-data="{$site}"
					arg-readOnly="{{ !$site.canEdit() }}"/>
			</xf:formrow>

			<hr class="formRowSep" />

			<xf:textarearow name="cookie_third_parties" value="{$site.cookie_third_parties}"
				readonly="{{ !$site.canEdit() }}"
				label="{{ phrase('cookie_third_parties') }}"
				explain="{{ phrase('cookie_third_parties_explain') }}" />
		</div>

		<xf:submitrow sticky="true" icon="save">
			<xf:html>
				<xf:button type="submit" icon="save" name="exit">{{ phrase('save_and_exit') }}</xf:button>
			</xf:html>
		</xf:submitrow>
	</div>
</xf:form>