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

<xf:pageaction if="$feed.isUpdate()">
	<xf:button href="{{ link('feeds/delete', $feed) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:form action="{{ link('feeds/save', $feed) }}" ajax="true" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:if is="$feed.feed_id">
				<xf:textboxrow name="title" value="{$feed}"
					label="{{ phrase('title') }}" />
			</xf:if>

			<xf:textboxrow name="url" value="{$feed}"
				label="{{ phrase('url') }}"
				dir="ltr" />

			<xf:selectrow name="frequency" value="{$feed}"
				label="{{ phrase('fetch_new_entries_every') }}">

				<xf:option value="600">{{ phrase('x_minutes', {'count': '10'}) }}</xf:option>
				<xf:option value="1200">{{ phrase('x_minutes', {'count': '20'}) }}</xf:option>
				<xf:option value="1800">{{ phrase('x_minutes', {'count': '30'}) }}</xf:option>
				<xf:option value="3600">{{ phrase('x_minutes', {'count': '60'}) }}</xf:option>
				<xf:option value="7200">{{ phrase('x_hours', {'count': '2'}) }}</xf:option>
				<xf:option value="14400">{{ phrase('x_hours', {'count': '4'}) }}</xf:option>
				<xf:option value="21600">{{ phrase('x_hours', {'count': '6'}) }}</xf:option>
				<xf:option value="43200">{{ phrase('x_hours', {'count': '12'}) }}</xf:option>
			</xf:selectrow>

			<xf:if is="$feed.feed_id">
				<xf:checkboxrow>
					<xf:option name="active" selected="$feed.active">
						<xf:label>{{ phrase('feed_is_active') }}</xf:label>
						<xf:hint>{{ phrase('disable_to_prevent_feed_import') }}</xf:hint>
					</xf:option>
				</xf:checkboxrow>
			<xf:else />
				<xf:hiddenval name="active">1</xf:hiddenval>
			</xf:if>

			<hr class="formRowSep" />

			<xf:radiorow name="user_id" value="{$feed}"
				label="{{ phrase('posting_user') }}">

				<xf:option value="0">{{ phrase('post_feed_entries_as_guest') }}</xf:option>
				<xf:option value="-1" label="{{ phrase('post_feed_entries_as_following_user') }}" selected="{$feed.User}">
					<xf:textbox name="username" value="{$feed.User.username}" placeholder="{{ phrase('user_name...') }}" ac="single" />
				</xf:option>
			</xf:radiorow>

			<hr class="formRowSep" />

			<xf:selectrow name="node_id" value="{$feed}" id="js-nodeList"
				label="{{ phrase('destination_forum') }}">

				<xf:foreach loop="$forums" value="$forum">
					<xf:option value="{$forum.value}" disabled="{$forum.disabled}" label="{$forum.label}" />
				</xf:foreach>
				<xf:explain>
					{{ phrase('select_forum_for_feed') }}
				</xf:explain>
			</xf:selectrow>

			<xf:prefixinputrow
				textbox-name="title_template"
				textbox-value="{$feed.title_template}"
				maxlength="{{ max_length($feed, 'title_template') }}"
				prefixes="{$prefixes}"
				prefix-value="{$feed.prefix_id}"
				type="thread"
				href="{{ link('forums/prefixes') }}"
				listen-to="#js-nodeList"
				label="{{ phrase('title_template') }}"
				hint="{{ phrase('optional') }}" />

			<xf:textarearow name="message_template" value="{$feed}" rows="5" autosize="true"
				label="{{ phrase('message_template') }}"
				hint="{{ phrase ('you_may_use_bb_code') }}"
				explain="{{ phrase('feed_message_template_explain') }}" />

			<hr class="formRowSep" />

			<xf:checkboxrow label="{{ phrase('options') }}">

				<xf:option name="discussion_visible" selected="$feed.discussion_visible">
					<xf:label>{{ phrase('post_immediately') }}</xf:label>
					<xf:hint>{{ phrase('otherwise_insert_into_moderation_queue') }}</xf:hint>
				</xf:option>
				<xf:option name="discussion_open" selected="$feed.discussion_open">
					<xf:label>{{ phrase('unlocked') }}</xf:label>
					<xf:hint>{{ phrase('people_may_reply_to_this_thread') }}</xf:hint>
				</xf:option>
				<xf:option name="discussion_sticky" selected="$feed.discussion_sticky">
					<xf:label>{{ phrase('sticky') }}</xf:label>
					<xf:hint>{{ phrase('sticky_threads_appear_at_top_of_first_page_of_list_of_threads') }}</xf:hint>
				</xf:option>
			</xf:checkboxrow>
		</div>
		<xf:submitrow sticky="true" icon="save"><xf:html>
			<xf:button type="submit" name="preview" icon="preview" />
		</xf:html></xf:submitrow>
	</div>
</xf:form>