<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPageSub.Master"
	Inherits="System.Web.Mvc.ViewPage<MvcEnterprise.Models.DataSet1+ArticleRow>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
	<link href="../../Content/Skin/Validation.css" rel="stylesheet" type="text/css" />
	<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
	<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
	<script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
	<script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
	<script src="../../Scripts/Admin.js" type="text/javascript"></script>
	<script src="<%=Url.Content("~/Content/fckeditor/fckeditor.js")%>" type="text/javascript"></script>
	<%Html.EnableClientValidation(); %>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="LeftContent" runat="server">
	<div class="Item">
		<div class="LeftNavTitle">
			<%= Language.Context.User.LabelNavTitle %></div>
		<div>
			<%Html.RenderPartial("partial_LeftNav_User");%></div>
	</div>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="RightContent" runat="server">
	<div class="Item">
		<div class="Location">
			<%= Html.ActionLink(Language.Context.Global.HomePage, "Index")%> <%= Language.Context.User.UserPostArticle %>
		</div>
		<div class="WebContent">
			<%
				string SortPath = Request.QueryString["SortPath"];
				int SortID = 0;
			%>
			<script type="text/javascript">
    	$(document).ready(function () {
			<%if (!string.IsNullOrEmpty(SortPath)) {%>
			$("#SortPath").val('<%= SortPath %>');
			<%} %>
            $("#SortID").val(GetSortID());
            $("#SortPath").change(function () {
                $("#SortID").val(GetSortID());
            });
        });
        var GetSortID = function () {
            var sortID = $("#SortPath").val();
            sortID = sortID.substring(0, sortID.length - 1);
            sortID = sortID.substring(sortID.lastIndexOf(",") + 1);
            return sortID;
        };
			</script>
			<% using (Html.BeginForm())
	  {%>
			<%= Html.AntiForgeryToken() %>
			<div>
				<%--新闻标题--%>
				<span class="editor-label"><%= Html.LabelFor(model => model.ArticleName) %>：</span>
				<span class="editor-field"><%= Html.TextBoxFor(model => model.ArticleName, new { style = "width:300px" })%> <%= Html.DisplayToolTipFor(model => model.ArticleName) %>
					<%= Html.ValidationMessageFor(model => model.ArticleName) %></span>
			</div>
			<div>
				<%--略图--%>
				<span class="editor-label"><%= Html.LabelFor(model => model.SmallPic)%>：</span>
				<span class="editor-field"><%= Html.TextBoxFor(model => model.SmallPic, new { style = "width:300px" })%> <%= Html.DisplayToolTipFor(model => model.SmallPic)%>
					<%= Html.ValidationMessageFor(model => model.SmallPic)%></span>
			</div>
			<div>
				<%--所属类别ID--%>
				<span class="editor-field"><%= Html.HiddenFor(model => model.SortID, new { value = 0}) %>
					<%= Html.DisplayToolTipFor(model => model.SortID) %> <%= Html.ValidationMessageFor(model => model.SortID) %></span>
			</div>
			<div>
				<%--类别路径--%>
				<span class="editor-label"><%= Html.LabelFor(model => model.SortPath) %>：</span>
				<span class="editor-field"><%= Html.DropDownListFor(model => model.SortPath, new SelectList(new CategoryService<DataSet1.ArticleSortRow, DataSet1.ValidationArticleSort>(new ArticleSortService()).CategoryList(SortID), "SortPath", "SortName"))%>
					<%= Html.DisplayToolTipFor(model => model.SortPath) %> <%= Html.ValidationMessageFor(model => model.SortPath) %></span>
			</div>
			<%
				if (!string.IsNullOrEmpty(Model.CustomFields) && Model.CustomFields.Contains("|ffcms.com|") && Model.CustomFields.Contains(":ffcms.com:"))
				{
					var cf = Model.CustomFields.Split(new string[] { "|ffcms.com|" }, StringSplitOptions.RemoveEmptyEntries);
					foreach (var item in cf)
					{
						var field = item.Split(new string[] { ":ffcms.com:" }, StringSplitOptions.None);
			%>
			<div>
				<span class="editor-label">
					<label for="<%= field[0] %>"><%= field[0]%></label></span>
				<span class="editor-field"><input type="text" id="<%= field[0] %>" name="<%= field[0] %>"
					value="<%= field[1] %>" /></span>
			</div>
			<%
				}
		   }
		   else
		   {
			   var table = CustomFields.Context.XPathSelectElement("/table[@name='" + Model.Table.TableName + "']");
			   var fields = table.Elements();
			   foreach (var field in fields)
			   {
				   var fieldName = field.Attribute("name").Value;
				   var defaultvalue = field.Attribute("defaultvalue").Value;
			%>
			<div>
				<span class="editor-label">
					<label for="<%= fieldName %>"><%= fieldName %></label></span>
				<span class="editor-field"><input type="text" id="<%= fieldName %>" name="<%= fieldName %>"
					value="<%= defaultvalue %>" /></span>
			</div>
			<%
				}
		   }
			%>
			<div>
				<%--详细内容--%>
				<%= Html.FckEditorFor(model => model.Content)%> <%= Html.ValidationMessageFor(model => model.Content) %></div>
			<div>
				<%----%>
				<%= Html.HiddenFor(model=>model.ID) %></div>
			<p><input type="submit" value=" 发表文章 " /></p>
			<% } %>
		</div>
	</div>
</asp:Content>

