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 placeData() { tblLanguages lang = new tblLanguages(); lang.Where.SiteId.Value = Int32.Parse(Request["siteId"]); lang.Query.Load(); do { tblPagesXLanguage pxl = new tblPagesXLanguage(); pxl.Where.LanguageId.Value = lang.LanguageId; pxl.Sort = "SortOrder ASC"; pxl.Query.Load(); do { tblPageXControl pxc = new tblPageXControl(); pxc.Where.PageId.Value = pxl.PageId; pxc.Query.Load(); pxc.Sort = "CmsSortOrder ASC"; if (pxc.RowCount > 0) { pxc.Rewind(); do { tblControls ctls = new tblControls(); ctls.LoadByPrimaryKey(pxc.ControlId); HyperLink hl = new HyperLink(); hl.Text = ctls.ControlFriendlyName; PlaceHolder1.Controls.Add(hl); } while (pxc.MoveNext()); } } while (pxl.MoveNext()); } while (lang.MoveNext()); }
private void placeData() { tblLanguages lang = new tblLanguages(); lang.Where.SiteId.Value = Int32.Parse(Request["siteId"]); lang.Query.Load(); do { tblPagesXLanguage pxl = new tblPagesXLanguage(); pxl.Where.LanguageId.Value = lang.LanguageId; pxl.Sort = "SortOrder ASC"; pxl.Query.Load(); do { tblPageXControl pxc = new tblPageXControl(); pxc.Where.PageId.Value = pxl.PageId; pxc.Query.Load(); pxc.Sort = "CmsSortOrder ASC"; if (pxc.RowCount > 0) { pxc.Rewind(); do { tblControls ctls = new tblControls(); ctls.LoadByPrimaryKey(pxc.ControlId); HyperLink hl = new HyperLink(); hl.Text = ctls.ControlFriendlyName; PlaceHolder1.Controls.Add(hl); } while (pxc.MoveNext()); } } while (pxl.MoveNext()); } while (lang.MoveNext()); }
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>")); } }
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 Page_PreInit(object sender, EventArgs e) { if (Request["pg"] != null) { if (int.Parse(Request["pg"]) > -1) { // first, grab the pageID int page = Int32.Parse(Request["pg"]); // then site id int site = Int32.Parse(Request["siteId"]); tblPages pages = new tblPages(); pages.Where.PageId.Value = page; pages.Query.Load(); tblMasterPages master = new tblMasterPages(); master.LoadByPrimaryKey(pages.MasterPageId); Page.MasterPageFile = "~/App_MasterPages/" + master.MasterPageTitle; // find the place holders tblContentPanes panes = new tblContentPanes(); panes.Where.MasterPageId.Value = pages.MasterPageId; panes.Query.Load(); do { tblPageXControl pgx = new tblPageXControl(); pgx.Where.PageId.Value = page; pgx.Where.ContentPaneId.Value = panes.ContentPaneId; pgx.Query.Load(); if (pgx.RowCount > 0) { pgx.Rewind(); do { ContentPlaceHolder ph1 = (ContentPlaceHolder)Master.FindControl(panes.ContentPaneTitle); tblControls control = new tblControls(); control.LoadByPrimaryKey(pgx.ControlId); ph1.Controls.Add(Page.LoadControl("~/App_Controls/" + control.ControlLocation)); } while (pgx.MoveNext()); } } while (panes.MoveNext()); tblSites ts = new tblSites(); ts.LoadByPrimaryKey(site); tblPagesXLanguage pg = new tblPagesXLanguage(); pg.Where.PageId.Value = page; pg.Where.LanguageId.Value = Convert.ToInt32(Request["langid"]); pg.Query.Load(); Page.Title = ts.SiteTitle + " - " + pg.PageFriendlyName; } } }
protected void Page_PreInit(object sender, EventArgs e) { if (Request["pg"] != null) { if (int.Parse(Request["pg"]) > -1) { // first, grab the pageID int page = Int32.Parse(Request["pg"]); // then site id int site = Int32.Parse(Request["siteId"]); tblPages pages = new tblPages(); pages.Where.PageId.Value = page; pages.Query.Load(); tblMasterPages master = new tblMasterPages(); master.LoadByPrimaryKey(pages.MasterPageId); Page.MasterPageFile = "~/App_MasterPages/" + master.MasterPageTitle; // find the place holders tblContentPanes panes = new tblContentPanes(); panes.Where.MasterPageId.Value = pages.MasterPageId; panes.Query.Load(); do { tblPageXControl pgx = new tblPageXControl(); pgx.Where.PageId.Value = page; pgx.Where.ContentPaneId.Value = panes.ContentPaneId; pgx.Query.Load(); if (pgx.RowCount > 0) { pgx.Rewind(); do { ContentPlaceHolder ph1 = (ContentPlaceHolder)Master.FindControl(panes.ContentPaneTitle); tblControls control = new tblControls(); control.LoadByPrimaryKey(pgx.ControlId); ph1.Controls.Add(Page.LoadControl("~/App_Controls/" + control.ControlLocation)); } while (pgx.MoveNext()); } } while (panes.MoveNext()); tblSites ts = new tblSites(); ts.LoadByPrimaryKey(site); tblPagesXLanguage pg = new tblPagesXLanguage(); pg.Where.PageId.Value = page; pg.Where.LanguageId.Value = Convert.ToInt32(Request["langid"]); pg.Query.Load(); Page.Title = ts.SiteTitle + " - " + pg.PageFriendlyName; } } }