/// <summary> /// This method is used to load settings from the DNN Settings collection, for upgrade sites /// </summary> /// <param name="moduleId"></param> /// <param name="Settings"></param> public static ModuleSettingsInfo LoadSettingsFromDnn(int moduleId, Hashtable Settings) { var validSettings = true; var oNewSettings = new ModuleSettingsInfo(); var oModController = new ModuleController(); oNewSettings.ModuleId = moduleId; //If we have CSS settings use them object titleCssSetting = Settings["ICG_ETH_TitleCss"]; object contentCssSetting = Settings["ICG_ETH_ContentCss"]; object sortOrderSettings = Settings["ICG_ETH_SortOrder"]; if (titleCssSetting != null) { oNewSettings.TitleCss = titleCssSetting.ToString(); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_TitleCss"); } else validSettings = false; if (contentCssSetting != null) { oNewSettings.TitleCss = contentCssSetting.ToString(); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_ContentCss"); } else validSettings = false; if (sortOrderSettings != null) { oNewSettings.SortOrder = sortOrderSettings.ToString(); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_SortOrder"); } else validSettings = false; if (Settings["ICG_ETH_ExpandOnPrint"] != null) { oNewSettings.ExpandOnPrint = bool.Parse(Settings["ICG_ETH_ExpandOnPrint"].ToString()); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_ExpandOnPrint"); } else validSettings = false; //Load the jquerysettings, if enable object jquerySetting = Settings["ICG_ETH_JQuery"]; if (jquerySetting != null) { oNewSettings.UseJquery = bool.Parse(jquerySetting.ToString()); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_JQuery"); } else validSettings = false; object displayLimitSetting = Settings["ICG_ETH_DisplayLimit"]; if (displayLimitSetting != null) { oNewSettings.DisplayLimit = int.Parse(displayLimitSetting.ToString()); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_DisplayLimit"); } else validSettings = false; //Also get show all text object showAllTextSetting = Settings["ICG_ETH_ShowAllText"]; if (showAllTextSetting != null) { oNewSettings.ShowAllText = showAllTextSetting.ToString(); oModController.DeleteModuleSetting(moduleId, "ICG_ETH_ShowAllText"); } else validSettings = false; if (validSettings) { oNewSettings.ShowExpandCollapseAll = true; Save(oNewSettings); return oNewSettings; } else { return null; } }
/// <summary> /// Updates the cache with the module settings for 20 minutes /// </summary> /// <param name="oinfo"></param> private static void UpdateCache(ModuleSettingsInfo oinfo) { if (oinfo != null) { string cacheKey = oinfo.ModuleId.ToString() + "_ICG_ETH_SETTINGS"; DataCache.SetCache(cacheKey, oinfo, new TimeSpan(0, 10, 0)); } }
/// <summary> /// handles updating the module settings for this control /// </summary> public override void UpdateSettings() { try { //Save the setting ModuleSettingsInfo oInfo = new ModuleSettingsInfo(); oInfo.ContentCss = txtContentCssClass.Text; oInfo.DisplayLimit = int.Parse(ddlDefaultShowLimit.SelectedValue); oInfo.ExpandOnPrint = chkExpandOnPrint.Checked; txtHeader.HtmlEncode = false; if (txtHeader.Text.Length > 10 && !txtHeader.Text.Equals("<p> </p>")) oInfo.HeaderText = txtHeader.Text; else oInfo.HeaderText = string.Empty; oInfo.ModuleId = ModuleId; oInfo.ShowAllText = txtShowAllText.Text; oInfo.SortOrder = ddlSortOrder.SelectedValue; oInfo.TitleCss = txtTitleCssClass.Text; oInfo.UseJquery = true; oInfo.ShowExpandCollapseAll = chkShowExpandCollapseAll.Checked; ModuleSettingsController.Save(oInfo); //Purge the cache ModuleController.SynchronizeModule(ModuleId); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// Saves the new settings /// </summary> /// <param name="oInfo"></param> public static void Save(ModuleSettingsInfo oInfo) { DataProvider.Instance().ModuleSettingsSave(oInfo.ModuleId, oInfo.SortOrder, oInfo.TitleCss, oInfo.ContentCss, oInfo.ExpandOnPrint, oInfo.HeaderText, oInfo.UseJquery, oInfo.DisplayLimit, oInfo.ShowAllText, oInfo.ShowExpandCollapseAll); UpdateCache(oInfo); }
/// <summary> /// This helper method is used to load the module settings from the DNN settings /// hash tables, any configuration elements that are needed are completed as well. /// </summary> /// <remarks> /// Jquery Method action stubs are included for future module use /// </remarks> private void ProcessModuleSettings(ModuleSettingsInfo oInfo) { _titleCssClass = oInfo.TitleCss; _contentCssClass = oInfo.ContentCss; //Get the item template _itemTemplate = GetLocalizeString("ItemTemplate"); //If the user selected forced expanding, see if we are in print mode if (Request.Url.PathAndQuery.Contains("dnnprintmode") && oInfo.ExpandOnPrint) _forceExpand = true; //Get display limit, ONLY if we don't have the "show=all" querystring if (Request.QueryString["show"] == null) { _displayLimit = oInfo.DisplayLimit; _showAllText = oInfo.ShowAllText; } }