PageRenderTime 28ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/admin/Posts/Add_entry.aspx

#
ASP.NET | 318 lines | 294 code | 24 blank | 0 comment | 17 complexity | b2c99143a8d666e19907521865a20487 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. <%@ Page Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true"
  2. CodeFile="Add_entry.aspx.cs" Inherits="Admin.Posts.AddEntry" ValidateRequest="False"
  3. EnableSessionState="True" %>
  4. <%@ Register Src="~/admin/htmlEditor.ascx" TagPrefix="Blog" TagName="TextEditor" %>
  5. <%@ Register src="Menu.ascx" tagname="TabMenu" tagprefix="menu" %>
  6. <%@ Register Src="~/admin/FileManager/FileManager.ascx" TagName="FileManager" TagPrefix="con" %>
  7. <asp:Content ID="Content1" ContentPlaceHolderID="cphAdmin" runat="Server">
  8. <div class="content-box-outer">
  9. <con:FileManager runat="server" ID="FileManager1" />
  10. <div class="content-box-full">
  11. <h1><%=Resources.labels.addEditPost %></h1>
  12. <script type="text/javascript">
  13. function GetSlug() {
  14. var title = document.getElementById('<%=txtTitle.ClientID %>').value;
  15. WebForm_DoCallback('__Page', title, ApplySlug, 'slug', null, false)
  16. }
  17. function ApplySlug(arg, context) {
  18. var slug = document.getElementById('<%=txtSlug.ClientID %>');
  19. slug.value = arg;
  20. }
  21. function AutoSave() {
  22. var content = document.getElementById('<%=txtRawContent.ClientID %>') != null ? document.getElementById('<%=txtRawContent.ClientID %>').value : tinyMCE.activeEditor.getContent();
  23. var title = document.getElementById('<%=txtTitle.ClientID %>').value;
  24. var desc = document.getElementById('<%=txtDescription.ClientID %>').value;
  25. var slug = document.getElementById('<%=txtSlug.ClientID %>').value;
  26. var tags = document.getElementById('<%=txtTags.ClientID %>').value;
  27. var s = ';|;';
  28. var post = content + s + title + s + desc + s + slug + s + tags;
  29. if (content.length > 10) {
  30. WebForm_DoCallback('__Page', '_autosave' + post, null, 'autosave', null, false);
  31. }
  32. setTimeout("AutoSave()", 5000);
  33. var currentDate = new Date()
  34. document.getElementById('autoSaveLabel').innerHTML = "Autosaved on " + currentDate;
  35. }
  36. document.body.onkeypress = ESCclose;
  37. function ESCclose(evt) {
  38. if (!evt)
  39. evt = window.event;
  40. if (evt.keyCode == 27)
  41. document.getElementById('tagselector').style.display = 'none';
  42. }
  43. function AddTag(element) {
  44. var input = document.getElementById('<%=txtTags.ClientID %>');
  45. input.value += element.innerHTML + ', ';
  46. }
  47. function ToggleTagSelector() {
  48. var element = document.getElementById('tagselector');
  49. if (element.style.display == "none")
  50. element.style.display = "block";
  51. else
  52. element.style.display = "none";
  53. }
  54. function toggleAutomaticDate() {
  55. var element = document.getElementById('rbtManual');
  56. var panel = document.getElementById('datePanel');
  57. if (element.checked) {
  58. panel.style.display = "block";
  59. }
  60. else {
  61. panel.style.display = "none";
  62. }
  63. }
  64. function SavePost() {
  65. $('.loader').show();
  66. var content = document.getElementById('<%=txtRawContent.ClientID %>') != null ? document.getElementById('<%=txtRawContent.ClientID %>').value : tinyMCE.activeEditor.getContent();
  67. var title = document.getElementById('<%=txtTitle.ClientID %>').value;
  68. var desc = document.getElementById('<%=txtDescription.ClientID %>').value;
  69. var slug = document.getElementById('<%=txtSlug.ClientID %>').value;
  70. var tags = document.getElementById('<%=txtTags.ClientID %>').value;
  71. var author = $("[id$='ddlAuthor'] option:selected").val();
  72. var isPublished = $("[id$='cbPublish']").is(':checked');
  73. var hasCommentsEnabled = $("[id$='cbEnableComments']").is(':checked');
  74. var cats = "";
  75. var checkedCats = $('.cblCategories input[@type=checkbox]:checked');
  76. if (checkedCats.length > 0) {
  77. checkedCats.each(function () {
  78. var jThis = $(this);
  79. cats += jThis.attr("id") + ",";
  80. });
  81. }
  82. var date = document.getElementById('<%=txtDate.ClientID %>').value;
  83. var time = document.getElementById('<%=txtTime.ClientID %>').value;
  84. var dto = {
  85. "id": Querystring('id'),
  86. "content": content,
  87. "title": title,
  88. "desc": desc,
  89. "slug": slug,
  90. "tags": tags,
  91. "author": author,
  92. "isPublished": isPublished,
  93. "hasCommentsEnabled": hasCommentsEnabled,
  94. "cats": cats,
  95. "date": date,
  96. "time": time
  97. };
  98. //alert(JSON.stringify(dto));
  99. $.ajax({
  100. url: SiteVars.ApplicationRelativeWebRoot + "admin/AjaxHelper.aspx/SavePost",
  101. type: "POST",
  102. dataType: "json",
  103. contentType: "application/json; charset=utf-8",
  104. data: JSON.stringify(dto),
  105. beforeSend: onAjaxBeforeSend,
  106. success: function (result) {
  107. var rt = result.d;
  108. if (rt.Success) {
  109. if (rt.Data) {
  110. window.location.href = rt.Data;
  111. } else {
  112. ShowStatus("success", rt.Message);
  113. }
  114. }
  115. else
  116. ShowStatus("warning", rt.Message);
  117. }
  118. });
  119. $('.loader').hide();
  120. return false;
  121. }
  122. </script>
  123. <script type="text/javascript" src="../jquery.colorbox.js"></script>
  124. <script type="text/javascript">
  125. $(document).ready(function () {
  126. $("#uploadImage").colorbox({ width: "550px", inline: true, href: "#uploadImagePanel" });
  127. $("#uploadVideo").colorbox({ width: "550px", inline: true, href: "#uploadVideoPanel" });
  128. $("#uploadFile").colorbox({ width: "550px", inline: true, href: "#uploadFilePanel" });
  129. });
  130. function closeOverlay() {
  131. $.colorbox.close();
  132. return false;
  133. }
  134. </script>
  135. <div runat="server" style="visibility:hidden;height:1px">
  136. <div id="uploadVideoPanel" class="overlaypanel">
  137. <h2><%=Resources.labels.insertVideo %></h2>
  138. <ul class="fl" style="margin:0;">
  139. <li>
  140. <asp:Label ID="lblVideoUpload" CssClass="lbl" AssociatedControlID="txtUploadVideo" runat="server" Text='<%$ Resources:labels, uploadVideo %>' />
  141. <asp:FileUpload runat="server" ID="txtUploadVideo" Width="400" size="50" ValidationGroup="imageupload" />
  142. <asp:RequiredFieldValidator ID="txtUploadVideoValidator" runat="Server" ControlToValidate="txtUploadVideo" ErrorMessage="<%$ Resources:labels, required %>"
  143. ValidationGroup="videoupload" />
  144. </li>
  145. <li style="margin:0;">
  146. <asp:Button runat="server" ID="btnUploadVideo" Text="<%$Resources:labels,upload %>"
  147. ValidationGroup="videoupload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('videoupload', 'uploadVideoPanel');" /> <%=Resources.labels.or %> <a href="#" onclick="return closeOverlay();"><%=Resources.labels.cancel %></a>
  148. </li>
  149. </ul>
  150. </div>
  151. <div id="uploadImagePanel" class="overlaypanel">
  152. <h2><%=Resources.labels.insertImage %></h2>
  153. <ul class="fl" style="margin:0;">
  154. <li>
  155. <asp:Label ID="lblFileUpload" CssClass="lbl" AssociatedControlID="txtUploadImage" runat="server" Text='<%$ Resources:labels, uploadImage %>' />
  156. <asp:FileUpload runat="server" ID="txtUploadImage" Width="400" size="50" ValidationGroup="imageupload" />
  157. <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="txtUploadImage" ErrorMessage="<%$ Resources:labels, required %>"
  158. ValidationGroup="imageupload" />
  159. </li>
  160. <li style="margin:0;">
  161. <asp:Button runat="server" ID="btnUploadImage" Text="<%$Resources:labels,upload %>"
  162. ValidationGroup="imageupload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('imageupload', 'uploadImagePanel');" /> <%=Resources.labels.or %> <a href="#" onclick="return closeOverlay();"><%=Resources.labels.cancel %></a>
  163. </li>
  164. </ul>
  165. </div>
  166. <div id="uploadFilePanel" class="overlaypanel">
  167. <h2><%=Resources.labels.attachFile %></h2>
  168. <ul class="fl" style="margin:0;">
  169. <li>
  170. <asp:Label ID="Label1" CssClass="lbl" AssociatedControlID="txtUploadFile" runat="server" Text='<%$ Resources:labels, uploadFile %>' />
  171. <asp:FileUpload runat="server" ID="txtUploadFile" Width="400" size="50" />
  172. <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtUploadFile" ErrorMessage="<%$ Resources:labels, required %>"
  173. ValidationGroup="fileUpload" />
  174. </li>
  175. <li style="margin:0;">
  176. <asp:Button runat="server" ID="btnUploadFile" Text="<%$Resources:labels,upload %>"
  177. ValidationGroup="fileUpload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('fileUpload', 'uploadFilePanel');" /> <%=Resources.labels.or %> <a href="#" onclick="return closeOverlay();"><%=Resources.labels.cancel %></a>
  178. </li>
  179. </ul>
  180. </div>
  181. </div>
  182. <table class="tblForm largeForm" style="width:100%; margin:0;">
  183. <tr>
  184. <td style="vertical-align:top; padding:0 40px 0 0;">
  185. <ul class="fl">
  186. <li>
  187. <asp:Label CssClass="lbl" AssociatedControlID="txtTitle" runat="server" Text='<%$ Code: Resources.labels.title %>' />
  188. <asp:TextBox runat="server" ID="txtTitle" Width="600px" />
  189. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
  190. ErrorMessage="<%$Resources:labels,enterTitle %>" Display="Dynamic" />
  191. </li>
  192. <li>
  193. <div class="editToolbar">
  194. <asp:CheckBox runat="server" ID="cbUseRaw" Text="<%$Resources:labels,useRawHtmlEditor %>" AutoPostBack="true" />
  195. <a href="#" id="uploadImage" class="image"><%=Resources.labels.insertImage %></a>
  196. <a href="#" id="uploadVideo" class="video"><%=Resources.labels.insertVideo %></a>
  197. <a href="#" id="uploadFile" class="file"><%=Resources.labels.attachFile %></a>
  198. <a href="javascript:;" id="fileManager" class="file">File Manager</a>
  199. </div>
  200. <Blog:TextEditor runat="server" id="txtContent" />
  201. <asp:TextBox runat="server" ID="txtRawContent" Width="98%" TextMode="multiLine" Height="400px" Visible="false" />
  202. </li>
  203. <li>
  204. <asp:Label ID="Label2" CssClass="lbl" AssociatedControlID="txtSlug" runat="server" Text='<%$Resources:labels,slug %>' />
  205. <asp:TextBox runat="server" ID="txtSlug" Width="600" />
  206. <a href="javascript:void(GetSlug());"><%=Resources.labels.extractFromTitle %></a>
  207. </li>
  208. <li>
  209. <asp:Label ID="Label3" CssClass="lbl" AssociatedControlID="txtDescription" runat="server" Text='<%$Resources:labels, excerpt %>' />
  210. <asp:TextBox runat="server" ID="txtDescription" TextMode="multiLine" Columns="50" Rows="3" Width="600" Height="80" />
  211. </li>
  212. <li>
  213. <label class="lbl"><%=Resources.labels.options %></label>
  214. <asp:CheckBox runat="server" ID="cbEnableComments" Text="<%$ Resources:labels, enableComments %>" Checked="true" />
  215. </li>
  216. <li>
  217. <asp:CheckBox runat="server" ID="cbPublish" Text="<%$ Resources:labels, publish %>" Checked="true" />
  218. </li>
  219. </ul>
  220. <div class="action_buttons">
  221. <input type="button" id="btnSave" value="<%=Resources.labels.savePost %>" class="btn primary rounded" onclick="return SavePost()" /> <%=Resources.labels.or %>
  222. <% if (!string.IsNullOrEmpty(Request.QueryString["id"]))
  223. { %>
  224. <a href="<%=PostUrl %>" title="<%=Resources.labels.goToPost %>"><%=Resources.labels.goToPost %></a>
  225. <%}
  226. else
  227. {%>
  228. <a href="Posts.aspx" title="<%=Resources.labels.cancel %>"><%=Resources.labels.cancel %></a>
  229. <%} %>
  230. <span id="autoSaveLabel" style="display:none;"></span>
  231. </div>
  232. </td>
  233. <td class="secondaryForm" style="padding:0; vertical-align:top;">
  234. <ul class="fl">
  235. <li>
  236. <asp:Label CssClass="lbl" AssociatedControlID="ddlAuthor" runat="server" Text='<%$ Code: Resources.labels.author %>' />
  237. <asp:DropDownList runat="Server" ID="ddlAuthor" />
  238. </li>
  239. <li>
  240. <asp:Label CssClass="lbl" AssociatedControlID="txtDate" runat="server" Text='<%$ Resources:labels, setPublishDate %>' />
  241. <input type="radio" name="PublishDate" id="rbtAuto" onclick="toggleAutomaticDate()" checked="checked" /><label for="rbtAuto"><%=Resources.labels.automatically %></label>
  242. <input type="radio" name="PublishDate" id="rbtManual" onclick="toggleAutomaticDate()" /><label for="rbtManual"><%=Resources.labels.manually %></label>
  243. <div id="datePanel" style="display:none;">
  244. <asp:TextBox runat="server" ID="txtDate" Width="170" />
  245. <asp:TextBox runat="server" ID="txtTime" Width="50" />
  246. <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtDate" ValidationExpression="[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
  247. ErrorMessage="<%$Resources:labels,enterValidDate %>" Display="dynamic" />
  248. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDate" ErrorMessage="<%$Resources:labels,enterDate %>"
  249. Display="Dynamic" />
  250. </div>
  251. </li>
  252. <li>
  253. <label class="lbl"><%=Resources.labels.categories %></label>
  254. <div class="rounded" style="overflow-y:auto; max-height:160px;border:solid 1px #dcdcdc; padding:5px; margin:0 0 5px;">
  255. <span id="cblCategories" runat="server" class="cblCategories"></span>
  256. </div>
  257. <div style="">
  258. <label for="<%=txtCategory.ClientID %>" style="margin-bottom:5px; display:block;"><%=Resources.labels.quickAddNewCategory %></label>
  259. <asp:TextBox runat="server" ID="txtCategory" ValidationGroup="category" Width="150" />
  260. <asp:Button runat="server" ID="btnCategory" Text="<%$ Resources:labels, add %>" ValidationGroup="category" CssClass="btn" style="min-width:0px; margin:0;" />
  261. <asp:CustomValidator runat="Server" ID="valExist" ValidationGroup="category" ControlToValidate="txtCategory"
  262. ErrorMessage="<%$ Resources:labels, categoryAlreadyExists %>" Display="dynamic" />
  263. <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtCategory" ErrorMessage="<%$ Resources:labels, required %>"
  264. ValidationGroup="category" Display="Dynamic" />
  265. </div>
  266. </li>
  267. <li style="position:relative;">
  268. <label class="lbl"><%=Resources.labels.tags%></label>
  269. <asp:TextBox runat="server" ID="txtTags" TextMode="MultiLine" Rows="3" />
  270. <span><%=Resources.labels.separateTagsWitComma %></span> <%=Resources.labels.or %>
  271. <a href="javascript:void(ToggleTagSelector())"><%=Resources.labels.chooseFromExistingTags %></a>
  272. <div id="tagselector" class="rounded" style="display: none;">
  273. <a class="close" onclick="ToggleTagSelector()"></a>
  274. <span><%=Resources.labels.clickTag %></span>
  275. <div class="clear"></div>
  276. <div style="max-height:150px; overflow-y:auto;">
  277. <asp:PlaceHolder runat="server" ID="phTags" />
  278. </div>
  279. <div class="clear"></div>
  280. </div>
  281. </li>
  282. </ul>
  283. </td>
  284. </tr>
  285. </table>
  286. <% if (Request.QueryString["id"] == null)
  287. { %>
  288. <script type="text/javascript">
  289. setTimeout("AutoSave()", 5000);
  290. </script>
  291. <% } %>
  292. </div>
  293. </div>
  294. </asp:Content>