<xf:if is="$bbCode.isInsert()">
	<xf:title>{{ phrase('add_bb_code') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_bb_code:') }} [{$bbCode.bb_code_id}]</xf:title>
</xf:if>

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

<xf:if is="{{ !$bbCode.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-codes/save', $bbCode) }}" ajax="true" class="block">
	<div class="block-container">

		<div class="block-body">
			<xf:textboxrow name="bb_code_id" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('bb_code_tag') }}"
				dir="ltr" />

			<xf:textboxrow name="title" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('title') }}" />
			<xf:textarearow name="desc" value="{$bbCode}" autosize="true"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('description') }}" />

			<xf:radiorow name="bb_code_mode" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('replacement_mode') }}">

				<xf:option value="replace">{{ phrase('simple_replacement') }}</xf:option>
				<xf:option value="callback">{{ phrase('php_callback') }}</xf:option>
			</xf:radiorow>

			<xf:radiorow name="has_option" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('supports_option_parameter') }}">

				<xf:option value="yes">{{ phrase('yes') }}</xf:option>
				<xf:option value="no">{{ phrase('no') }}</xf:option>
				<xf:option value="optional" explain="{{ phrase('bb_code_tag_will_work_with_and_without_option_provided') }}">
					{{ phrase('optional') }}
				</xf:option>
			</xf:radiorow>

			<xf:codeeditorrow name="replace_html" value="{$bbCode.replace_html}"
				mode="html" data-line-wrapping="true"
				readonly="{{ !$bbCode.canEdit() }}"
				class="codeEditor--autoSize"
				label="{{ phrase('html_replacement') }}"
				explain="{{ phrase('use_option_and_text_in_custom_bb_code') }}" />

			<xf:macro id="helper_callback_fields::callback_row"
				arg-label="{{ phrase('php_callback') }}"
				arg-explain="{{ phrase('custom_bb_code_callback_will_receive_parameters') }}"
				arg-data="{$bbCode}"
				arg-readOnly="{{ !$bbCode.canEdit() }}" />

			<hr class="formRowSep" />

			<xf:radiorow name="editor_icon_type" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('editor_icon') }}">

				<xf:option value="">{{ phrase('none') }}</xf:option>
				<xf:option value="fa" label="{{ phrase('font_awesome_icon') }}">
					<xf:textbox name="editor_icon_fa"
						readonly="{{ !$bbCode.canEdit() }}"
						value="{{ $bbCode.editor_icon_type == 'fa' ? $bbCode.editor_icon_value : '' }}"
						maxlength="{{ max_length($bbCode, 'editor_icon_value') }}"
						dir="ltr" />
				</xf:option>
				<xf:option value="image" label="{{ phrase('image') }}">
					<xf:assetupload name="editor_icon_image" asset="editor_icons"
						readonly="{{ !$bbCode.canEdit() }}"
						value="{{ $bbCode.editor_icon_type == 'image' ? $bbCode.editor_icon_value : '' }}"
						maxlength="{{ max_length($bbCode, 'editor_icon_value') }}" />
				</xf:option>
			</xf:radiorow>

			<hr class="formRowSep" />

			<xf:textarearow name="example" value="{$bbCode}" autosize="true"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('example_usage') }}"
				explain="{{ phrase('if_provide_example_bb_code_appear_on_bb_code_help_page') }}" />

			<xf:textarearow name="output" value="{$bbCode}" autosize="true"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('example_output') }}"
				explain="{{ phrase('control_how_example_appear_on_bb_code_help_page') }}" />

			<hr class="formRowSep" />

			<xf:checkboxrow>
				<xf:option name="allow_signature" value="1" selected="$bbCode.allow_signature">
					{{ phrase('allow_this_bb_code_in_signatures') }}
				</xf:option>
			</xf:checkboxrow>

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

			<xf:macro id="addon_macros::addon_edit" arg-addOnId="{$bbCode.addon_id}" />
		</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:textarearow name="option_regex" value="{$bbCode}" code="true" autosize="true"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('option_match_regular_expression') }}"
				explain="{{ phrase('if_provided_tag_only_be_valid_if_option_matches_regex') }}" />

			<xf:checkboxrow label="{{ phrase('within_this_bb_code') }}" readonly="{{ !$bbCode.canEdit() }}">
				<xf:option name="disable_smilies" value="1" selected="$bbCode.disable_smilies">
					{{ phrase('disable_smilies') }}
				</xf:option>
				<xf:option name="disable_nl2br" value="1" selected="$bbCode.disable_nl2br">
					{{ phrase('disable_line_break_conversion') }}
				</xf:option>
				<xf:option name="disable_autolink" value="1" selected="$bbCode.disable_autolink">
					{{ phrase('disable_auto_linking') }}
				</xf:option>
				<xf:option name="plain_children" value="1" selected="$bbCode.plain_children">
					{{ phrase('stop_parsing_bb_code') }}
				</xf:option>
			</xf:checkboxrow>

			<xf:checkboxrow readonly="{{ !$bbCode.canEdit() }}">
				<xf:option name="allow_empty" value="1" selected="$bbCode.allow_empty"
					label="{{ phrase('display_html_replacement_when_empty') }}"
					explain="{{ phrase('if_selected_replacement_html_displayed_no_text_inside_bb_code') }}" />
			</xf:checkboxrow>

			<xf:numberboxrow name="trim_lines_after" value="{$bbCode}"
				readonly="{{ !$bbCode.canEdit() }}"
				label="{{ phrase('trim_line_breaks_after') }}"
				explain="{{ phrase('if_tag_is_block_level_may_want_to_ignore_line_breaks') }}" />

			<hr class="formRowSep" />

			<xf:codeeditorrow name="replace_html_email" value="{$bbCode.replace_html_email}"
				mode="html" data-line-wrapping="true"
				readonly="{{ !$bbCode.canEdit() }}"
				class="codeEditor--autoSize"
				label="{{ phrase('html_email_replacement') }}"
				explain="{{ phrase('if_provided_bb_code_replace_html_email_desc') }}" />

			<xf:codeeditorrow name="replace_text" value="{$bbCode.replace_text}"
				mode="text" data-line-wrapping="true"
				readonly="{{ !$bbCode.canEdit() }}"
				class="codeEditor--autoSize"
				label="{{ phrase('text_replacement') }}"
				explain="{{ phrase('if_provided_bb_code_replace_text_desc') }}" />
		</div>

		<xf:submitrow sticky="true" icon="save" />
	</div>

</xf:form>