protected override void OnInit(EventArgs e) { base.OnInit(e); mCategoryId = QueryHelper.GetInteger("categoryid", 0); mTreeRoot = QueryHelper.GetText("treeroot", "customsettings"); mWholeSettings = mTreeRoot == "settings"; mRootName = mWholeSettings ? "CMS.Settings" : "CMS.CustomSettings"; if (mCategoryId > 0) { mCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(mCategoryId); } else { mCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mRootName); } if (mCategoryInfo != null) { mCategoryId = mCategoryInfo.CategoryID; } // Intialize the control SetupControl(); }
public SettingsKey GetKeyByName(string keyName) { var keyInfo = SettingsKeyInfoProvider.GetSettingsKeyInfo(keyName); if (keyInfo == null) { throw new ArgumentException($"'{keyName}' is not a valid key name"); } var groupInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(keyInfo.KeyCategoryID); var categoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(groupInfo.CategoryParentID); var categoryParentInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryInfo.CategoryParentID); var category = new Category(categoryInfo.CategoryDisplayName, categoryInfo.CategoryName, categoryParentInfo.CategoryName); var group = new Group(groupInfo.CategoryDisplayName, category); var key = new SettingsKey { KeyDefaultValue = keyInfo.KeyDefaultValue, KeyDescription = keyInfo.KeyDescription, KeyDisplayName = keyInfo.KeyDisplayName, KeyEditingControlPath = keyInfo.KeyEditingControlPath, KeyExplanationText = keyInfo.KeyExplanationText, KeyFormControlSettings = keyInfo.KeyFormControlSettings, KeyName = keyInfo.KeyName, KeyType = keyInfo.KeyType, KeyValidation = keyInfo.KeyValidation, Group = group }; return(key); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Get query string parameters int siteId = QueryHelper.GetInteger("siteid", 0); int categoryId = QueryHelper.GetInteger("categoryid", 0); string searchForText = QueryHelper.GetString("search", ""); bool searchInDescription = QueryHelper.GetBoolean("description", false); // Get category SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); // Either category or search text needs to be set if ((category == null) && (!string.IsNullOrEmpty(searchForText))) { return; } // Get site SiteInfo site = SiteInfoProvider.GetSiteInfo(siteId); // Export settings Export(category, searchForText, searchInDescription, site); }
protected void Page_Load(object sender, EventArgs e) { if (!RequestHelper.IsPostBack()) { treeSettings.SelectPath = "/"; int categoryId = QueryHelper.GetInteger("categoryid", -1); SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); // Select requested category if (category != null) { treeSettings.SelectPath = category.CategoryIDPath; treeSettings.CategoryID = category.CategoryID; treeSettings.ParentID = category.CategoryParentID; treeSettings.CategoryModuleID = category.CategoryResourceID; treeSettings.Value = category.CategoryID + "|" + category.CategoryParentID; } else { // Select root SettingsCategoryInfo rootCat = treeSettings.RootCategory; if (rootCat != null) { treeSettings.CategoryID = rootCat.CategoryID; treeSettings.ParentID = rootCat.CategoryParentID; treeSettings.Value = rootCat.CategoryID + "|" + rootCat.CategoryParentID; } } } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); string[,] breadcrumbs = new string[2, 4]; breadcrumbs[0, 2] = "_parent"; breadcrumbs[1, 1] = ""; // Set bradcrumbs for editing if (skeEditKey.SettingsKeyObj != null) { SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(skeEditKey.SettingsKeyObj.KeyCategoryID); breadcrumbs[0, 0] = sci.CategoryDisplayName; breadcrumbs[0, 1] = ResolveUrl("CustomSettingsCategory_Default.aspx?treeroot=" + mTreeRoot + "&categoryid=" + sci.CategoryParentID + "&siteid=" + mSiteId); breadcrumbs[1, 0] = skeEditKey.SettingsKeyObj.KeyDisplayName; } // Set bradcrumbs for creating new key else { if (mParentGroup != null) { SettingsCategoryInfo parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup); if (parentCat != null) { breadcrumbs[0, 0] = parentCat.CategoryDisplayName; breadcrumbs[0, 1] = ResolveUrl("CustomSettingsCategory_Default.aspx?treeroot=" + mTreeRoot + "&categoryid=" + parentCat.CategoryParentID + "&siteid=" + mSiteId); breadcrumbs[1, 0] = GetString("Development.CustomSettings.NewKey"); } } } CurrentMaster.Title.Breadcrumbs = breadcrumbs; }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(Page); // URL for tree selection string script = "var categoryURL = '" + ResolveUrl("keys.aspx") + "';\n"; script += "var doNotReloadContent = false;\n"; // Get selected site id mSiteId = ValidationHelper.GetInteger(siteSelector.Value, 0); TreeViewCategories.SiteID = mSiteId; TreeViewCategories.RootIsClickable = true; int categoryId = 0; if (Request.Params["selectedCategoryId"] != null) { // Selected category categoryId = ValidationHelper.GetInteger(Request.Params["selectedCategoryId"], 0); } else { // First request to Settings categoryId = SettingsCategoryInfoProvider.GetRootSettingsCategoryInfo().CategoryID; } bool reload = QueryHelper.GetBoolean("reload", true); // Select category SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (sci != null) { // Stop reloading of right frame, if explicitly set if (!reload) { script += "doNotReloadContent = true;"; } script += SelectAtferLoad(sci.CategoryIDPath, sci.CategoryName, sci.CategoryID, sci.CategoryParentID); } ScriptHelper.RegisterStartupScript(Page, typeof(string), "SelectCat", ScriptHelper.GetScript(script)); // Style site selector siteSelector.DropDownSingleSelect.CssClass = ""; siteSelector.DropDownSingleSelect.Attributes.Add("style", "width: 100%"); lblSite.Text = GetString("general.site") + ResHelper.Colon; // Set site selector siteSelector.DropDownSingleSelect.AutoPostBack = true; siteSelector.AllowAll = false; siteSelector.UniSelector.SpecialFields = new string[1, 2] { { GetString("general.global"), "0" } }; siteSelector.OnlyRunningSites = false; }
/// <summary> /// Handles the whole category actions. /// </summary> /// <param name="sender">Sender of event</param> /// <param name="e">Event arguments</param> protected void grpEdit_ActionPerformed(object sender, CommandEventArgs e) { int categoryId = ValidationHelper.GetInteger(e.CommandArgument, 0); switch (e.CommandName.ToLowerCSafe()) { case ("edit"): // Redirect to category edit page SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (sci != null) { URLHelper.Redirect(URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditCategory", false), "isgroup=1&categoryid=" + categoryId + "&moduleid=" + moduleId)); } break; case ("delete"): try { SettingsCategoryInfo settingGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (settingGroup != null) { // Register refresh tree script StringBuilder sb = new StringBuilder(); sb.Append("if (window.parent != null) {"); sb.Append("if (window.parent.parent.frames['settingstree'] != null) {"); sb.Append("window.parent.parent.frames['settingstree'].location = '" + ResolveUrl("~/CMSModules/Modules/Pages/Settings/Tree.aspx") + "?categoryid=" + settingGroup.CategoryParentID + "&moduleid=" + moduleId + "&reloadtreeselect=1';"); sb.Append("}"); sb.Append("if (window.parent.frames['settingstree'] != null) {"); sb.Append("window.parent.frames['settingstree'].location = '" + ResolveUrl("~/CMSModules/Modules/Pages/Settings/Tree.aspx") + "?categoryid=" + settingGroup.CategoryParentID + "&moduleid=" + moduleId + "&reloadtreeselect=1';"); sb.Append("}"); sb.Append("}"); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "treeGroupRefresh", ScriptHelper.GetScript(sb.ToString())); SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(settingGroup); } } catch { ShowError(GetString("settings.group.deleteerror")); } grpEdit.ReloadData(); break; case ("moveup"): SettingsCategoryInfoProvider.MoveCategoryUp(categoryId); grpEdit.ReloadData(); break; case ("movedown"): SettingsCategoryInfoProvider.MoveCategoryDown(categoryId); grpEdit.ReloadData(); break; } }
/// <summary> /// Initialization of controls. /// </summary> private void InitControls() { // Init validations rfvKeyDisplayName.ErrorMessage = ResHelper.GetString("general.requiresdisplayname"); rfvKeyName.ErrorMessage = ResHelper.GetString("general.requirescodename"); // Display of LoadGeneration table row trLoadGeneration.Visible = SystemContext.DevelopmentMode; // Set the root category if (RootCategoryID > 0) { drpCategory.RootCategoryId = RootCategoryID; } // Enable only groups which belong to selected module drpCategory.EnabledCondition = "{% " + (!SystemContext.DevelopmentMode ? "(CategoryResourceID == " + ModuleID + ") && " : String.Empty) + "(CategoryIsGroup)%}"; // If category specified programmatically if (mSelectedGroupId >= 0) { // Set category selector value if (!RequestHelper.IsPostBack()) { drpCategory.SelectedCategory = mSelectedGroupId; } // Hide category selector trCategory.Visible = false; } else { // Set category selector value if (!URLHelper.IsPostback() && (SettingsKeyObj != null) && (SettingsKeyObj.KeyCategoryID > 0)) { drpCategory.SelectedCategory = SettingsKeyObj.KeyCategoryID; } } if (!URLHelper.IsPostback()) { LoadKeyTypes(); } // Disable editing for keys not assigned to current module if (SettingsKeyObj != null) { SettingsCategoryInfo parentCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(SettingsKeyObj.KeyCategoryID); ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(ModuleID); plnEdit.Enabled = btnOk.Enabled = (resource != null) && (((parentCategory != null) && (parentCategory.CategoryResourceID == resource.ResourceId) && resource.ResourceIsInDevelopment) || SystemContext.DevelopmentMode); } ucControlSettings.BasicForm.EnsureMessagesPlaceholder(MessagesPlaceHolder); }
/// <summary> /// Get path to the given settings category. /// </summary> /// <param name="settingsKeyCategoryInfo">The key that path is generated for</param> /// <returns>Path to the given settings category</returns> private IEnumerable <SettingsCategoryInfo> GetCategoryPath(SettingsCategoryInfo settingsKeyCategoryInfo) { var sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(settingsKeyCategoryInfo.CategoryParentID); while (sci != null) { yield return(sci); sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(sci.CategoryParentID); } }
/// <summary> /// Raised after menu action (new, delete, up or down) has been taken. /// </summary> protected void menuElem_AfterAction(string actionName, object actionArgument) { string[] split = actionArgument.ToString().Split('|'); int categoryId = ValidationHelper.GetInteger(split[0], 0); SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (category != null) { treeSettings.SelectPath = category.CategoryIDPath; treeSettings.SelectedItem = category.CategoryName; switch (actionName.ToLower()) { case "delete": treeSettings.ExpandPath = category.CategoryIDPath + "/"; // Reload header and content after save StringBuilder sb = new StringBuilder(); sb.Append("if (window.parent != null) {"); sb.Append("if (window.parent.frames['customsettingsmain'] != null) {"); sb.Append("window.parent.frames['customsettingsmain'].location = '" + ResolveUrl("CustomSettingsCategory_Default.aspx") + "?categoryid=" + categoryId + "';"); sb.Append("}"); sb.Append("}"); this.ltlScript.Text += ScriptHelper.GetScript(sb.ToString()); treeSettings.ExpandPath = category.CategoryIDPath + "/"; // Update menu actions parameters this.menuElem.Value = category.CategoryID + "|" + category.CategoryParentID; break; case "moveup": if (split.Length == 2) { this.ltlScript.Text += ScriptHelper.GetScript("window.tabIndex = " + split[1] + ";"); } break; case "movedown": if (split.Length == 2) { this.ltlScript.Text += ScriptHelper.GetScript("window.tabIndex = " + split[1] + ";"); } break; } this.ltlScript.Text += ScriptHelper.GetScript("SelectNode(" + ScriptHelper.GetString(category.CategoryName) + ");"); this.ltlScript.Text += ScriptHelper.GetScript("var postParentId = " + category.CategoryParentID + ";"); // Load data treeSettings.ReloadData(); } }
/// <summary> /// Generate info text for given setting key /// </summary> /// <param name="ski">Setting key object</param> private String GenerateInfoText(SettingsKeyInfo ski) { // Get setting's group SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(ski.KeyCategoryID); // Get resource name from group ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(sci.CategoryResourceID); string resourceName = ResHelper.LocalizeString(ri.ResourceDisplayName); string path = string.Join(" -> ", GetCategoryPath(sci).Reverse().Select(s => ResHelper.LocalizeString(s.CategoryDisplayName))); return(String.Format(GetString("ui.moduledisabled.general"), resourceName, path, ResHelper.GetString(ski.KeyDisplayName))); }
protected void btnDeleteElem_Click(object sender, EventArgs e) { GetHiddenValues(); if ((ElementID > 0) && (ParentID > 0)) { SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(ElementID); if (categoryObj.CategoryName != "CMS.CustomSettings") { SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(categoryObj); if (AfterAction != null) { AfterAction("delete", ParentID); } } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); int categoryId = QueryHelper.GetInteger("categoryid", -1); // Get root of tree mTreeRoot = QueryHelper.GetString("treeroot", "customsettings"); // Get site id mSiteId = QueryHelper.GetInteger("siteid", 0); // Find category if (categoryId >= 0) { mCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); } // Use root category for CustomSettings or Settings if category not found or specified if ((categoryId == -1) || (mCategory == null)) { switch (mTreeRoot) { case ("customsettings"): grpEdit.CategoryName = "CMS.CustomSettings"; break; case ("settings"): default: grpEdit.CategoryName = "CMS.Settings"; break; } mCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(grpEdit.CategoryName); } grpEdit.CategoryName = mCategory.CategoryName; grpEdit.SiteID = mSiteId; grpEdit.ActionPerformed += new CommandEventHandler(grpEdit_ActionPerformed); grpEdit.OnNewKey += new CommandEventHandler(grpEdit_OnNewKey); grpEdit.OnKeyAction += new OnActionEventHandler(grpEdit_OnKeyAction); // Read data grpEdit.ReloadData(); }
/// <summary> /// Raised after menu action (new, delete, up or down) has been taken. /// </summary> protected void AfterAction(string actionName, int categoryId, int tabIndex = 0) { SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if ((category.CategoryResourceID != ModuleID) && !SystemContext.DevelopmentMode) { // If parent doesn't belong to current module, try find first module category DataSet ds = SettingsCategoryInfoProvider.GetSettingsCategories("CategoryResourceID = " + ModuleID, "CategoryLevel, CategoryOrder", 1); if (!DataHelper.DataSourceIsEmpty(ds)) { category = new SettingsCategoryInfo(ds.Tables[0].Rows[0]); } } SelectPath = category.CategoryIDPath; SelectedItem = category.CategoryName; string scriptAction = String.Empty; switch (actionName.ToLowerCSafe()) { case "delete": ExpandPath = category.CategoryIDPath + "/"; // Update menu actions parameters Value = category.CategoryID + "|" + category.CategoryParentID; break; case "moveup": scriptAction = "window.tabIndex = " + tabIndex + ";"; break; case "movedown": scriptAction = "window.tabIndex = " + tabIndex + ";"; break; } RegisterSelectNodeScript(category); scriptAction += "var postParentId = " + category.CategoryParentID + ";"; ScriptHelper.RegisterStartupScript(this, typeof(string), "afterActionScript", ScriptHelper.GetScript(scriptAction)); // Load data ReloadData(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); int categoryId = QueryHelper.GetInteger("categoryid", -1); // Find category if (categoryId >= 0) { mCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); } // Use root category for Settings if category not found or specified if ((categoryId == -1) || (mCategory == null)) { mCategory = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("CMS.Settings"); } // Set edited object EditedObject = mCategory; if (mCategory.CategoryParentID != 0) { grpEdit.CategoryName = mCategory.CategoryName; grpEdit.ModuleID = moduleId; grpEdit.ActionPerformed += grpEdit_ActionPerformed; grpEdit.OnNewKey += grpEdit_OnNewKey; grpEdit.OnKeyAction += grpEdit_OnKeyAction; // Read data grpEdit.ReloadData(); } if (!Resource.ResourceIsInDevelopment && !SystemContext.DevelopmentMode) { // Show information about installed module ShowInformation(GetString("settingcategory.installedmodule")); } else if ((mCategory.CategoryID == categoryId) && (mCategory.CategoryParentID == 0)) { // Show information about creating module categories and groups ShowInformation(GetString("settingcategory.createmodulecategory")); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Parent category info for level up link SettingsCategoryInfo parentCategoryInfo = null; var categoryBreadcrumb = new BreadcrumbItem(); if (mCategoryId <= 0) { catEdit.ShowParentSelector = false; if (catEdit.SettingsCategoryObj == null) { categoryBreadcrumb.Text = GetString(catEdit.IsGroupEdit ? "settings.group.new" : "settingsedit.category_list.newitemcaption"); } else { categoryBreadcrumb.Text = catEdit.SettingsCategoryObj.CategoryDisplayName; } } else { categoryBreadcrumb.Text = GetString(catEdit.IsGroupEdit ? catEdit.SettingsCategoryObj.CategoryDisplayName : "settingsedit.settingscategory.edit.headercaption"); } var parentCategoryBreadcrumb = new BreadcrumbItem(); parentCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(catEdit.SelectedParentCategory); // Set up title and breadcrumbs if (parentCategoryInfo != null) { parentCategoryBreadcrumb.Text = ResHelper.LocalizeString(parentCategoryInfo.CategoryDisplayName); parentCategoryBreadcrumb.RedirectUrl = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditKeys", false), "categoryid=" + parentCategoryInfo.CategoryID + "&moduleid=" + moduleId); } if (mCategoryId <= 0 || catEdit.IsGroupEdit) { PageBreadcrumbs.AddBreadcrumb(parentCategoryBreadcrumb); PageBreadcrumbs.AddBreadcrumb(categoryBreadcrumb); } }
/// <summary> /// DataBinds the control. /// </summary> public void ReloadData() { DisabledItems = string.Empty; this.drpCategories.Items.Clear(); int shift = -1; string where = string.Empty; if (DisplayOnlyCategories) { // Only categories that are not marked as groups will be displayed where += "ISNULL([CategoryIsGroup], 0) = 0"; } if (!string.IsNullOrEmpty(WhereCondition)) { // Append additional WHERE condition where += " AND " + WhereCondition; } // Add root category item if needed if (this.IncludeRootCategory) { SettingsCategoryInfo rootCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(this.RootCategoryId); if (rootCat != null) { ListItem item = new ListItem(); item.Text = GetPrefix(shift) + ResHelper.LocalizeString(rootCat.CategoryDisplayName); item.Value = this.RootCategoryId.ToString(); this.drpCategories.Items.Add(item); DisableItemInKeyEdit(item, rootCat.CategoryIsGroup); // Increase indent shift++; } } DataSet ds = SettingsCategoryInfoProvider.GetSettingsCategories(where, "CategoryOrder", 0, "CategoryID, CategoryParentID, CategoryName, CategoryDisplayName, CategoryOrder, CategoryIsGroup"); if (!DataHelper.DataSourceIsEmpty(ds)) { this.groupedDS = new GroupedDataSource(ds, "CategoryParentID"); FillDropDownList(shift, this.RootCategoryId); } }
/// <summary> /// Handles the whole category actions. /// </summary> /// <param name="sender">Sender of event</param> /// <param name="e">Event arguments</param> protected void grpEdit_ActionPerformed(object sender, CommandEventArgs e) { int categoryId = ValidationHelper.GetInteger(e.CommandArgument, 0); switch (e.CommandName.ToLowerCSafe()) { case ("edit"): SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (sci != null) { URLHelper.Redirect("~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Edit.aspx?treeroot=" + mTreeRoot + "&isgroup=1&categoryid=" + categoryId); } break; case ("delete"): try { SettingsCategoryInfo categoryObj = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (categoryObj.CategoryName != "CMS.CustomSettings") { SettingsCategoryInfoProvider.DeleteSettingsCategoryInfo(categoryObj); } } catch { lblError.Text = GetString("settings.group.deleteerror"); lblError.Visible = true; } grpEdit.ReloadData(); break; case ("moveup"): SettingsCategoryInfoProvider.MoveCategoryUp(categoryId); grpEdit.ReloadData(); break; case ("movedown"): SettingsCategoryInfoProvider.MoveCategoryDown(categoryId); grpEdit.ReloadData(); break; } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var categoryBreadcrumb = new BreadcrumbItem(); var settingBreadcrumb = new BreadcrumbItem(); // Set bradcrumbs for editing if (skeEditKey.SettingsKeyObj != null) { var sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(skeEditKey.SettingsKeyObj.KeyCategoryID); categoryBreadcrumb.Text = sci.CategoryDisplayName; categoryBreadcrumb.RedirectUrl = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditKeys", false), "categoryid=" + sci.CategoryParentID + "&moduleid=" + mModuleId); settingBreadcrumb.Text = skeEditKey.SettingsKeyObj.KeyDisplayName; } // Set bradcrumbs for creating new key else { if (mParentGroup != null) { var parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup); if (parentCat != null) { categoryBreadcrumb.Text = parentCat.CategoryDisplayName; categoryBreadcrumb.RedirectUrl = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditKeys", false), "categoryid=" + parentCat.CategoryParentID + "&moduleid=" + mModuleId); settingBreadcrumb.Text = GetString("Development.CustomSettings.NewKey"); } } } PageBreadcrumbs.AddBreadcrumb(categoryBreadcrumb); PageBreadcrumbs.AddBreadcrumb(settingBreadcrumb); }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(Page); SitePanel.Visible = ShowHeaderPanel && ShowSiteSelector; ActionsPanel.Visible = ShowHeaderPanel && !SitePanel.Visible; plcActionSelectionScript.Visible = ShowHeaderPanel && !ShowSiteSelector; plcSelectionScript.Visible = !plcActionSelectionScript.Visible; if (RootCategory != null) { string levelWhere = (MaxRelativeLevel <= 0 ? "" : " AND (CategoryLevel <= " + (RootCategory.CategoryLevel + MaxRelativeLevel) + ")"); // Restrict CategoryChildCount to MaxRelativeLevel. If level < MaxRelativeLevel, use count of non-group children. string levelColumn = "CASE CategoryLevel WHEN " + MaxRelativeLevel + " THEN 0 ELSE (SELECT COUNT(*) AS CountNonGroup FROM CMS_SettingsCategory AS sc WHERE (sc.CategoryParentID = CMS_SettingsCategory.CategoryID) AND (sc.CategoryIsGroup = 0)) END AS CategoryChildCount"; // Create and set category provider UniTreeProvider provider = new UniTreeProvider(); provider.RootLevelOffset = RootCategory.CategoryLevel; provider.ObjectType = "CMS.SettingsCategory"; provider.DisplayNameColumn = "CategoryDisplayName"; provider.IDColumn = "CategoryID"; provider.LevelColumn = "CategoryLevel"; provider.OrderColumn = "CategoryOrder"; provider.ParentIDColumn = "CategoryParentID"; provider.PathColumn = "CategoryIDPath"; provider.ValueColumn = "CategoryID"; provider.ChildCountColumn = "CategoryChildCount"; provider.ImageColumn = "CategoryIconPath"; provider.WhereCondition = "((CategoryIsGroup IS NULL) OR (CategoryIsGroup = 0)) " + levelWhere; if (!ShowEmptyCategories) { var where = "CategoryID IN (SELECT CategoryParentID FROM CMS_SettingsCategory WHERE (CategoryIsGroup = 0) OR (CategoryIsGroup = 1 AND CategoryID IN (SELECT KeyCategoryID FROM CMS_SettingsKey WHERE ISNULL(SiteID, 0) = 0 AND ISNULL(KeyIsHidden, 0) = 0"; if (SiteID > 0) { where += " AND KeyIsGlobal = 0"; } where += ")))"; provider.WhereCondition = SqlHelper.AddWhereCondition(provider.WhereCondition, where); } provider.Columns = "CategoryID, CategoryName, CategoryDisplayName, CategoryLevel, CategoryOrder, CategoryParentID, CategoryIDPath, CategoryIconPath, CategoryResourceID, " + levelColumn; if (String.IsNullOrEmpty(JavaScriptHandler)) { Tree.SelectedNodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ##NAMECSSCLASS## ContentTreeSelectedItem\" onclick=\"SelectNode('##NODECODENAME##');\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; Tree.NodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ##NAMECSSCLASS##\" onclick=\"SelectNode('##NODECODENAME##');\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; } else { Tree.SelectedNodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ##NAMECSSCLASS## ContentTreeSelectedItem\" onclick=\"SelectNode('##NODECODENAME##'); if (" + JavaScriptHandler + ") { " + JavaScriptHandler + "('##NODECODENAME##',##NODEID##, ##SITEID##, ##PARENTID##, ##RESOURCEID##); }\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; Tree.NodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ##NAMECSSCLASS##\" onclick=\"SelectNode('##NODECODENAME##'); if (" + JavaScriptHandler + ") { " + JavaScriptHandler + "('##NODECODENAME##',##NODEID##, ##SITEID##, ##PARENTID##, ##RESOURCEID##); }\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; } Tree.UsePostBack = false; Tree.ProviderObject = provider; Tree.ExpandPath = RootCategory.CategoryIDPath; Tree.OnNodeCreated += Tree_OnNodeCreated; } GetExpandedPaths(); NewItemButton.ToolTip = GetString("settings.newelem"); DeleteItemButton.ToolTip = GetString("settings.deleteelem"); MoveUpItemButton.ToolTip = GetString("settings.modeupelem"); MoveDownItemButton.ToolTip = GetString("settings.modedownelem"); // Create new element javascript NewItemButton.OnClientClick = "return newItem();"; // Confirm delete DeleteItemButton.OnClientClick = "if(!deleteConfirm()) { return false; }"; var isPostback = RequestHelper.IsPostBack(); if (!isPostback) { Tree.ReloadData(); if (QueryHelper.GetBoolean("reloadtreeselect", false)) { var category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(CategoryID); // Select requested category RegisterSelectNodeScript(category); } } if (ShowSiteSelector) { if (!isPostback) { if (QueryHelper.Contains("selectedSiteId")) { // Get from URL SiteID = QueryHelper.GetInteger("selectedSiteId", 0); SiteSelector.Value = SiteID; } } else { SiteID = ValidationHelper.GetInteger(SiteSelector.Value, 0); } // Style site selector SiteSelector.SetValue("AllowGlobal", true); SiteSelector.SetValue("GlobalRecordValue", 0); bool reload = QueryHelper.GetBoolean("reload", true); // URL for tree selection string script = "var categoryURL = '" + UIContextHelper.GetElementUrl(ModuleName.CMS, "Settings.Keys") + "';\n"; script += "var doNotReloadContent = false;\n"; // Select category SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(CategoryID); if (sci != null) { // Stop reloading of right frame, if explicitly set if (!reload) { script += "doNotReloadContent = true;"; } script += SelectAtferLoad(sci.CategoryIDPath, sci.CategoryName, sci.CategoryID, sci.CategoryParentID); } ScriptHelper.RegisterStartupScript(Page, typeof(string), "SelectCat", ScriptHelper.GetScript(script)); } else { ResourceInfo resource = ResourceInfoProvider.GetResourceInfo(ModuleID); StringBuilder sb = new StringBuilder(); sb.Append(@" var frameURL = '", UIContextHelper.GetElementUrl(ModuleName.CMS, "EditSettingsCategory", false), @"'; var rootId = ", (RootCategory != null ? RootCategory.CategoryID : 0), @"; var selectedModuleId = ", ModuleID, @"; var developmentMode = ", SystemContext.DevelopmentMode ? "true" : "false", @"; var resourceInDevelopment = ", (resource != null) && resource.ResourceIsInDevelopment ? "true" : "false", @"; var postParentId = ", CategoryID, @"; function newItem() { var hidElem = document.getElementById('" + hidSelectedElem.ClientID + @"'); var ids = hidElem.value.split('|'); if (window.parent != null && window.parent.frames['settingsmain'] != null) { window.parent.frames['settingsmain'].location = '" + ResolveUrl("~/CMSModules/Modules/Pages/Settings/Category/Edit.aspx") + @"?moduleid=" + ModuleID + @"&parentId=' + ids[0]; } return false; } function deleteConfirm() { return confirm(" + ScriptHelper.GetString(GetString("settings.categorydeleteconfirmation")) + @"); } "); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "setupTreeScript", ScriptHelper.GetScript(sb.ToString())); } }
protected void Page_Load(object sender, EventArgs e) { int siteId = QueryHelper.GetInteger("siteid", 0); int categoryId = QueryHelper.GetInteger("categoryid", 0); string searchText = QueryHelper.GetString("search", ""); bool searchInDescription = QueryHelper.GetBoolean("description", false); // Get the category SettingsCategoryInfo ci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); // If category is set or search is used if ((ci != null) || (string.IsNullOrEmpty(searchText))) { StringBuilder sb = new StringBuilder(); // Prepare the header of the file SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si == null) { sb.Append("Global settings, "); } else { sb.Append("Settings for site \"" + si.DisplayName + "\", "); } DataSet groups = new DataSet(); // Get right DataSet of settings category groups if (!string.IsNullOrEmpty(searchText)) { sb.Append("search text \"" + searchText + "\"" + Environment.NewLine + Environment.NewLine); groups = SettingsCategoryInfoProvider.GetSettingsCategories("CategoryIsGroup = 1", "CategoryName", -1, " CategoryID, CategoryDisplayName, CategoryIDPath"); } else { sb.Append("category \"" + ResHelper.LocalizeString(GetCategoryPathNames(ci)) + "\"" + Environment.NewLine + Environment.NewLine); groups = SettingsCategoryInfoProvider.GetSettingsCategories(string.Format("CategoryParentID = {0} AND CategoryIsGroup = 1", ci.CategoryID), "CategoryOrder", -1, " CategoryID, CategoryDisplayName"); } // Iterate over all groups under selected category foreach (DataRow groupRow in groups.Tables[0].Rows) { string groupName = ResHelper.LocalizeString(groupRow["CategoryDisplayName"].ToString()); int groupCategoryId = ValidationHelper.GetInteger(groupRow["CategoryID"], -1); // Get all settings keys in specified group DataSet ds = SettingsKeyProvider.GetSettingsKeysOrdered(siteId, groupCategoryId); if (!DataHelper.DataSourceIsEmpty(ds)) { string result = GetGroupKeys(ds.Tables[0], siteId > 0, searchText, searchInDescription); if (!string.IsNullOrEmpty(result)) { if (!string.IsNullOrEmpty(searchText)) { // Get parent categories names string parentName = ResHelper.LocalizeString(GetCategoryNames(groupRow["CategoryIDPath"].ToString())); // Print group name with parent sb.Append(Environment.NewLine + parentName + " - " + groupName + Environment.NewLine + GROUP_SEPARATOR + Environment.NewLine + Environment.NewLine); } else { // Print group name sb.Append(Environment.NewLine + groupName + Environment.NewLine + GROUP_SEPARATOR + Environment.NewLine + Environment.NewLine); } // Print SettingsKey names and values sb.Append(result); } } } // Send the file to the user string siteName = (siteId > 0 ? si.SiteName : "Global"); Response.AddHeader("Content-disposition", "attachment; filename=" + siteName + "_" + ValidationHelper.GetIdentifier(ci.CategoryName, "_") + ".txt"); Response.ContentType = "text/plain"; Response.Write(sb.ToString()); RequestHelper.EndResponse(); } }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(this.Page); // Root of tree flag string treeRoot = QueryHelper.GetString("treeroot", "customsettings"); // Decide which category to use as root: custom settings or settings switch (treeRoot) { case ("settings"): treeSettings.CategoryName = "CMS.Settings"; treeSettings.RootIsClickable = true; this.menuElem.WholeSettings = true; break; case ("customsettings"): default: treeSettings.CategoryName = "CMS.CustomSettings"; this.menuElem.WholeSettings = false; break; } this.menuElem.AfterAction += new OnActionEventHandler(menuElem_AfterAction); // Prepare root info SettingsCategoryInfo rootCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(treeSettings.CategoryName); StringBuilder sb = new StringBuilder(""); StringBuilder sbAfter = new StringBuilder(""); // Create links for JS sb.Append("var frameURL = '").Append(ResolveUrl("~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Default.aspx?treeroot=" + ScriptHelper.GetString(treeRoot, false))).Append("';"); sb.Append("var newURL = '").Append(ResolveUrl("~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Edit.aspx?treeroot=" + ScriptHelper.GetString(treeRoot, false))).Append("';"); sb.Append("var rootParentId = ").Append(rootCat != null ? rootCat.CategoryParentID : 0).Append(";"); // Disable delete on custom settings category if (treeRoot == "settings") { DataSet ds = SettingsCategoryInfoProvider.GetSettingsCategories("CategoryName = 'CMS.CustomSettings'", null, 1, "CategoryID"); int customSettingsId = 0; if (!DataHelper.DataSourceIsEmpty(ds)) { customSettingsId = SqlHelperClass.GetInteger(ds.Tables[0].Rows[0]["CategoryID"], 0); } sb.Append("var customSettingsId = ").Append(customSettingsId).Append(";"); } else { sb.Append("var customSettingsId = 0;"); } if (!RequestHelper.IsPostBack()) { int categoryId = QueryHelper.GetInteger("categoryid", -1); treeSettings.SelectPath = "/"; SettingsCategoryInfo category = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); // Select requested category if (category != null) { treeSettings.SelectPath = category.CategoryIDPath; this.menuElem.ElementID = category.CategoryID; this.menuElem.ParentID = category.CategoryParentID; this.menuElem.Value = category.CategoryID + "|" + category.CategoryParentID; // Select category after page load sbAfter.Append("SelectNode(" + ScriptHelper.GetString(category.CategoryName) + ");"); sbAfter.Append("enableMenu(").Append(category.CategoryID).Append(",").Append(category.CategoryParentID).Append(");"); } // Select root else { if (rootCat != null) { this.menuElem.ElementID = rootCat.CategoryID; this.menuElem.ParentID = rootCat.CategoryParentID; this.menuElem.Value = rootCat.CategoryID + "|" + rootCat.CategoryParentID; } // Select category after page load sbAfter.Append("SelectNode(").Append(ScriptHelper.GetString(treeSettings.CategoryName)).Append(");"); sbAfter.Append("enableMenu(").Append(rootCat.CategoryID).Append(",").Append(rootCat.CategoryParentID).Append(");"); } } sb.Append("var postParentId = ").Append(rootCat.CategoryParentID).Append(";"); this.ltlScript.Text = ScriptHelper.GetScript(sb.ToString()); this.ltlAfterScript.Text = ScriptHelper.GetScript(sbAfter.ToString()); }
/// <summary> /// Handles OnClick event of btnOK. /// </summary> /// <param name="sender">Asp Button instance</param> /// <param name="e">EventArgs instance</param> protected void btnOK_Click(object sender, EventArgs e) { if (IsValid()) { // Try to get SettingsKey object by name SettingsKeyInfo sk = SettingsKeyProvider.GetSettingsKeyInfo(txtKeyName.Text.Trim()); if ((sk == null) || (sk.KeyID == mSettingsKeyId)) { SettingsKeyInfo ski = (mSettingsKeyId > 0) ? SettingsKeyProvider.GetSettingsKeyInfo(mSettingsKeyId) : null; if (ski == null) { ski = new SettingsKeyInfo(); UpdateAllSitesKey(txtKeyName.Text.Trim(), ski, true); } else { UpdateAllSitesKey(ski.KeyName, ski, false); } mSettingsKeyId = ski.KeyID; RaiseOnSaved(); // Set the info message lblInfo.Text = GetString("general.changessaved"); // Select 'Keep current settings' option for load generation property drpGeneration.Value = -1; if ((TreeRefreshUrl != null) || (HeaderRefreshUrl != null)) { int parentCatForGroupId = mSelectedGroupId >= 0 ? mSelectedGroupId : drpCategory.SelectedCategory; SettingsCategoryInfo parentCategoryForGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(parentCatForGroupId); if (parentCategoryForGroup != null) { int categoryIdToShow = parentCategoryForGroup.CategoryParentID; StringBuilder sb = new StringBuilder(); sb.Append("if (window.parent != null) {"); if (HeaderRefreshUrl != null) { sb.Append("if (window.parent.parent.frames['customsettingscategorytabs'] != null) {"); sb.Append("window.parent.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';"); sb.Append("}"); sb.Append("if (window.parent.frames['customsettingscategorytabs'] != null) {"); sb.Append("window.parent.frames['customsettingscategorytabs'].location = '" + ResolveUrl(HeaderRefreshUrl) + "categoryid=" + categoryIdToShow + "';"); sb.Append("}"); } if (TreeRefreshUrl != null) { sb.Append("if (window.parent.parent.frames['customsettingstree'] != null) {"); sb.Append("window.parent.parent.frames['customsettingstree'].location = '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';"); sb.Append("}"); sb.Append("if (window.parent.frames['customsettingstree'] != null) {"); sb.Append("window.parent.frames['customsettingstree'].location = '" + ResolveUrl(TreeRefreshUrl) + "categoryid=" + categoryIdToShow + "';"); sb.Append("}"); } sb.Append("}"); ltlScript.Text = ScriptHelper.GetScript(sb.ToString()); } } } else { lblError.Text = ResHelper.GetString("general.codenameexists"); } } }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(Page); // URL for tree selection string script = "var categoryURL = '" + ResolveUrl("keys.aspx") + "';\n"; script += "var doNotReloadContent = false;\n"; // Get selected site id mSiteId = ValidationHelper.GetInteger(siteSelector.Value, 0); TreeViewCategories.SiteID = mSiteId; TreeViewCategories.RootIsClickable = true; bool searchMode = false; int categoryId = 0; if (Request.Params["selectedCategoryId"] != null) { // Selected category categoryId = ValidationHelper.GetInteger(Request.Params["selectedCategoryId"], 0); searchMode = true; } else { // First request to Settings categoryId = SettingsCategoryInfoProvider.GetRootSettingsCategoryInfo().CategoryID; searchMode = SettingsKeyProvider.DevelopmentMode; } TreeViewCategories.RootIsClickable = SettingsKeyProvider.DevelopmentMode; bool reload = QueryHelper.GetBoolean("reload", true); // Select category if set if ((categoryId > 0) && (searchMode)) { SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(categoryId); if (sci != null) { // Stop reloading of right frame, if explicitly set if (!reload) { script += "doNotReloadContent = true;"; } script += SelectAtferLoad(sci.CategoryIDPath, sci.CategoryName, sci.CategoryID, sci.CategoryParentID); } } // If no category specified, select the first category under root by default else { SettingsCategoryInfo sci = SettingsCategoryInfoProvider.GetRootSettingsCategoryInfo(); TreeViewCategories.RootCategory = sci; if (sci != null) { TreeViewCategories.RootIsClickable = false; DataSet ds = SettingsCategoryInfoProvider.GetSettingsCategories(string.Format("CategoryParentID = {0}", sci.CategoryID), "CategoryOrder", 1, "CategoryIDPath, CategoryName, CategoryID, CategoryParentID"); if (!DataHelper.DataSourceIsEmpty(ds)) { DataRow firstRow = ds.Tables[0].Rows[0]; script += SelectAtferLoad(SqlHelperClass.GetString(firstRow["CategoryIDPath"], "/"), SqlHelperClass.GetString(firstRow["CategoryName"], "CMS.Settings"), SqlHelperClass.GetInteger(firstRow["CategoryID"], 0), SqlHelperClass.GetInteger(firstRow["CategoryParentID"], 0)); } } } ScriptHelper.RegisterStartupScript(Page, typeof(string), "SelectCat", ScriptHelper.GetScript(script)); // Style site selector siteSelector.DropDownSingleSelect.CssClass = ""; siteSelector.DropDownSingleSelect.Attributes.Add("style", "width: 100%"); lblSite.Text = GetString("general.site") + ResHelper.Colon; // Set site selector siteSelector.DropDownSingleSelect.AutoPostBack = true; siteSelector.AllowAll = false; siteSelector.UniSelector.SpecialFields = new string[1, 2] { { GetString("general.global"), "0" } }; siteSelector.OnlyRunningSites = false; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); string[,] breadcrumbs = new string[2, 4]; breadcrumbs[0, 2] = "customsettingsmain"; // Get root category: Settings or CustomSettings SettingsCategoryInfo customSettingsRoot = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mTreeRoot == "settings" ? "CMS.Settings" : "CMS.CustomSettings"); // Parent category info for level up link SettingsCategoryInfo parentCategoryInfo = null; if (mCategoryId <= 0) { // Set new title string title = GetString(catEdit.IsGroupEdit ? "settings.group.new" : "settingsedit.category_list.newitemcaption"); if (!catEdit.IsGroupEdit && mShowTitle) { CurrentMaster.Title.TitleText = title; } catEdit.ShowParentSelector = false; if (catEdit.SettingsCategoryObj == null) { catEdit.RootCategoryID = mParentId; parentCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(mParentId); breadcrumbs[1, 0] = title; } else { parentCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(catEdit.SettingsCategoryObj.CategoryParentID); breadcrumbs[1, 0] = catEdit.SettingsCategoryObj.CategoryDisplayName; } } else { SetEditEnabled(false); // One level up link category Id, but maximaly to current root mLinkCatId = customSettingsRoot.CategoryID == catEdit.SettingsCategoryObj.CategoryParentID ? customSettingsRoot.CategoryID : (catEdit.IsGroupEdit ? catEdit.SettingsCategoryObj.CategoryParentID : catEdit.SettingsCategoryObj.CategoryID); parentCategoryInfo = SettingsCategoryInfoProvider.GetSettingsCategoryInfo(mLinkCatId); breadcrumbs[1, 0] = GetString(catEdit.IsGroupEdit ? catEdit.SettingsCategoryObj.CategoryDisplayName : "settingsedit.settingscategory.edit.headercaption"); if (mShowTitle && !catEdit.IsGroupEdit) { CurrentMaster.Title.TitleText = GetString("settingsedit.settingscategory.edit.headercaption"); } if (catEdit.SettingsCategoryObj.CategoryID != customSettingsRoot.CategoryID) { SetEditEnabled(true); // Allow assigning of all categories in edit mode catEdit.RootCategoryID = customSettingsRoot != null ? customSettingsRoot.CategoryID : catEdit.SettingsCategoryObj.CategoryParentID; catEdit.IsGroupEdit = catEdit.SettingsCategoryObj.CategoryIsGroup; } } // Set up title and breadcrumbs if (parentCategoryInfo != null) { breadcrumbs[0, 0] = ResHelper.LocalizeString(parentCategoryInfo.CategoryDisplayName); breadcrumbs[0, 1] = ResolveUrl("~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Default.aspx") + "?treeroot=" + mTreeRoot + "&categoryid=" + parentCategoryInfo.CategoryID; } if (mCategoryId <= 0 || catEdit.IsGroupEdit) { CurrentMaster.Title.Breadcrumbs = breadcrumbs; } CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_CustomSettings/object.png"); }