void AccountForumManage_New(object sender, ModuleModeEventArgs e) { SetTemplate("account_forum_edit"); long id = core.Functions.RequestLong("id", 0); /* Forum Types SelectBox */ SelectBox forumTypesSelectBox = new SelectBox("type"); Dictionary<string, string> forumTypes = new Dictionary<string, string>(); forumTypesSelectBox.Add(new SelectBoxItem("FORUM", "Forum")); forumTypesSelectBox.Add(new SelectBoxItem("CAT", "Category")); //forumTypes.Add("LINK", "Link"); /* Forum Types SelectBox */ SelectBox forumParentSelectBox = new SelectBox("parent"); /* Title TextBox */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* Description TextBox */ TextBox descriptionTextBox = new TextBox("description"); descriptionTextBox.IsFormatted = true; descriptionTextBox.Lines = 6; /* Rules TextBox */ TextBox rulesTextBox = new TextBox("rules"); rulesTextBox.IsFormatted = true; rulesTextBox.Lines = 6; ForumSettings settings = new ForumSettings(core, Owner); List<Forum> forums = settings.GetForums(); forumParentSelectBox.Add(new SelectBoxItem("0", "")); foreach (Forum forum in forums) { string levelString = string.Empty; for (int i = 0; i < forum.Level; i++) { levelString += "--"; } SelectBoxItem item = new SelectBoxItem(forum.Id.ToString(), levelString + " " + forum.Title); if (forum.Id == id && e.Mode == "edit") { item.Selectable = false; } forumParentSelectBox.Add(item); } switch (e.Mode) { case "new": forumTypesSelectBox.SelectedKey = "FORUM"; template.Parse("S_ID", id.ToString()); forumParentSelectBox.SelectedKey = id.ToString(); break; case "edit": try { Forum forum = new Forum(core, id); string type = "FORUM"; if (forum.IsCategory) { type = "CAT"; } titleTextBox.Value = forum.Title; forumParentSelectBox.SelectedKey = forum.ParentId.ToString(); descriptionTextBox.Value = forum.Description; rulesTextBox.Value = forum.Rules; template.Parse("S_ID", forum.Id.ToString()); List<string> disabledItems = new List<string>(); forumTypesSelectBox["FORUM"].Selectable = false; forumTypesSelectBox["CAT"].Selectable = false; //forumTypesSelectBox["LINK"].Selectable = false; forumTypesSelectBox.SelectedKey = type; template.Parse("EDIT", "TRUE"); } catch (InvalidForumException) { DisplayGenericError(); } break; } /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_DESCRIPTION", descriptionTextBox); template.Parse("S_RULES", rulesTextBox); template.Parse("S_FORUM_TYPE", forumTypesSelectBox); template.Parse("S_FORUM_PARENT", forumParentSelectBox); }
/// <summary> /// Add a select box item to the select box. /// </summary> /// <param name="item"></param> public void Add(SelectBoxItem item) { if (!itemKeys.ContainsKey(item.Key)) { items.Add(item); itemKeys.Add(item.Key, item); } }
void AccountPagesWrite_Show(object sender, EventArgs e) { SetTemplate("account_write"); VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js"); VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css"); core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute); long pageId = 0; long pageParentId = 0; byte licenseId = 0; ushort pagePermissions = 4369; string pageTitle = (core.Http.Form["title"] != null) ? core.Http.Form["title"] : ""; string pageSlug = (core.Http.Form["slug"] != null) ? core.Http.Form["slug"] : ""; string pageText = (core.Http.Form["post"] != null) ? core.Http.Form["post"] : ""; string pagePath = ""; Classifications pageClassification = Classifications.Everyone; try { if (core.Http.Form["license"] != null) { licenseId = core.Functions.GetLicenseId(); } if (core.Http.Form["id"] != null) { pageId = long.Parse(core.Http.Form["id"]); } if (core.Http.Form["page-parent"] != null) { pageParentId = long.Parse(core.Http.Form["page-parent"]); } } catch { } if (core.Http.Query["id"] != null) { try { pageId = long.Parse(core.Http.Query["id"]); } catch { } } if (pageId > 0) { if (core.Http.Query["mode"] == "edit") { try { Page page = new Page(core, Owner, pageId); pageParentId = page.ParentId; pageTitle = page.Title; pageSlug = page.Slug; //pagePermissions = page.Permissions; licenseId = page.LicenseId; pageText = page.Body; pagePath = page.FullPath; pageClassification = page.Classification; } catch (PageNotFoundException) { DisplayGenericError(); } } } Pages myPages = new Pages(core, Owner); List<Page> pagesList = myPages.GetPages(false, true); SelectBox pagesSelectBox = new SelectBox("page-parent"); pagesSelectBox.Add(new SelectBoxItem("0", "/")); foreach (Page page in pagesList) { SelectBoxItem item = new SelectBoxItem(page.Id.ToString(), page.FullPath); pagesSelectBox.Add(item); if (pageId > 0) { if (page.FullPath.StartsWith(pagePath, StringComparison.Ordinal)) { item.Selectable = false; } } } List<string> permissions = new List<string>(); permissions.Add("Can Read"); if (pageId > 0 && pagesSelectBox.ContainsKey(pageId.ToString())) { pagesSelectBox[pageId.ToString()].Selectable = false; } pagesSelectBox.SelectedKey = pageParentId.ToString(); core.Display.ParseLicensingBox(template, "S_PAGE_LICENSE", licenseId); core.Display.ParseClassification(template, "S_PAGE_CLASSIFICATION", pageClassification); template.Parse("S_PAGE_PARENT", pagesSelectBox); //core.Display.ParsePermissionsBox(template, "S_PAGE_PERMS", pagePermissions, permissions); template.Parse("S_TITLE", pageTitle); template.Parse("S_SLUG", pageSlug); template.Parse("S_PAGE_TEXT", pageText); template.Parse("S_ID", pageId.ToString()); Save(new EventHandler(AccountPagesWrite_Save)); if (core.Http.Form["publish"] != null) { AccountPagesWrite_Save(this, new EventArgs()); } }