/// <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> public static Control GetEditControl(Page p) { PortalDefinition.Tab tab = PortalDefinition.CurrentTab; PortalDefinition.Module m = tab.GetModule(p.Request["ModuleRef"]); if (!UserManagement.HasEditRights(HttpContext.Current.User, m.roles)) { return(GetNoAccessControl()); } 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, m.type, Config.GetModuleDataVirtualPath(m.type), true); return(em); }
public static Module Create() { PortalDefinition.Module m = new PortalDefinition.Module(); m.reference = Guid.NewGuid().ToString(); m.type = "HtmlEdit"; return(m); }
/// <summary> /// Checks if this module is requested to appear in edit mode. /// </summary> public static bool IsEditModuleRequested(PortalDefinition.Module module) { HttpRequest request = HttpContext.Current.Request; string editMode = request["Edit"]; string moduleRef = request["ModuleRef"]; bool dataAvailable = !string.IsNullOrEmpty(editMode) && !string.IsNullOrEmpty(moduleRef); return(dataAvailable && editMode == "Content" && moduleRef == module.reference && module.moduleSettings.HasEditCtrl); }
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 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 = new PortalDefinition.Module(); m.reference = Guid.NewGuid().ToString(); t.right.Add(m); pd.Save(); Response.Redirect(Helper.GetEditModuleLink(m.reference)); }
public static string GetEditLink(PortalDefinition.Module module) { // Link depends on the Edit Type (Inplace / Fullscreen). bool isInplace = module.moduleSettings != null && module.moduleSettings.IsInplaceEdit; if (isInplace) { return(Config.GetTabUrl(HttpContext.Current.Request["TabRef"]) + "?Edit=Content&ModuleRef=" + module.reference + "&TabRef="); } else { return("EditPageTable.aspx?ModuleRef=" + module.reference + "&TabRef=" + HttpContext.Current.Request["TabRef"]); } }
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)); }
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; } } } }
/// <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); }
public abstract void SetModuleConfig(PortalDefinition.Module md);
/// <summary> /// Initializes the Control /// </summary> /// <param name="md"></param> public override void SetModuleConfig(PortalDefinition.Module md) { ModuleDef = md; lnkEditLink.Module = md; }
/// <summary> /// Initializes the Control /// </summary> /// <param name="md"></param> internal void SetModuleConfig(PortalDefinition.Module md) { ModuleDef = md; lnkEditLink.ModuleRef = md.reference; }
public static Module Create() { PortalDefinition.Module m = new PortalDefinition.Module(); m.reference = Guid.NewGuid().ToString(); m.type = "HtmlEdit"; return m; }