protected void Page_Load(object sender, EventArgs e) { if (Request["pageId"] != null) { tblPageXControl pxc = new tblPageXControl(); pxc.Where.PageId.Value = Int32.Parse(Request["pageId"]); pxc.Query.Load(); pxc.Sort = "SortOrder"; tblControlsXItems cxi = new tblControlsXItems(); cxi.Where.ControlId.Value = pxc.ControlId; cxi.Query.Load(); if (cxi.RowCount > 0) { Button1.Visible = true; } else { Button1.Visible = false; } if (pxc.RowCount > 0) { pxc.Rewind(); do { // add this control's children tblControls ctl = new tblControls(); ctl.Where.ParentControlId.Value = pxc.ControlId; ctl.Query.Load(); ctl.Sort = "ParentControlSortOrder ASC"; addControl(pxc.ControlId); if (ctl.RowCount > 0) { ctl.Rewind(); do { if ((pxc.ControlId != ctl.ParentControlId) && (ctl.Custom)) { addControl(ctl.ControlId); } }while (ctl.MoveNext()); } else { } } while (pxc.MoveNext()); } } if (PlaceHolder1.Controls.Count == 0) { Button1.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (Request["pageId"] != null) { tblPageXControl pxc = new tblPageXControl(); pxc.Where.PageId.Value = Int32.Parse(Request["pageId"]); pxc.Query.Load(); pxc.Sort = "SortOrder"; tblControlsXItems cxi = new tblControlsXItems(); cxi.Where.ControlId.Value = pxc.ControlId; cxi.Query.Load(); if (cxi.RowCount > 0) { Button1.Visible = true; } else{Button1.Visible = false;} if (pxc.RowCount > 0) { pxc.Rewind(); do { // add this control's children tblControls ctl = new tblControls(); ctl.Where.ParentControlId.Value = pxc.ControlId; ctl.Query.Load(); ctl.Sort = "ParentControlSortOrder ASC"; addControl(pxc.ControlId); if (ctl.RowCount > 0) { ctl.Rewind(); do { if ((pxc.ControlId != ctl.ParentControlId) && (ctl.Custom)) { addControl(ctl.ControlId); } } while (ctl.MoveNext()); } else { } } while (pxc.MoveNext()); } } if (PlaceHolder1.Controls.Count == 0) { Button1.Visible = false; } }
private void addControl(int controlId) { tblControls ctl = new tblControls(); ctl.LoadByPrimaryKey(controlId); int start = PlaceHolder1.Controls.Count; PlaceHolder1.Controls.Add(new LiteralControl("<h2>" + ctl.ControlFriendlyName)); if (((int)UserContext.GetContextItemAsInt("userlevel") == 1) && (!ctl.Custom)) { HyperLink hl = new HyperLink(); hl.Text = "Add New Item »"; hl.NavigateUrl = epicCMSLib.Navigation.PopupPageLink("AddItem.aspx?ctl=" + controlId.ToString() + "&langId=" + Request["langId"], 350, 100); PlaceHolder1.Controls.Add(new LiteralControl(" | ")); PlaceHolder1.Controls.Add(hl); // PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); } PlaceHolder1.Controls.Add(new LiteralControl("</h2><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">")); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); bool foundItems = false; if (!ctl.Custom) { tblControlsXItems cxi = new tblControlsXItems(); cxi.Where.ControlId.Value = controlId; cxi.Where.LanguageId.Value = Int32.Parse(Request["langId"]); cxi.Query.Load(); cxi.Sort = "SortOrder"; if (cxi.RowCount > 0) { cxi.Rewind(); do { admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadItem(cxi.ItemId); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } while (cxi.MoveNext()); } } else { //PlaceHolder1.Controls.Add(new LiteralControl("<tr><td style=\"padding:8px;\">")); //PlaceHolder1.Controls.Add(Page.LoadControl("~/App_Controls/" + ctl.CustomCmsLocation)); //PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); //foundItems = true; admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadCustomItem(ctl.CustomCmsLocation); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } if ((!foundItems) && ((int)UserContext.GetContextItemAsInt("userlevel") != 1)) { for (int x = PlaceHolder1.Controls.Count - 1; x >= start; x--) { PlaceHolder1.Controls.RemoveAt(x); } } else { PlaceHolder1.Controls.Add(new LiteralControl("</table><br>")); } }
protected void Button1_Click(object sender, EventArgs e) { tblItems item = new tblItems(); item.AddNew(); item.ItemTitle = TextBox1.Text; item.ItemTypeId = int.Parse(DropDownList1.SelectedValue); item.Save(); tblItemFieldsXValue fxv = new tblItemFieldsXValue(); // now, create the field values switch (DropDownList1.SelectedValue) { case "1": tblItemFieldStringValues txt21 = new tblItemFieldStringValues(); txt21.AddNew(); txt21.ItemFieldValue = " "; txt21.Save(); fxv.AddNew(); fxv.ItemId = item.ItemId; fxv.LanguageId = int.Parse(Request["langId"]); fxv.ItemFieldId = 7; // text fxv.ItemFieldStringId = -1; if (ConfigurationManager.AppSettings["usesApprovals"] == "true") { fxv.ItemFieldStringTempId = txt21.ItemFieldStringValueId; } else { fxv.ItemFieldStringId = txt21.ItemFieldStringValueId; } fxv.Save(); break; case "2": // image //tblImageAssets blob = new tblImageAssets(); //blob.AddNew(); //blob.Save(); tblItemFieldStringValues img = new tblItemFieldStringValues(); img.AddNew(); img.ItemFieldValue = " "; img.Save(); fxv.AddNew(); fxv.ItemId = item.ItemId; fxv.LanguageId = int.Parse(Request["langId"]); fxv.ItemFieldId = 3; // image fxv.ItemFieldStringId = -1; if (ConfigurationManager.AppSettings["usesApprovals"] == "true") { fxv.ItemFieldStringTempId = img.ItemFieldStringValueId; } else { fxv.ItemFieldStringId = img.ItemFieldStringValueId; } fxv.Save(); break; case "3": // rich text tblItemFieldTextValues txt = new tblItemFieldTextValues(); txt.AddNew(); txt.Save(); fxv.AddNew(); fxv.ItemId = item.ItemId; fxv.LanguageId = int.Parse(Request["langId"]); fxv.ItemFieldId = 2; // image if (ConfigurationManager.AppSettings["usesApprovals"] == "true") { fxv.ItemFieldTextTempId = txt.ItemFieldStringValueId; } else { fxv.ItemFieldTextId = txt.ItemFieldStringValueId; } fxv.Save(); break; case "4": // pdf fxv.AddNew(); fxv.ItemId = item.ItemId; fxv.LanguageId = int.Parse(Request["langId"]); fxv.ItemFieldId = 5; // pdf fxv.ItemFieldPdfAssetId = -1; fxv.Save(); break; case "5": // rich text tblItemFieldStringValues txt2 = new tblItemFieldStringValues(); txt2.AddNew(); txt2.ItemFieldValue = " "; txt2.Save(); fxv.AddNew(); fxv.ItemId = item.ItemId; fxv.LanguageId = int.Parse(Request["langId"]); fxv.ItemFieldId = 6; // image if (ConfigurationManager.AppSettings["usesApprovals"] == "true") { fxv.ItemFieldStringTempId = txt2.ItemFieldStringValueId; } else { fxv.ItemFieldStringId = txt2.ItemFieldStringValueId; } fxv.Save(); break; } tblControlsXItems cxi = new tblControlsXItems(); cxi.AddNew(); cxi.ControlId = int.Parse(Request["ctl"]); cxi.LanguageId = int.Parse(Request["langId"]); cxi.ItemId = item.ItemId; cxi.Save(); lbJs.Text = epicCMSLib.Navigation.CloseWindowString; }
private void addControl(int controlId) { tblControls ctl = new tblControls(); ctl.LoadByPrimaryKey(controlId); int start = PlaceHolder1.Controls.Count; PlaceHolder1.Controls.Add(new LiteralControl("<h2>"+ ctl.ControlFriendlyName)); if (((int)UserContext.GetContextItemAsInt("userlevel") == 1) && (!ctl.Custom)) { HyperLink hl = new HyperLink(); hl.Text = "Add New Item »"; hl.NavigateUrl = epicCMSLib.Navigation.PopupPageLink("AddItem.aspx?ctl=" + controlId.ToString() + "&langId=" + Request["langId"], 350, 100); PlaceHolder1.Controls.Add(new LiteralControl(" | ")); PlaceHolder1.Controls.Add(hl); // PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); } PlaceHolder1.Controls.Add(new LiteralControl("</h2><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">")); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); bool foundItems = false; if (!ctl.Custom) { tblControlsXItems cxi = new tblControlsXItems(); cxi.Where.ControlId.Value = controlId; cxi.Where.LanguageId.Value = Int32.Parse(Request["langId"]); cxi.Query.Load(); cxi.Sort = "SortOrder"; if (cxi.RowCount > 0) { cxi.Rewind(); do { admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadItem(cxi.ItemId); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } while (cxi.MoveNext()); } } else { //PlaceHolder1.Controls.Add(new LiteralControl("<tr><td style=\"padding:8px;\">")); //PlaceHolder1.Controls.Add(Page.LoadControl("~/App_Controls/" + ctl.CustomCmsLocation)); //PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); //foundItems = true; admin_controls_ctlEditItem edit = (admin_controls_ctlEditItem)Page.LoadControl("~/admin/controls/ctlEditItem.ascx"); edit.LoadCustomItem(ctl.CustomCmsLocation); PlaceHolder1.Controls.Add(new LiteralControl("<tr><td>")); PlaceHolder1.Controls.Add(edit); PlaceHolder1.Controls.Add(new LiteralControl("</td></tr>")); foundItems = true; } if ((!foundItems) && ((int)UserContext.GetContextItemAsInt("userlevel") != 1)) { for (int x = PlaceHolder1.Controls.Count - 1; x >= start ; x--) { PlaceHolder1.Controls.RemoveAt(x); } } else { PlaceHolder1.Controls.Add(new LiteralControl("</table><br>")); } }