edit_post.naml

<macro name="edit_post" requires="servlet">
	<n.node_page.>
		<n.if.not.visitor.can_edit.page_node>
			<then>
				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
			</then>
		</n.if.not.visitor.can_edit.page_node>
		<n.if.not.is_submitted_form>
			<then>
				<n.subject_field.set_value value="[n.page_node.raw_subject/]" />
				<n.html_format_field.set_value value="[n.page_node.message.is_html_format/]" />
				<n.message_field.set_value value="[n.page_node.message.as_editable/]" />
				<n.alert_field.set_value value="[n.page_node.visitor_is_subscribed_to_topic/]" />
				<n.page_node.init_edit_post_custom_fields/>
			</then>
			<else>
				<n.catch_exception. id="save-block">
					<n.edit_page_node. commit="[n.not.is_preview/]">
						<n.set_subject subject="[n.subject_field.value/]" />
						<n.set_message message="[n.message_field.value/]" is_html="[n.not.is_null.html_format_field.value/]" />
						<n.if.not.is_preview>
							<then.save_post />
						</n.if.not.is_preview>
					</n.edit_page_node.>
					<n.if.not.is_preview>
						<then>
							<n.page_node.save_alert_field/>
							<n.page_node.save_edit_post_custom_fields/>
							<n.redirect_to.page_node.url/>
						</then>
					</n.if.not.is_preview>
				</n.catch_exception.>
			</else>
		</n.if.not.is_submitted_form>
		<n.html>
			<head>
				<META NAME="robots" CONTENT="noindex,nofollow"/>
				<n.title.><t>Edit Post</t></n.title.>
				<style type="text/css">
					.title-row {
						padding:.2em;
						border-width:2px;
						border-style:solid;
						font-weight:bold;
					}
					div.field-title {
						margin-top: 0;
					}
				</style>
			</head>
			<body>
				<n.edit_header first_text="[t]Edit Post[/t]" second_text="[n.page_node.get_app_node.subject/]" />
				<n.if.is_submitted_form>
					<then>
						<n.if.is_preview>
							<then>
								<n.page_node.preview/>
							</then>
						</n.if.is_preview>
						<n.show_edit_post_error/>
					</then>
				</n.if.is_submitted_form>
				<n.form.>
					<n.edit_post_form />

					<div style="margin-top:1em">
						<input type="submit" class="toolbar action-button" value="[t]Post Message[/t]" />
						<input type="submit" class="toolbar action-button" name="preview" value="[t]Preview Message[/t]" />
						<t>or</t> <a href="[n.page_node.url/]"><t>Cancel</t></a>
					</div>
				</n.form.>
			</body>
		</n.html>
	</n.node_page.>
</macro>

<macro name="save_post" requires="node_editor,servlet">
	<n.save_node />
</macro>

<macro name="edit_post_form">
	<n.if.page_node.is_mail_to_list>
		<then>
			<div class="title-row info-message" style="font-weight:normal;padding:.3em .5em">
				<div class="important" style="font-weight:bold">
					<t>Your changes will not be sent to the mailing list.</t>
				</div>
				<t>If you want others in the mailing list to know of your changes,
					please compose a new message or reply to your original message.</t>
			</div>
		</then>
	</n.if.page_node.is_mail_to_list>

	<n.if.page_node.message.is_imported_mail>
		<then>
			<div class="info-message" style="font-weight:bold;padding:.3em .5em">                
				<t>The post you are editing was originally imported by email. If this post has attachments, those files will be lost after you save your changes. You may download the attachments and re-upload them to your edited post.</t>
			</div>
			</then>
	</n.if.page_node.message.is_imported_mail>
	
	<n.if.not.visitor.is_registered>
		<then>
			<div class="field-box light-border-color">
				<div class="second-font field-title"><t>Your Name</t></div>
				<div class="weak-color">
					<n.page_node.owner.name/>
				</div>
			</div>
		</then>
	</n.if.not.visitor.is_registered>

	<div class="field-box light-border-color">
		<div class="second-font field-title"><t>Subject</t></div>
		<div class="weak-color">
			<n.subject_field.input size="60" tabindex="1" />
		</div>
	</div>

	<div class="field-box light-border-color">
		<div class="second-font field-title"><t>Message</t></div>
		<div class="weak-color">
			<n.if.visitor.is_registered>
				<then>
					<n.html_format_field.checkbox />
					<label for="[n.html_format_field.name/]"><t>Message is in HTML Format</t></label><br/>
					<div style="margin:.1em 0">
						<n.editor_toolbar
							textarea_id="[n.message_field.name/]"
							original_text="[n.if.page_node.parent_node.is_post][then.page_node.parent_node.message_quoted/][/n.if.page_node.parent_node.is_post]"
							node_id="[n.page_node.id/]"
						/>
					</div>
				</then>
			</n.if.visitor.is_registered>
			<n.message_field.textarea wrap="SOFT" tabindex="2" style="min-width:30em;max-width:55em;width:100%;height:20em;" />

			<n.edit_post_extra_fields/>
		</div>
	</div>
</macro>

<macro name="edit_post_extra_fields" requires="node_page">
	<n.extra_fields.>
		<n.if.visitor.is_registered>
			<then>
				<div class="extra-fields">
					<n.alert_field.checkbox style="margin-top:.1em"/>
					<label for="[n.alert_field.name/]"><t>Alert me by email when someone posts to this thread</t></label>
				</div>
			</then>
		</n.if.visitor.is_registered>
	</n.extra_fields.>
</macro>

<macro name="is_preview">
	<n.if.not.global_is_var_set name="is_preview">
		<then>
			<n.global_set_var. name="is_preview"><n.not.is_null.get_parameter name="preview" /></n.global_set_var.>
		</then>
	</n.if.not.global_is_var_set>
	<n.global_var name="is_preview" />
</macro>

<macro name="subject_field" dot_parameter="do">
	<n.field. name="subject"><n.do/></n.field.>
</macro>

<macro name="html_format_field" dot_parameter="do">
	<n.field. name="html_format"><n.do/></n.field.>
</macro>

<macro name="message_field" dot_parameter="do">
	<n.field. name="message"><n.do/></n.field.>
</macro>

<macro name="alert_field" dot_parameter="do">
	<n.field. name="alert"><n.do/></n.field.>
</macro>

<macro name="show_edit_post_error">
	<n.format_error.handle_exception. for="save-block">
		<n.exception. name="required_subject">
			<t>The subject is required.</t>
		</n.exception.>
		<n.spam_errors/>
		<n.custom_edit_post_errors/>
	</n.format_error.handle_exception.>
</macro>

<macro name="custom_edit_post_errors">
	<n.comment.>To be overridden</n.comment.>
</macro>

<macro name="preview" requires="node">
	<div class="title-row light-border-color shaded-bg-color" style="margin-top:.5em"><t>Message Preview</t></div>
	<div class="light-border-color" style="padding-left:.7em;border-width:2px;border-style:solid">
		<div class="field-box" style="width:100%;border:none">
			<table style="border-collapse:collapse;margin-bottom:1em">
				<tr>
					<td><n.owner.avatar/></td>
					<td>&nbsp;<a href="[n.owner.url/]"><n.owner.name/></a> &ndash; </td>
					<td><b><n.subject/></b></td>
					<td class="weak-color"><t>on <t.date.when_created.long_format/></t></td>
				</tr>
			</table>
			<n.message_text/>
		</div>
	</div>
</macro>

<macro name="init_edit_post_custom_fields" requires="node_page">
	<n.comment.>To be overridden</n.comment.>
</macro>

<macro name="save_edit_post_custom_fields" requires="node_page">
	<n.comment.>To be overridden</n.comment.>
</macro>