forked from chrishulbert/SimpleCSharpWiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
New.aspx.cs
42 lines (38 loc) · 1.19 KB
/
New.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class New : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
Auth.OnlyAdminAllowed();
}
protected void bnSave_Click(object sender, EventArgs e) {
// Get the slashes correct and trim it
txtPath.Text = txtPath.Text.Replace('\\', '/').Trim();
// Ensure they start with a slash
if (!txtPath.Text.StartsWith("/")) txtPath.Text = "/" + txtPath.Text;
// Ensure its a unique name
String path = txtPath.Text;
string urlpath = Wiki.Page.PathToUrlPath(path);
int uniqCount=2;
while (DbServices.PageExistsWithUrlpath(urlpath)) {
path = txtPath.Text + " " + uniqCount.ToString();
urlpath = Wiki.Page.PathToUrlPath(path);
uniqCount++;
}
// Save it
Wiki.Page page = new Wiki.Page();
page.path = path;
page.contents = txtRichEditor.Text.Trim();
page.author = Auth.UserName;
page.Save();
Response.Redirect("./?" + page.urlpath);
}
}