PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/admin/Pages/EditPage.aspx

#
ASP.NET | 217 lines | 199 code | 18 blank | 0 comment | 6 complexity | 288502f37420f46a347e58b0a5dfb803 MD5 | raw file
  1<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" 
  2ValidateRequest="false" CodeFile="EditPage.aspx.cs" Inherits="Admin.Pages.EditPage" %>
  3
  4<%@ Register Src="~/admin/htmlEditor.ascx" TagPrefix="Blog" TagName="TextEditor" %>
  5<%@ Register Src="~/admin/FileManager/FileManager.ascx" TagName="FileManager" TagPrefix="con" %>
  6
  7<asp:Content ID="Content1" ContentPlaceHolderID="cphAdmin" runat="Server">
  8    <script type="text/javascript">
  9        function GetSlug() {
 10            var title = document.getElementById('<%=txtTitle.ClientID %>').value;
 11            WebForm_DoCallback('__Page', title, ApplySlug, 'slug', null, false)
 12        }
 13
 14        function ApplySlug(arg, context) {
 15            var slug = document.getElementById('<%=txtSlug.ClientID %>');
 16            slug.value = arg;
 17        }
 18
 19        function SavePage() {
 20            $('.loader').show();
 21
 22            var content = tinyMCE.activeEditor.getContent();
 23
 24            if (content.length == 0) content = '[No text]';
 25
 26            var title = $("[id$='txtTitle']").val();
 27            var description = $("[id$='txtDescription']").val();
 28            var keywords = $("[id$='txtKeyword']").val();
 29            var slug = $("[id$='txtSlug']").val();
 30
 31            var isFrontPage = $("[id$='cbFrontPage']").is(':checked');
 32            var showInList = $("[id$='cbShowInList']").is(':checked');
 33            var isPublished = $("[id$='cbPublished']").is(':checked');
 34
 35            var parent = $("[id$='ddlParent'] option:selected").val();
 36
 37            var dto = {
 38                "id": Querystring('id'),
 39                "content": content,
 40                "title": title,
 41                "description": description,
 42                "keywords": keywords,
 43                "slug": slug,
 44                "isFrontPage": isFrontPage,
 45                "showInList": showInList,
 46                "isPublished": isPublished,
 47                "parent": parent
 48            };
 49
 50            //alert(JSON.stringify(dto));
 51
 52            $.ajax({
 53                url: SiteVars.ApplicationRelativeWebRoot + "admin/AjaxHelper.aspx/SavePage",
 54                type: "POST",
 55                dataType: "json",
 56                contentType: "application/json; charset=utf-8",
 57                data: JSON.stringify(dto),
 58                beforeSend: onAjaxBeforeSend,
 59                success: function (result) {
 60                    var rt = result.d;
 61                    if (rt.Success) {
 62                        if (rt.Data) {
 63                            window.location.href = rt.Data;
 64                        } else {
 65                            ShowStatus("success", rt.Message);
 66                        }
 67                    }
 68                    else
 69                        ShowStatus("warning", rt.Message);
 70                }
 71            });
 72
 73            $('.loader').hide();
 74            return false;
 75        }
 76    </script>
 77
 78    <script type="text/javascript" src="../jquery.colorbox.js"></script>
 79    <script type="text/javascript">
 80        $(document).ready(function () {
 81            $("#uploadImage").colorbox({ width: "550px", inline: true, href: "#uploadImagePanel" });
 82            $("#uploadVideo").colorbox({ width: "550px", inline: true, href: "#uploadVideoPanel" });
 83            $("#uploadFile").colorbox({ width: "550px", inline: true, href: "#uploadFilePanel" });
 84        });
 85
 86        function closeOverlay() {
 87            $.colorbox.close();
 88        }
 89    </script>
 90
 91    <div style="display:none;">
 92        <div id="uploadVideoPanel" class="overlaypanel">
 93            <h2><%=Resources.labels.insertVideo %></h2>
 94            <ul class="fl" style="margin:0;">
 95                <li>
 96                    <asp:Label ID="lblVideoUpload" CssClass="lbl" AssociatedControlID="txtUploadVideo" runat="server" Text='<%$ Resources:labels, uploadVideo %>' />
 97                    <asp:FileUpload runat="server" ID="txtUploadVideo" Width="400" size="50" ValidationGroup="imageupload" />
 98                    <asp:RequiredFieldValidator ID="txtUploadVideoValidator" runat="Server" ControlToValidate="txtUploadVideo" ErrorMessage="<%$ Resources:labels, required %>"
 99                        ValidationGroup="videoupload" />
100                </li>
101                <li style="margin:0;">
102                    <asp:Button runat="server" ID="btnUploadVideo" Text="<%$Resources:labels,upload %>"
103                        ValidationGroup="videoupload" CssClass="btn primary" OnClientClick="colorboxDialogSubmitClicked('videoupload', 'uploadVideoPanel');" /> 
104                        <%=Resources.labels.or %> <a href="#" onclick="return closeOverlay();"><%=Resources.labels.cancel %></a>
105                </li>
106            </ul>
107        </div>
108        <div id="uploadImagePanel" class="overlaypanel">
109            <h2><%=Resources.labels.insertImage %></h2>
110            <ul class="fl" style="margin:0;">
111                <li>
112                    <label class="lbl"><%=Resources.labels.uploadImage %></label>
113                    <asp:FileUpload runat="server" ID="txtUploadImage" size="50" />
114                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="txtUploadImage" ErrorMessage="<%$ Resources:labels, required %>"
115                        ValidationGroup="imageupload" />
116                </li>
117                <li style="margin:0;">
118                    <asp:Button CssClass="btn primary" runat="server" ID="btnUploadImage" Text="<%$Resources:labels,upload %>"
119                        ValidationGroup="imageupload" OnClientClick="colorboxDialogSubmitClicked('imageupload', 'uploadImagePanel');" />
120                        <%=Resources.labels.or %> <a href="#" onclick="closeOverlay();"><%=Resources.labels.cancel %></a>
121                </li>
122            </ul>
123        </div>
124        <div id="uploadFilePanel" class="overlaypanel">
125            <h2><%=Resources.labels.attachFile %></h2>
126            <ul class="fl" style="margin:0;">
127                <li>
128                    <label class="lbl"><%=Resources.labels.uploadFile %></label>
129                    <asp:FileUpload runat="server" ID="txtUploadFile" size="50" />
130                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtUploadFile" ErrorMessage="<%$ Resources:labels, required %>"
131                        ValidationGroup="fileUpload" />
132                </li>
133                <li style="margin:0;">
134                    <asp:Button CssClass="btn primary" runat="server" ID="btnUploadFile" Text="<%$Resources:labels,upload %>"
135                        ValidationGroup="fileUpload" OnClientClick="colorboxDialogSubmitClicked('fileUpload', 'uploadFilePanel');" />
136                        <%=Resources.labels.or %> <a href="#" onclick="closeOverlay();"><%=Resources.labels.cancel %></a>
137                </li>
138            </ul>
139        </div>
140    </div>
141
142    <div class="content-box-outer">
143        <con:FileManager runat="server" ID="FileManager1" />
144        <div class="content-box-full">
145            <h1><%=Resources.labels.editPage %></h1>
146            <table class="tblForm largeForm" style="width:100%; margin:0;">
147                <tr>
148                    <td style="vertical-align:top; padding:0 40px 0 0;">
149                        <ul class="fl">
150                            <li>
151                                <label class="lbl" for="<%=txtTitle.ClientID %>">
152                                    <%=Resources.labels.title %></label>
153                                <asp:TextBox runat="server" ID="txtTitle" Width="600" />
154                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle" Display="Dynamic"
155                                    ErrorMessage="<%$Resources:labels,enterTitle %>" />
156                            </li>
157                            <li>
158                                <div class="editToolbar">
159                                    <a href="#" id="uploadImage" class="image"><%=Resources.labels.insertImage %></a>
160                                    <a href="#" id="uploadVideo" class="video"><%=Resources.labels.insertVideo %></a>
161                                    <a href="#" id="uploadFile" class="file"><%=Resources.labels.attachFile %></a>
162                                     <a href="javascript:;" id="fileManager" class="file">File Manager</a>
163                                </div>
164                                <Blog:TextEditor runat="server" id="txtContent" TabIndex="4" />
165                            </li>
166                            <li>
167                                <label class="lbl" for="<%=txtSlug.ClientID %>"><%=Resources.labels.slug %></label>
168                                <asp:TextBox runat="server" ID="txtSlug" TabIndex="9" Width="600" />
169                                <a href="javascript:void(GetSlug());">
170                                    <%=Resources.labels.extractFromTitle %></a>
171                            </li>
172                            <li>
173                                <label class="lbl" for="<%=txtDescription.ClientID %>"><%=Resources.labels.excerpt %></label>
174                                <asp:TextBox runat="server" ID="txtDescription" Width="600" TextMode="multiLine"
175                                    Columns="50" Rows="4" />
176                            </li>
177                            <li>
178                                <asp:CheckBox runat="Server" ID="cbPublished" Checked="true" Text="<%$ Resources:labels, publish %>" />
179                            </li>
180                        </ul>
181                    </td>
182                    <td class="secondaryForm" style="padding:0; vertical-align:top;">
183                        <ul class="fl">
184                            <li>
185                                <label class="lbl" for="<%=ddlParent.ClientID %>"><%=Resources.labels.selectParent %></label>
186                                <asp:DropDownList runat="server" ID="ddlParent" Width="250" />
187                            </li>
188                            <li>
189                                <label class="lbl" for="<%=txtKeyword.ClientID %>"><%=Resources.labels.keywords %></label>
190                                <asp:TextBox runat="server" ID="txtKeyword" TextMode="MultiLine" Rows="5"  />
191                            </li>
192                            <li>
193                                <label class="lbl"><%=Resources.labels.options %></label>
194                                <asp:CheckBox runat="Server" ID="cbFrontPage" Text="<%$ Resources:labels, isFrontPage %>" /><br />
195                            </li>
196                            <li>
197                                 <asp:CheckBox runat="Server" ID="cbShowInList" Text="<%$ Resources:labels, showInList %>" Checked="true" />
198                            </li>
199                        </ul>
200                    </td>
201                </tr>
202            </table>
203
204            <div class="action_buttons">
205                <input type="button" id="btnSave" value="<%=Resources.labels.savePage %>" class="btn primary" onclick="return SavePage()" /> <%=Resources.labels.or %> 
206                <% if (!string.IsNullOrEmpty(Request.QueryString["id"]))
207                   { %>
208                <a href="<%=PageUrl %>" title="Go to page"><%=Resources.labels.goToPage %></a>
209                <%}
210                   else
211                   {%>
212                <a href="Pages.aspx" title="Cancel"><%=Resources.labels.cancel %></a>
213                <%} %>
214            </div>
215        </div>
216    </div>
217</asp:Content>