public JsonResult Clone(int id, int parentId) { try { var generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2"); object[] queryargs = { generalModuleDef, PortalSettings.PortalID }; int moduleDefinition; try { moduleDefinition = new rb_ModuleDefinitions().All(where: "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID; } catch(Exception e) { // Shortcut module doesn't exist in current Portal var modules = new ModulesDB(); modules.UpdateModuleDefinitions( generalModuleDef, PortalSettings.PortalID, true); moduleDefinition = new rb_ModuleSettings().All(where: "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID; } var db = new PagesDB(); PortalPages = db.GetPagesFlat(PortalSettings.PortalID); var t = new PageItem { Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; PortalPages.Add(t); var tabs = new PagesDB(); t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order); db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID); OrderPages(); //JsonResult treeData = GetTreeData(); // Coping Modules var pagesModules = new rb_Modules().All(where: "TabID = @0", args: id); foreach (var module in pagesModules) { var m = new ModuleItem(); m.Title = module.ModuleTitle; m.ModuleDefID = moduleDefinition; m.Order = module.ModuleOrder; // save to database var mod = new ModulesDB(); m.ID = mod.AddModule( t.ID, m.Order, module.PaneName, module.ModuleTitle, m.ModuleDefID, 0, module.AuthorizedEditRoles, module.AuthorizedViewRoles, module.AuthorizedAddRoles, module.AuthorizedDeleteRoles, module.AuthorizedPropertiesRoles, module.AuthorizedMoveModuleRoles, module.AuthorizedDeleteModuleRoles, false, PortalSecurity.GetDeleteModulePermissions(module.ModuleID), false, false, false); var settings = new rb_ModuleSettings(); settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID }); } return Json(new {pageId = t.ID}); } catch(Exception e) { ErrorHandler.Publish(LogLevel.Error, e); Response.StatusCode = 500; return Json(""); } }
public JsTreeModel[] getChildrenTree(PageItem page) { List<PageStripDetails> childPages = new PagesDB().GetPagesinPage(this.PortalSettings.PortalID, page.ID); int count = 0; List<JsTreeModel> lstTree = new List<JsTreeModel>(); foreach (PageStripDetails childPage in childPages) { PageItem aux = new PageItem (); aux.ID = childPage.PageID; aux.Name = childPage.PageName; //JsTreeModel[] childs = getChildrenTree(aux); JsTreeModel node = new JsTreeModel { data = aux.Name, attr = new JsTreeAttribute { id = "pjson_" + aux.ID.ToString()}, //children = childs, state = "closed" }; lstTree.Add(node); count++; } JsTreeModel[] tree = lstTree.ToArray<JsTreeModel>(); return tree; }
/// <summary> /// The AddTabButton_Click server event handler /// on this page is used to add a new portal module /// into the tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddTabButton_Click(Object sender, EventArgs e) { if (Page.IsValid) { // Hide error message in case there was a previous error. moduleError.Visible = false; // This allows the user to pick what type of people can view the module being added. // If Authorised Roles is selected from the dropdown then every role that has view permission for the // Add Role module will be added to the view permissions of the module being added. string viewPermissionRoles = PermissionDropDown.SelectedValue.ToString(); if (viewPermissionRoles == "Authorised Roles") { viewPermissionRoles = PortalSecurity.GetViewPermissions(ModuleID); } try { // New tabs go to the end of the list PageItem t = new PageItem(); t.Name = TabTitleTextBox.Text; t.ID = -1; t.Order = 990000; // Get Parent Tab Id Convert only once used many times var parentTabID = int.Parse(parentTabDropDown.SelectedValue); // write tab to database PagesDB tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, parentTabID, t.Name, t.Order, viewPermissionRoles, cb_ShowMobile.Checked, tb_MobileTabName.Text); CurrentCache.RemoveAll("_TabNavigationSettings_"); AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches(); //Jump to Page option string returnTab = string.Empty; if (rbl_JumpToTab.SelectedValue.ToString() == "Yes") { // Redirect to New Page/Tab - Mike Stone 30/12/2004 // modified by Hongwei Shen 9/25/2005 // returnTab = HttpUrlBuilder.BuildUrl(""~/"+HttpUrlBuilder.DefaultPage", t.ID, "SelectedTabID=" + t.ID.ToString()); string newPage = "~/" + t.Name.Trim().Replace(" ", "_") + ".aspx"; returnTab = HttpUrlBuilder.BuildUrl(newPage, t.ID); } else { // Do NOT Redirect to New Form - Mike Stone 30/12/2004 // I guess every .aspx page needs to have a module tied to it. // or you will get an error about edit access denied. // Modified by Hongwei Shen 9/25/2005 to fix: QueryString["tabID"] maybe null. // returnTab = HttpUrlBuilder.BuildUrl("~/"+HttpUrlBuilder.DefaultPage, int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString()); returnTab = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, PageID, "SelectedTabID=" + t.ID.ToString()); } Response.Redirect(returnTab); } catch (Exception ex) { moduleError.Visible = true; ErrorHandler.Publish(LogLevel.Error, "There was an error with the Add Tab Module while trying to add a new tab.", ex); return; } // Reload page to pick up changes Response.Redirect(Request.RawUrl, false); } }
public JsonResult create(int id) { PagesDB db = new PagesDB(); this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID); var t = new PageItem { Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; this.PortalPages.Add(t); var tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order); db.UpdatePageParent(t.ID, id, this.PortalSettings.PortalID); this.OrderPages(); //JsonResult treeData = GetTreeData(); return Json(""); }
/// <summary> /// The AddPage_Click server event handler is used /// to add a new tab for this portal /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="T:System.EventArgs"/> instance containing the event data. /// </param> /// <remarks> /// </remarks> protected void AddPageClick(object sender, EventArgs e) { if (this.Settings["TAB_VERSION"] == null) { return; } if (this.Settings["TAB_VERSION"].ToString().ToLowerInvariant() == "true") { // Use Old Version // New tabs go to the end of the list var t = new PageItem { // Just in case it comes to be empty Name = General.GetString("TAB_NAME", "New Page Name"), ID = -1, Order = 990000 }; this.PortalPages.Add(t); // write tab to database var tabs = new PagesDB(); t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order); // Reset the order numbers for the tabs within the list this.OrderPages(); // Clear SiteMaps Cache AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches(); // Redirect to edit page // 3_aug_2004 Cory Isakson added returntabid so that PageLayout could return to the tab it was called from. // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09) this.Response.Redirect( HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Pages/PageLayout.aspx", t.ID, "mID=" + this.ModuleID + "&returntabid=" + this.Page.PageID)); } else { // Redirect to New Form - Mike Stone 19/12/2004 this.Response.Redirect( HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Pages/AddPage.aspx", "mID=" + this.ModuleID + "&returntabid=" + this.Page.PageID)); } }