protected void OnAddTab(object sender, EventArgs args) { PortalDefinition pd = PortalDefinition.Load(); PortalDefinition.Tab t = new PortalDefinition.Tab(); t.reference = Guid.NewGuid().ToString(); pd.GetTab(Request["TabRef"]).tabs.Add(t); pd.Save(); Response.Redirect(Helper.GetEditTabLink(t.reference)); }
protected void OnAddRightModule(object sender, EventArgs args) { PortalDefinition pd = PortalDefinition.Load(); // Do NOT use GetCurrentTab! You will be unable to save PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]); PortalDefinition.Module m = PortalDefinition.Module.Create(); t.right.Add(m); pd.Save(); Response.Redirect(Helper.GetEditModuleLink(m.reference)); }
protected void OnDeleteTab(object sender, EventArgs args) { PortalDefinition.Tab t = PortalDefinition.CurrentTab; PortalDefinition.DeleteTab(t.reference); if (t.parent == null) { Response.Redirect(Helper.GetTabLink("")); } else { Response.Redirect(Helper.GetTabLink(t.parent.reference)); } }
protected void OnAddMiddleModule(object sender, EventArgs args) { PortalDefinition pd = PortalDefinition.Load(); // Do NOT use GetCurrentTab! You will be unable to save PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]); PortalDefinition.Module m = new PortalDefinition.Module(); m.reference = Guid.NewGuid().ToString(); t.middle.Add(m); pd.Save(); Response.Redirect(Helper.GetEditModuleLink(m.reference)); }
override protected void OnInit(EventArgs e) { PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab(); if (UserManagement.HasViewRights(Page.User, tab.roles)) { // Render RenderModules(left, tab, tab.left); RenderModules(middle, tab, tab.middle); RenderModules(right, tab, tab.right); } // CODEGEN: This call is required by the ASP.NET Web Form Designer. InitializeComponent(); base.OnInit(e); }
protected void OnMoveRight(object sender, System.EventArgs args) { PortalDefinition pd = PortalDefinition.Load(); PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]); for (int i = 0; i < 2; i++) { ArrayList a = null; switch (i) { case 0: a = t.left; break; case 1: a = t.middle; break; } for (int idx = 0; idx < a.Count; idx++) { if (((PortalDefinition.Module)a[idx]).reference == ModuleDef.reference) { PortalDefinition.Module m = (PortalDefinition.Module)a[idx]; a.RemoveAt(idx); if (i == 0) { t.middle.Insert(t.middle.Count, m); } else if (i == 1) { t.right.Insert(t.right.Count, m); } else { throw new InvalidOperationException("Invalid Column"); } pd.Save(); Server.Transfer(Request.Url.PathAndQuery); return; } } } }
protected void OnMoveDown(object sender, System.EventArgs args) { PortalDefinition pd = PortalDefinition.Load(); PortalDefinition.Tab t = pd.GetTab(Request["TabRef"]); for (int i = 0; i < 3; i++) { ArrayList a = null; switch (i) { case 0: a = t.left; break; case 1: a = t.middle; break; case 2: a = t.right; break; } for (int idx = 0; idx < a.Count; idx++) { if (((PortalDefinition.Module)a[idx]).reference == ModuleDef.reference) { if (idx >= a.Count - 1) { return; } PortalDefinition.Module m = (PortalDefinition.Module)a[idx]; a.RemoveAt(idx); a.Insert(idx + 1, m); pd.Save(); Server.Transfer(Request.Url.PathAndQuery); return; } } } }
public DisplayTabItem(PortalDefinition.Tab t, bool currTab) { m_Text = t.title; m_CurrentTab = currTab; m_URL = Helper.GetTabLink(t.reference); m_Reference = t.reference; // Check if image exist. if (t.imgPathInactive.Trim() != string.Empty) { // if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(t.imgPathInactive))) m_ImgPathI = t.imgPathInactive; } if (t.imgPathActive.Trim() != string.Empty) { // if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(t.imgPathActive))) m_ImgPathA = t.imgPathActive; } }
private void Page_Load(object sender, System.EventArgs e) { // Load Protal Definition and the current Tab PortalDefinition pd = PortalDefinition.Load(); PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]); // Foreach Tab... ArrayList tabList = new ArrayList(); foreach (PortalDefinition.Tab t in pd.tabs) { if (UserManagement.HasViewRights(Page.User, t.roles)) { // User may view the tab, create a Display Item DisplayTabItem dt = new DisplayTabItem(); tabList.Add(dt); dt.m_Text = t.title; // Set current Tab Property if (currentTab == null) { if (tabList.Count == 1) { // First tab -> default dt.m_CurrentTab = true; } } else { dt.m_CurrentTab = currentTab.GetRootTab() == t; } dt.m_URL = Helper.GetTabLink(t.reference); } // if(User may view) } // foreach(tab) // Bind Repeater Tabs.DataSource = tabList; Tabs.DataBind(); }
override protected void CreateChildControls() { PortalDefinition.Tab tab = PortalDefinition.CurrentTab; if (tab == null) { return; } if (UserManagement.HasViewRights(Page.User, tab.roles)) { // Render RenderModules(TabLeft, tab, tab.left); RenderModules(TabMiddle, tab, tab.middle); RenderModules(TabRight, tab, tab.right); // Special case, if the middle part is not visible. if (!TabMiddle.Visible && TabLeft.Visible && TabRight.Visible) { TabLeft.Attributes["class"] = "TabLeftTwoCol"; TabRight.Attributes["class"] = "TabRightTwoCol"; } } }
/// <summary> /// Returns the proper edit ascx Control. Uses the current Page to load the Control. /// If the user has no right a error control is returned /// </summary> /// <param name="p">The current Page</param> /// <returns>Edit ascx Control</returns> internal static Control GetEditControl(Page p) { PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab(); PortalDefinition.Module m = tab.GetModule(p.Request["ModuleRef"]); if (!UserManagement.HasEditRights(HttpContext.Current.User, m.roles)) { // No rights, return a error Control Label l = new Label(); l.CssClass = "Error"; l.Text = "Access denied!"; return(l); } m.LoadModuleSettings(); Module em = null; if (m.moduleSettings != null) { // Module Settings are present, use custom ascx Control em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + m.moduleSettings.editCtrl); } else { // Use default ascx control (Edit[type].ascx) em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + "Edit" + m.type + ".ascx"); } // Initialize the control em.InitModule( tab.reference, m.reference, Config.GetModuleVirtualPath(m.type), true); return(em); }
private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules) { if (modules.Count == 0) { td.Visible = false; return; } foreach (PortalDefinition.Module md in modules) { if (UserManagement.HasViewRights(Page.User, md.roles)) { md.LoadModuleSettings(); // Initialize the Module Control m = null; bool visible = false; try { // Is the Edit Mode Requested? if (Helper.IsEditModuleRequested(md)) { // Load the Edit Mode of the module. m = Helper.GetEditControl(Page); } if (m == null) { // Load the View of the module. if (md.moduleSettings == null) { m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx"); } else { m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl); } ((Module)m).InitModule(tab.reference, md.reference, md.type, Config.GetModuleDataVirtualPath(md.type), UserManagement.HasEditRights(Page.User, md.roles)); visible = ((Module)m).IsVisible(); } else { visible = true; } if (visible) { // Add ModuleContainer HtmlGenericControl cont = new HtmlGenericControl("div"); cont.Attributes.Add("class", "ModuleContainer"); td.Controls.Add(cont); // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); cont.Controls.Add(mh); // Add Module Body Container HtmlGenericControl bodyCont = new HtmlGenericControl("div"); bodyCont.Attributes.Add("class", "Module"); cont.Controls.Add(bodyCont); // Add Module HtmlGenericControl div = new HtmlGenericControl("div"); div.Controls.Add(m); bodyCont.Controls.Add(div); } } catch (Exception e) { if (Config.ShowModuleExceptions) { throw new Exception(e.Message, e); } // Add ModuleContainer HtmlGenericControl cont = new HtmlGenericControl("div"); cont.Attributes.Add("class", "ModuleContainer"); cont.Controls.Add(m); td.Controls.Add(cont); // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); cont.Controls.Add(mh); // Add Error Module ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx"); while (e != null) { mf.Message += e.GetType().Name + ": "; mf.Message += e.Message + "<br>"; e = e.InnerException; } mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(mf); cont.Controls.Add(div); } } } }
private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules) { if (modules.Count == 0) { td.Visible = false; return; } foreach (PortalDefinition.Module md in modules) { if (UserManagement.HasViewRights(Page.User, md.roles)) { md.LoadModuleSettings(); // Initialize the Module Module m = null; #if !DEBUG try { #endif if (md.moduleSettings == null) { m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx"); } else { m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl); } m.InitModule(tab.reference, md.reference, Config.GetModuleVirtualPath(md.type), UserManagement.HasEditRights(Page.User, md.roles)); if (m.IsVisible()) { // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); td.Controls.Add(mh); // Add Module HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(m); td.Controls.Add(div); } #if !DEBUG } catch (Exception e) { // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); td.Controls.Add(mh); // Add Error Module ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx"); while (e != null) { mf.Message += e.GetType().Name + ": "; mf.Message += e.Message + "<br>"; e = e.InnerException; } mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(mf); td.Controls.Add(div); } #endif } } }