Пример #1
0
    /// <summary>
    /// Handles the settings key action event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void grpEdit_OnKeyAction(string actionName, object actionArgument)
    {
        int             keyId = ValidationHelper.GetInteger(actionArgument, 0);
        SettingsKeyInfo ski   = SettingsKeyInfoProvider.GetSettingsKeyInfo(keyId);

        switch (actionName.ToLowerCSafe())
        {
        case ("edit"):
            // Redirect to key edit page
            if (ski != null)
            {
                URLHelper.Redirect(URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ModuleName.CMS, "Modules.Settings.EditSettingsKey", false), "keyname=" + ski.KeyName + "&moduleid=" + moduleId));
            }
            break;

        case ("delete"):
            try
            {
                SettingsKeyInfoProvider.DeleteSettingsKeyInfo(ski);
            }
            catch
            {
                ShowError(GetString("settingsedit.settingskey_edit.errordelete"));
            }
            break;

        case ("moveup"):
            SettingsKeyInfoProvider.MoveSettingsKeyUp(ski.KeyName);
            break;

        case ("movedown"):
            SettingsKeyInfoProvider.MoveSettingsKeyDown(ski.KeyName);
            break;
        }
    }
Пример #2
0
    /// <summary>
    /// Gets and bulk updates settings keys. Called when the "Get and bulk update keys" button is pressed.
    /// Expects the CreateSettingsKey method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSettingsKeys()
    {
        // Prepare the parameters
        string where = "KeyName LIKE N'MyNew%'";

        // Get the data
        DataSet keys = SettingsKeyProvider.GetSettingsKeys(where, null, 0, null);

        if (!DataHelper.DataSourceIsEmpty(keys))
        {
            // Loop through the individual items
            foreach (DataRow keyDr in keys.Tables[0].Rows)
            {
                // Create object from DataRow
                SettingsKeyInfo modifyKey = new SettingsKeyInfo(keyDr);

                // Update the property
                modifyKey.KeyDisplayName = modifyKey.KeyDisplayName.ToUpper();

                // Update the settings key
                SettingsKeyProvider.SetValue(modifyKey);
            }

            return(true);
        }

        return(false);
    }
Пример #3
0
    /// <summary>
    /// Creates settings key. Called when the "Create key" button is pressed.
    /// </summary>
    private bool CreateSettingsKey()
    {
        // Get the settings group
        SettingsCategoryInfo settingsGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsGroup");

        if (settingsGroup != null)
        {
            // Create new settings key object
            SettingsKeyInfo newKey = new SettingsKeyInfo();

            // Set the properties
            newKey.KeyDisplayName  = "My new key";
            newKey.KeyName         = "MyNewKey";
            newKey.KeyDescription  = "My new key description";
            newKey.KeyType         = "string";
            newKey.KeyValue        = "My new value";
            newKey.KeyCategoryID   = settingsGroup.CategoryID;
            newKey.KeyDefaultValue = null;

            // Set Site ID for site specific settings key (for global settings key is default value 0).
            newKey.SiteID = CMSContext.CurrentSiteID;

            // Create the settings key
            SettingsKeyProvider.SetValue(newKey);

            return(true);
        }

        return(false);
    }
Пример #4
0
        private void SettingsKeyUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo setting = e.Object as SettingsKeyInfo;

            if (setting.KeyName == "CMSSalesForceLeadReplicationMapping")
            {
                SettingsKeyInfoProvider.SetGlobalValue("CMSSalesForceLeadReplicationMappingDateTime", DateTime.Now.ToString("s"));
            }
        }
Пример #5
0
 /// <summary>
 /// Updates key values to default after type change.
 /// </summary>
 /// <param name="keyObj">Global key that changed</param>
 private void UpdateKeyValuesAfterTypeChanged(SettingsKeyInfo keyObj)
 {
     // Loop through all the keys (site and global) and set the value to the selected default one
     foreach (var settingKey in SettingsKeyInfoProvider.GetSettingsKeys().WhereEquals("KeyName", keyObj.KeyName))
     {
         settingKey.KeyValue = keyObj.KeyDefaultValue;
         SettingsKeyInfoProvider.SetSettingsKeyInfo(settingKey);
     }
 }
Пример #6
0
    /// <summary>
    /// Deletes settings key. Called when the "Delete key" button is pressed.
    /// Expects the CreateSettingsKey method to be run first.
    /// </summary>
    private bool DeleteSettingsKey()
    {
        // Get the settings key
        SettingsKeyInfo deleteKey = SettingsKeyProvider.GetSettingsKeyInfo("MyNewKey", CMSContext.CurrentSiteID);

        // Delete the settings key
        SettingsKeyProvider.DeleteKey(deleteKey);

        return(deleteKey != null);
    }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get parameters
        mKeyName     = QueryHelper.GetString("keyname", "");
        mSiteId      = QueryHelper.GetInteger("siteid", -1);
        mParentGroup = QueryHelper.GetString("parentgroup", null);
        mTreeRoot    = QueryHelper.GetText("treeroot", "customsettings");

        skeEditKey.IsCustomSetting = mTreeRoot.EqualsCSafe("customsettings", true);
        skeEditKey.OnSaved        += new EventHandler(skeEditKey_OnSaved);

        if (skeEditKey.IsCustomSetting)
        {
            SettingsCategoryInfo root = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("CMS.CustomSettings");
            if (root != null)
            {
                skeEditKey.RootCategoryID = root.CategoryID;
            }
        }

        // Set up editing mode
        if ((mSiteId >= 0) && !string.IsNullOrEmpty(mKeyName))
        {
            mEditedKey = SettingsKeyProvider.GetSettingsKeyInfo(mKeyName, mSiteId);

            // Set id of key
            if (mEditedKey != null)
            {
                skeEditKey.SettingsKeyID = mEditedKey.KeyID;
            }
        }
        // Set up creating mode
        else
        {
            if (mParentGroup != null)
            {
                SettingsCategoryInfo parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup);
                if (parentCat != null)
                {
                    skeEditKey.SelectedGroupID = parentCat.CategoryID;
                }
            }
        }

        // Check if there is something right created to edit.
        if (ViewState["newId"] != null)
        {
            skeEditKey.SettingsKeyID = ValidationHelper.GetInteger(ViewState["newId"], 0);
        }

        skeEditKey.TreeRefreshUrl   = "~/CMSModules/Settings/Development/CustomSettings/CustomSettings_Menu.aspx?treeroot=" + mTreeRoot + "&";
        skeEditKey.HeaderRefreshUrl = "~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Tabs.aspx?selectedtab=keys&treeroot=" + mTreeRoot + "&";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get parameters
        mKeyName = QueryHelper.GetString("keyname", "");
        mSiteId = QueryHelper.GetInteger("siteid", -1);
        mParentGroup = QueryHelper.GetString("parentgroup", null);
        mTreeRoot = QueryHelper.GetText("treeroot", "customsettings");

        skeEditKey.IsCustomSetting = mTreeRoot.EqualsCSafe("customsettings", true);
        skeEditKey.OnSaved += new EventHandler(skeEditKey_OnSaved);

        if (skeEditKey.IsCustomSetting)
        {
            SettingsCategoryInfo root = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("CMS.CustomSettings");
            if (root != null)
            {
                skeEditKey.RootCategoryID = root.CategoryID;
            }
        }

        // Set up editing mode
        if ((mSiteId >= 0) && !string.IsNullOrEmpty(mKeyName))
        {
            mEditedKey = SettingsKeyProvider.GetSettingsKeyInfo(mKeyName, mSiteId);

            // Set id of key
            if (mEditedKey != null)
            {
                skeEditKey.SettingsKeyID = mEditedKey.KeyID;
            }
        }
        // Set up creating mode
        else
        {
            if (mParentGroup != null)
            {
                SettingsCategoryInfo parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup);
                if (parentCat != null)
                {
                    skeEditKey.SelectedGroupID = parentCat.CategoryID;
                }
            }
        }

        // Check if there is something right created to edit.
        if (ViewState["newId"] != null)
        {
            skeEditKey.SettingsKeyID = ValidationHelper.GetInteger(ViewState["newId"], 0);
        }

        skeEditKey.TreeRefreshUrl = "~/CMSModules/Settings/Development/CustomSettings/CustomSettings_Menu.aspx?treeroot=" + mTreeRoot + "&";
        skeEditKey.HeaderRefreshUrl = "~/CMSModules/Settings/Development/CustomSettings/CustomSettingsCategory_Tabs.aspx?selectedtab=keys&treeroot=" + mTreeRoot + "&";
    }
Пример #9
0
    /// <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)));
    }
Пример #10
0
    /// <summary>
    /// Handles the settings key action event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void grpEdit_OnKeyAction(string actionName, object actionArgument)
    {
        int             keyId = ValidationHelper.GetInteger(actionArgument, 0);
        SettingsKeyInfo ski   = SettingsKeyProvider.GetSettingsKeyInfo(keyId);

        switch (actionName.ToLowerCSafe())
        {
        case ("edit"):
            // Redirect to key-editing page
            if (ski != null)
            {
                URLHelper.Redirect("~/CMSModules/Settings/Development/CustomSettings/SettingsKey_Edit.aspx?treeroot=" + mTreeRoot + "&keyname=" + ski.KeyName + "&siteid=" + mSiteId);
            }
            break;

        case ("delete"):
            try
            {
                // Delete all keys
                DataSet ds = SiteInfoProvider.GetSites(null, null, "[SiteName]");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    DataTable tbl = ds.Tables[0];
                    foreach (DataRow row in tbl.Rows)
                    {
                        string siteName = ValidationHelper.GetString(row[0], "");
                        if (!string.IsNullOrEmpty(siteName))
                        {
                            SettingsKeyProvider.DeleteKey(string.Format("{0}.{1}", siteName, ski.KeyName));
                        }
                    }
                }
                SettingsKeyProvider.DeleteKey(ski.KeyName);
            }
            catch
            {
                lblError.Text    = GetString("settingsedit.settingskey_edit.errordelete");
                lblError.Visible = true;
            }
            break;

        case ("moveup"):
            SettingsKeyProvider.MoveSettingsKeyUp(ski.KeyName);
            break;

        case ("movedown"):
            SettingsKeyProvider.MoveSettingsKeyDown(ski.KeyName);
            break;
        }
    }
Пример #11
0
    /// <summary>
    /// Creates new FormFieldInfo from given SettingKeyInfo.
    /// </summary>
    /// <param name="setting">Setting key info.</param>
    private FormFieldInfo CreateFormFieldInfo(SettingsKeyInfo setting)
    {
        var ffi = new FormFieldInfo
        {
            Name      = setting.KeyName,
            DataType  = setting.KeyType,
            FieldType = FormHelper.GetFormFieldDefaultControlType(setting.KeyType, false)
        };

        ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, setting.KeyDisplayName);
        ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, setting.KeyDescription);
        ffi.SetPropertyValue(FormFieldPropertyEnum.ExplanationText, setting.KeyExplanationText);
        ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, setting.KeyDefaultValue);

        return(ffi);
    }
Пример #12
0
    /// <summary>
    /// Gets and updates settings key. Called when the "Get and update key" button is pressed.
    /// Expects the CreateSettingsKey method to be run first.
    /// </summary>
    private bool GetAndUpdateSettingsKey()
    {
        // Get the settings key
        SettingsKeyInfo updateKey = SettingsKeyProvider.GetSettingsKeyInfo("MyNewKey", CMSContext.CurrentSiteID);

        if (updateKey != null)
        {
            // Update the property
            updateKey.KeyDisplayName = updateKey.KeyDisplayName.ToLowerCSafe();

            // Update the settings key
            SettingsKeyProvider.SetValue(updateKey);

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Creates new FormFieldInfo from given SettingKeyInfo.
    /// </summary>
    /// <param name="setting">Setting key info.</param>
    private FormFieldInfo CreateFormFieldInfo(SettingsKeyInfo setting)
    {
        var ffi = new FormFieldInfo
        {
            Name      = setting.KeyName,
            DataType  = setting.KeyType,
            FieldType = FormHelper.GetFormFieldDefaultControlType(setting.KeyType, false)
        };

        ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, setting.KeyDisplayName);
        ffi.SetPropertyValue(FormFieldPropertyEnum.ExplanationText, setting.KeyExplanationText);
        ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, setting.KeyDefaultValue);
        if (!string.IsNullOrEmpty(setting.KeyDescription))
        {
            ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCssClass, "form-group settings-group-inline");
            ffi.SetPropertyValue(FormFieldPropertyEnum.ContentAfter, UIHelper.GetIcon("icon-question-circle", GetString(setting.KeyDescription)).GetRenderedHTML());
        }

        return(ffi);
    }
Пример #14
0
    /// <summary>
    /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object.
    /// </summary>
    /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
    /// <param name="inputControl">Input control associated to the label</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private Label GetLabel(SettingsKeyInfo settingsKey, Control inputControl, int groupNo, int keyNo)
    {
        LocalizedLabel label = new LocalizedLabel
        {
            EnableViewState = false,
            ID           = string.Format(@"lblDispName{0}{1}", groupNo, keyNo),
            CssClass     = "control-label editing-form-label",
            Text         = HTMLHelper.HTMLEncode(settingsKey.KeyDisplayName),
            DisplayColon = true
        };

        if (inputControl != null)
        {
            label.AssociatedControlID = inputControl.ID;
        }

        ScriptHelper.AppendTooltip(label, ResHelper.LocalizeString(settingsKey.KeyDescription), null);

        return(label);
    }
        public void CreateKey(SettingsKey key)
        {
            var groupInfo = GetGroup(key.Group.DisplayName, key.Group.Category.Name);

            var newKey = new SettingsKeyInfo
            {
                KeyDisplayName         = key.KeyDisplayName,
                KeyName                = key.KeyName,
                KeyDescription         = key.KeyDescription,
                KeyType                = key.KeyType,
                KeyValue               = key.KeyDefaultValue,
                KeyCategoryID          = groupInfo.CategoryID,
                KeyDefaultValue        = key.KeyDefaultValue,
                KeyEditingControlPath  = key.KeyEditingControlPath,
                KeyExplanationText     = key.KeyExplanationText,
                KeyFormControlSettings = key.KeyFormControlSettings,
                KeyValidation          = key.KeyValidation
            };

            SettingsKeyInfoProvider.SetSettingsKeyInfo(newKey);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get parameters
        mKeyName = QueryHelper.GetString("keyname", "");
        mParentGroup = QueryHelper.GetString("parentgroup", null);

        skeEditKey.OnSaved += skeEditKey_OnSaved;

        // Set up editing mode
        if (!string.IsNullOrEmpty(mKeyName))
        {
            mEditedKey = SettingsKeyInfoProvider.GetSettingsKeyInfo(mKeyName, 0);

            // Set id of key
            if (mEditedKey != null)
            {
                skeEditKey.SettingsKeyID = mEditedKey.KeyID;
            }
        }
        // Set up creating mode
        else
        {
            if (mParentGroup != null)
            {
                SettingsCategoryInfo parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup);
                if (parentCat != null)
                {
                    skeEditKey.SelectedGroupID = parentCat.CategoryID;
                }
            }
        }

        // Check if there is something right created to edit.
        if (ViewState["newId"] != null)
        {
            skeEditKey.SettingsKeyID = ValidationHelper.GetInteger(ViewState["newId"], 0);
        }

        skeEditKey.ModuleID = mModuleId;
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get parameters
        mKeyName     = QueryHelper.GetString("keyname", "");
        mParentGroup = QueryHelper.GetString("parentgroup", null);

        skeEditKey.OnSaved += skeEditKey_OnSaved;

        // Set up editing mode
        if (!string.IsNullOrEmpty(mKeyName))
        {
            mEditedKey = SettingsKeyInfoProvider.GetSettingsKeyInfo(mKeyName, 0);

            // Set id of key
            if (mEditedKey != null)
            {
                skeEditKey.SettingsKeyID = mEditedKey.KeyID;
            }
        }
        // Set up creating mode
        else
        {
            if (mParentGroup != null)
            {
                SettingsCategoryInfo parentCat = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName(mParentGroup);
                if (parentCat != null)
                {
                    skeEditKey.SelectedGroupID = parentCat.CategoryID;
                }
            }
        }

        // Check if there is something right created to edit.
        if (ViewState["newId"] != null)
        {
            skeEditKey.SettingsKeyID = ValidationHelper.GetInteger(ViewState["newId"], 0);
        }

        skeEditKey.ModuleID = mModuleId;
    }
Пример #18
0
        private void EnableDataProtectionSamples(ISiteInfo site)
        {
            var dataProtectionSamplesEnabledSettingsKey = SettingsKeyInfoProvider.GetSettingsKeyInfo(DATA_PROTECTION_SETTINGS_KEY);

            if (dataProtectionSamplesEnabledSettingsKey?.KeyValue.ToBoolean(false) ?? false)
            {
                return;
            }

            var keyInfo = new SettingsKeyInfo
            {
                KeyName         = DATA_PROTECTION_SETTINGS_KEY,
                KeyDisplayName  = DATA_PROTECTION_SETTINGS_KEY,
                KeyType         = "boolean",
                KeyValue        = "True",
                KeyDefaultValue = "False",
                KeyIsGlobal     = true,
                KeyIsHidden     = true
            };

            SettingsKeyInfoProvider.SetSettingsKeyInfo(keyInfo);
            EnsureTask(site);
        }
Пример #19
0
        private void SettingsKey_InsertUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo Key = (SettingsKeyInfo)e.Object;

            switch (Key.KeyName.ToLower())
            {
            case "cmsdefaultculturecode":
                if (Key.SiteID > 0)
                {
                    string SiteName = DynamicRouteHelper.GetSite(Key.SiteID).SiteName;
                    DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                }
                else
                {
                    foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                    {
                        DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                    }
                }
                break;

            case "generateculturevariationurlslugs":
                if (Key.SiteID > 0)
                {
                    string SiteName = DynamicRouteHelper.GetSite(Key.SiteID).SiteName;
                    DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                }
                else
                {
                    foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                    {
                        DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                    }
                }
                break;
            }
        }
        protected override void OnInit()
        {
            base.OnInit();

            ApplicationEvents.End.Execute += End_Execute;

            if (SettingsHelper.AppSettings[nameof(WebConfigKeys.CMSStorageProviderAssembly)] == "AzureStorageProvider")
            {
                var provider = new StorageProvider("AzureStorageProvider", "AzureStorageProvider", true);
                StorageHelper.MapStoragePath("/", provider);
            }


            if (SettingsKeyInfoProvider.GetSettingsKeyInfo(nameof(SettingsKeys.AzureStorageProviderEnableLogs)) == null)
            {
                var category = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("CMS.Debug.General");
                // settings key does not exist
                var logEnabledKey = new SettingsKeyInfo
                {
                    KeyName         = nameof(SettingsKeys.AzureStorageProviderEnableLogs),
                    KeyDisplayName  = "Azure Storage Provider Enable Logs",
                    KeyDescription  = "Enables logs",
                    KeyType         = "boolean",
                    KeyCategoryID   = category.CategoryID,
                    KeyDefaultValue = "False",
                    KeyIsGlobal     = true,
                    KeyIsCustom     = false,
                    KeyIsHidden     = false
                };
                logEnabledKey.Insert();
            }

            if (ValidationHelper.GetBoolean(SettingsHelper.AppSettings[nameof(WebConfigKeys.AzureStorageProviderInitializeAtAppStart)], false))
            {
                BlobDirectoryCollection.Instance.GetOrCreate(string.Empty).Reinitialize();
            }
        }
    /// <summary>
    /// Updates settings key for all sites (or only global if the IsGlobal checkbox is checked).
    /// </summary>
    /// <returns>CodeName of the SettingsKey objects.</returns>
    private int UpdateKey()
    {
        // Try to get the key
        var keyObj = (SettingsKeyID > 0) ? SettingsKeyInfoProvider.GetSettingsKeyInfo(SettingsKeyID) : null;
        if (keyObj == null)
        {
            // Create new
            keyObj = new SettingsKeyInfo();
        }

        var oldKeyCategoryID = keyObj.KeyCategoryID;
        bool keyTypeChanged = (keyObj.KeyType != drpKeyType.SelectedValue);

        // Set values
        keyObj.KeyName = txtKeyName.Text.Trim();
        keyObj.KeyDisplayName = txtKeyDisplayName.Text.Trim();
        keyObj.KeyDescription = txtKeyDescription.Text.Trim();
        keyObj.KeyExplanationText = txtKeyExplanationText.Text.Trim();
        keyObj.KeyCategoryID = SelectedGroupID >= 0 ? SelectedGroupID : drpCategory.SelectedCategory;
        keyObj.KeyIsGlobal = chkKeyIsGlobal.Checked;
        keyObj.KeyIsHidden = chkKeyIsHidden.Checked;
        keyObj.KeyType = drpKeyType.SelectedValue;
        keyObj.KeyValidation = (string.IsNullOrEmpty(txtKeyValidation.Text.Trim()) ? null : txtKeyValidation.Text.Trim());
        keyObj.KeyDefaultValue = (string.IsNullOrEmpty(DefaultValue) ? null : DefaultValue);

        var path = ValidationHelper.GetString(ucSettingsKeyControlSelector.ControlPath, string.Empty);
        keyObj.KeyEditingControlPath = (string.IsNullOrEmpty(path.Trim()) ? null : path.Trim());

        // Update form control settings
        if (ucSettingsKeyControlSelector.IsFormControlSelected)
        {
            var formFieldInfo = new FormFieldInfo();
            ucControlSettings.SaveData();

            formFieldInfo.SettingsMacroTable = ucControlSettings.MacroTable;

            if ((ucControlSettings.FormData != null) && (ucControlSettings.FormData.ItemArray.Length > 0))
            {
                foreach (DataColumn column in ucControlSettings.FormData.Table.Columns)
                {
                    formFieldInfo.Settings[column.ColumnName] = ucControlSettings.FormData.Table.Rows[0][column.Caption];
                }
            }

            var settings = FormHelper.GetFormControlSettingsXml(formFieldInfo);
            keyObj.KeyFormControlSettings = settings;
        }
        else
        {
            keyObj.KeyFormControlSettings = null;
        }

        if (drpGeneration.Value >= 0)
        {
            keyObj.KeyLoadGeneration = drpGeneration.Value;
        }

        if (keyObj.KeyID == 0)
        {
            keyObj.KeyValue = DefaultValue;
        }

        if (chkKeyIsGlobal.Checked)
        {
            keyObj.SiteID = 0;
        }

        // If category changed set new order or if new set on the end of key list
        if (keyObj.KeyCategoryID != oldKeyCategoryID)
        {
            var keys = SettingsKeyInfoProvider.GetSettingsKeys(keyObj.KeyCategoryID)
                .OrderByDescending("KeyOrder")
                .Column("KeyOrder");

            keyObj.KeyOrder = keys.GetScalarResult(0) + 1;
        }

        SettingsKeyInfoProvider.SetSettingsKeyInfo(keyObj);

        if (keyTypeChanged)
        {
            UpdateKeyValuesAfterTypeChanged(keyObj);
        }

        // Update property
        mSettingsKeyObj = keyObj;

        return keyObj.KeyID;
    }
Пример #22
0
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return(null);
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl           = FormUserControlInfoProvider.GetFormUserControlInfo(key.KeyEditingControlPath);

        if (formUserControl != null)
        {
            var fileName       = "";
            var formProperties = "";

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    fileName       = parentFormUserControl.UserControlFileName;
                    formProperties = formUserControl.UserControlMergedParameters;
                }
            }
            else
            {
                // Current user control info
                fileName       = formUserControl.UserControlFileName;
                formProperties = formUserControl.UserControlParameters;
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(fileName) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(formUserControl.UserControlCodeName, formProperties, true);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(key.KeyEditingControlPath) as FormEngineUserControl;
            }
            catch
            {
            }
        }

        if (control == null)
        {
            return(null);
        }

        control.ID         = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return(control);
        }

        // Set properties to the specific controls
        switch (key.KeyEditingControlPath.ToLowerCSafe())
        {
        // Class names selectors
        case "~/cmsformcontrols/classes/selectclassnames.ascx":
            control.SetValue("SiteID", 0);
            break;
        }

        return(control);
    }
Пример #23
0
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        string controlNameOrPath = key.KeyEditingControlPath;

        if (string.IsNullOrEmpty(controlNameOrPath))
        {
            return(null);
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl           = FormUserControlInfoProvider.GetFormUserControlInfo(controlNameOrPath);

        if (formUserControl != null)
        {
            var formProperties = formUserControl.UserControlMergedParameters;

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    formUserControl = parentFormUserControl;
                }
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(FormUserControlInfoProvider.GetFormUserControlUrl(formUserControl)) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(controlNameOrPath, formProperties, false);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(controlNameOrPath) as FormEngineUserControl;
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("Settings", "LoadControl", ex);
            }
        }

        if (control == null)
        {
            return(null);
        }

        control.ID         = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        return(control);
    }
    /// <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));
    }
    /// <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();

                // Show the info message
                ShowChangesSaved();

                // 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;

                        // Prepare script for refreshing header
                        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
            {
                ShowError(GetString("general.codenameexists"));
            }
        }
    }
Пример #26
0
    /// <summary>
    /// Gets and bulk updates settings keys. Called when the "Get and bulk update keys" button is pressed.
    /// Expects the CreateSettingsKey method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSettingsKeys()
    {
        // Prepare the parameters
        string where = "KeyName LIKE N'MyNew%'";

        // Get the data
        DataSet keys = SettingsKeyProvider.GetSettingsKeys(where, null, 0, null);
        if (!DataHelper.DataSourceIsEmpty(keys))
        {
            // Loop through the individual items
            foreach (DataRow keyDr in keys.Tables[0].Rows)
            {
                // Create object from DataRow
                SettingsKeyInfo modifyKey = new SettingsKeyInfo(keyDr);

                // Update the property
                modifyKey.KeyDisplayName = modifyKey.KeyDisplayName.ToUpper();

                // Update the settings key
                SettingsKeyProvider.SetValue(modifyKey);
            }

            return true;
        }

        return false;
    }
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="settingsKey">SettingsKeyInfo instance</param>
    /// <param name="groupNo">Number representing index of the proccesing settings group</param>
    /// <param name="keyNo">Number representing index of the proccesing SettingsKeyInfo</param>
    /// <returns><c>CheckBox</c> object.</returns>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo settingsKey, int groupNo, int keyNo)
    {
        FormEngineUserControl control = null;
        if (!string.IsNullOrEmpty(settingsKey.KeyEditingControlPath))
        {
            // Try to get form control by its name
            FormUserControlInfo formcontrol = FormUserControlInfoProvider.GetFormUserControlInfo(settingsKey.KeyEditingControlPath);
            if (formcontrol != null)
            {
                string fileName = "";
                string formProperties = "";

                if (formcontrol.UserControlParentID > 0)
                {
                    // Get parent user control
                    FormUserControlInfo fuci = FormUserControlInfoProvider.GetFormUserControlInfo(formcontrol.UserControlParentID);
                    if (fuci != null)
                    {
                        fileName = fuci.UserControlFileName;
                        formProperties = formcontrol.MergedFormInfo;
                    }
                }
                else
                {
                    // Current user control info
                    fileName = formcontrol.UserControlFileName;
                    formProperties = formcontrol.UserControlParameters;
                }

                // Create FormInfo and load control
                FormInfo fi = FormHelper.GetFormControlParameters(formcontrol.UserControlCodeName, formProperties, true);
                control = Page.LoadUserControl(fileName) as FormEngineUserControl;
                control.LoadDefaultProperties(fi);
            }
            else
            {
                // Load the control path
                try
                {
                    control = Page.LoadUserControl(settingsKey.KeyEditingControlPath) as FormEngineUserControl;
                }
                catch
                {
                }
            }
        }

        // Handling exceptions
        if (control != null)
        {
            control.ID = string.Format(@"key{0}{1}", groupNo, keyNo);
            control.IsLiveSite = false;

            // Store value of editing control path
            string editingCtrlPath = null;
            if (!String.IsNullOrEmpty(settingsKey.KeyEditingControlPath))
            {
                editingCtrlPath = settingsKey.KeyEditingControlPath.ToLowerCSafe();
            }

            // Apply additional styles or set properties to the specific controls
            switch (editingCtrlPath)
            {
                case "~/cmsmodules/ecommerce/formcontrols/checkoutprocess.ascx":
                    SetStyle(control, "pnlContent", "panel", "padding:0px 0px 0px 0px");
                    SetStyle(control, "pnlHeaderLine", "panel", "padding:0px 0px 0px 0px;border-bottom:0px solid #CCCCCC;background-color:transparent");
                    SetStyle(control, "Panel2", "panel", "padding:0px 0px 0px 0px");
                    SetStyle(control, "plcEditDiv", "htmlcontrol", "padding:0px 0px 0px 0px;border-bottom:0px solid #CCCCCC;background-color:transparent");

                    HelpControl helpElem = control.FindControl("helpElem") as HelpControl;
                    if (helpElem != null)
                    {
                        HyperLink lnkHelp = helpElem.FindControl("lnkHelp") as HyperLink;
                        if (lnkHelp != null)
                        {
                            lnkHelp.Style["display"] = "none";
                        }
                    }
                    break;
                // Class names selectors
                case "~/cmsformcontrols/classes/selectclassnames.ascx":
                    control.SetValue("SiteID", 0);
                    break;
            }
        }
        return control;
    }
 /// <summary>
 /// Updates key values to default after type change.
 /// </summary>
 /// <param name="keyObj">Global key that changed</param>
 private void UpdateKeyValuesAfterTypeChanged(SettingsKeyInfo keyObj)
 {
     // Loop through all the keys (site and global) and set the value to the selected default one
     foreach (var settingKey in SettingsKeyInfoProvider.GetSettingsKeys().WhereEquals("KeyName", keyObj.KeyName))
     {
         settingKey.KeyValue = keyObj.KeyDefaultValue;
         SettingsKeyInfoProvider.SetSettingsKeyInfo(settingKey);
     }
 }
    /// <summary>
    /// Gets <c>CheckBox</c> control used for key value editing.
    /// </summary>
    /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance representing the current processing key</param>
    /// <param name="groupNo">Number representing index of the proccesing settings group</param>
    /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
    /// <param name="inheritChecked">Output parameter indicating whether the inherit <c>CheckBox</c> should be checked</param>
    /// <param name="chkInherit">Inherit <c>CheckBox</c> instance</param>
    /// <param name="inputControlID">Output parameter representing the ID of the edit control</param>
    /// <param name="value">Output parameter representing the value of the edit control</param>
    /// <returns><c>CheckBox</c> object.</returns>
    private CheckBox GetCheckBox(SettingsKeyInfo settingsKey, int groupNo, int keyNo, out bool inheritChecked, CheckBox chkInherit, out string inputControlID, out string value)
    {
        CheckBox chbox = new CheckBox();
        chbox.ID = string.Format("chkKey{0}{1}", groupNo, keyNo);
        chbox.EnableViewState = false;
        if (string.IsNullOrEmpty(settingsKey.KeyValue) && (mSiteId > 0))
        {
            inheritChecked = true;
            chbox.Checked = SettingsKeyProvider.GetBoolValue(settingsKey.KeyName.ToLower());
        }
        else
        {
            inheritChecked = false;
            chbox.Checked = SettingsKeyProvider.GetBoolValue(GetFullKeyName(settingsKey.KeyName).ToLower());
        }

        // Disable checkbox if inheriting from global settings
        if ((URLHelper.IsPostback() && (chkInherit != null)) ? (Request.Form[chkInherit.UniqueID] == null) : !inheritChecked)
        {
            chbox.InputAttributes.Remove("disabled");
        }
        else
        {
            chbox.InputAttributes.Add("disabled", "disabled");
        }

        inputControlID = chbox.ID;
        value = chbox.Checked.ToString();
        return chbox;
    }
    /// <summary>
    /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object.
    /// </summary>
    /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
    /// <param name="inputControl">Input control associated to the label</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private Label GetLabel(SettingsKeyInfo settingsKey, Control inputControl, int groupNo, int keyNo)
    {
        LocalizedLabel label = new LocalizedLabel
        {
            EnableViewState = false,
            ID = string.Format(@"lblDispName{0}{1}", groupNo, keyNo),
            CssClass = "control-label editing-form-label",
            Text = settingsKey.KeyDisplayName,
            DisplayColon = true
        };
        if (inputControl != null)
        {
            label.AssociatedControlID = inputControl.ID;
        }

        ScriptHelper.AppendTooltip(label, ResHelper.LocalizeString(settingsKey.KeyDescription), null);

        return label;
    }
        private void SettingsKey_InsertUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo Key = (SettingsKeyInfo)e.Object;

            switch (Key.KeyName.ToLower())
            {
            case "cmsdefaultculturecode":
                try
                {
                    if (Key.SiteID > 0)
                    {
                        string SiteName = DynamicRouteInternalHelper.GetSite(Key.SiteID).SiteName;
                        DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                    }
                    else
                    {
                        foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                        {
                            DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                        }
                    }
                }
                catch (UrlSlugCollisionException ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                    e.Cancel();
                }
                catch (Exception ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                }
                break;

            case "generateculturevariationurlslugs":
                try
                {
                    if (Key.SiteID > 0)
                    {
                        string SiteName = DynamicRouteInternalHelper.GetSite(Key.SiteID).SiteName;
                        DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                    }
                    else
                    {
                        foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                        {
                            DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                        }
                    }
                }
                catch (UrlSlugCollisionException ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                    e.Cancel();
                }
                catch (Exception ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                }
                break;
            }
        }
    /// <summary>
    /// Creates settings key. Called when the "Create key" button is pressed.
    /// </summary>
    private bool CreateSettingsKey()
    {
        // Get the settings group
        SettingsCategoryInfo settingsGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsGroup");
        if (settingsGroup != null)
        {
            // Create new settings key object
            SettingsKeyInfo newKey = new SettingsKeyInfo();

            // Set the properties
            newKey.KeyDisplayName = "My new key";
            newKey.KeyName = "MyNewKey";
            newKey.KeyDescription = "My new key description";
            newKey.KeyType = "string";
            newKey.KeyValue = "My new value";
            newKey.KeyCategoryID = settingsGroup.CategoryID;
            newKey.KeyDefaultValue = null;

            // Set Site ID for site specific settings key (for global settings key is default value 0).
            newKey.SiteID = SiteContext.CurrentSiteID;

            // Create the settings key
            SettingsKeyInfoProvider.SetSettingsKeyInfo(newKey);

            return true;
        }

        return false;
    }
    /// <summary>
    /// Gets <c>FormEngineUserControl</c> instance for the input <c>SettingsKeyInfo</c> object.
    /// </summary>
    /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
    /// <param name="groupNo">Number representing index of the proccesing settings group</param>
    /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
    /// <returns><c>CheckBox</c> object.</returns>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo settingsKey, int groupNo, int keyNo)
    {
        FormEngineUserControl control = null;
        if (!string.IsNullOrEmpty(settingsKey.KeyEditingControlPath))
        {
            try
            {
                control = Page.LoadControl(settingsKey.KeyEditingControlPath) as FormEngineUserControl;
            }
            catch
            {
            }
        }

        // Handling exceptions
        if (control != null)
        {
            control.ID = string.Format(@"key{0}{1}", groupNo, keyNo);
            control.IsLiveSite = false;

            // Store value of editing control path
            string editingCtrlPath = null;
            if (!String.IsNullOrEmpty(settingsKey.KeyEditingControlPath))
            {
                editingCtrlPath = settingsKey.KeyEditingControlPath.ToLower();
            }

            // Apply additional styles or set properties to the specific controls
            switch (editingCtrlPath)
            {
                case "~/cmsmodules/ecommerce/formcontrols/checkoutprocess.ascx":
                    SetStyle(control, "pnlContent", "panel", "padding:0px 0px 0px 0px");
                    SetStyle(control, "pnlHeaderLine", "panel", "padding:0px 0px 0px 0px;border-bottom:0px solid #CCCCCC;background-color:transparent");
                    SetStyle(control, "Panel2", "panel", "padding:0px 0px 0px 0px");
                    SetStyle(control, "plcEditDiv", "htmlcontrol", "padding:0px 0px 0px 0px;border-bottom:0px solid #CCCCCC;background-color:transparent");

                    HelpControl helpElem = control.FindControl("helpElem") as HelpControl;
                    if (helpElem != null)
                    {
                        HyperLink lnkHelp = helpElem.FindControl("lnkHelp") as HyperLink;
                        if (lnkHelp != null)
                        {
                            lnkHelp.Style["display"] = "none";
                        }
                    }
                    break;
                // Class names selectors
                case "~/cmsformcontrols/classes/selectclassnames.ascx":
                    control.SetValue("SiteID", 0);
                    break;
            }
        }
        return control;
    }
Пример #34
0
    /// <summary>
    /// Updates settings key for all sites (or only global if the IsGlobal checkbox is checked).
    /// </summary>
    /// <returns>CodeName of the SettingsKey objects.</returns>
    private int UpdateKey()
    {
        // Try to get the key
        var keyObj = (mSettingsKeyId > 0) ? SettingsKeyInfoProvider.GetSettingsKeyInfo(mSettingsKeyId) : null;

        if (keyObj == null)
        {
            // Create new
            keyObj = new SettingsKeyInfo();
        }

        var oldKeyCategoryID = keyObj.KeyCategoryID;

        // Set values
        keyObj.KeyName         = txtKeyName.Text.Trim();
        keyObj.KeyDisplayName  = txtKeyDisplayName.Text.Trim();
        keyObj.KeyDescription  = txtKeyDescription.Text.Trim();
        keyObj.KeyType         = drpKeyType.SelectedValue;
        keyObj.KeyCategoryID   = mSelectedGroupId >= 0 ? mSelectedGroupId : drpCategory.SelectedCategory;
        keyObj.KeyIsGlobal     = chkKeyIsGlobal.Checked;
        keyObj.KeyIsHidden     = chkKeyIsHidden.Checked;
        keyObj.KeyValidation   = (string.IsNullOrEmpty(txtKeyValidation.Text.Trim()) ? null : txtKeyValidation.Text.Trim());
        keyObj.KeyDefaultValue = (string.IsNullOrEmpty(DefaultValue) ? null : DefaultValue);

        var path = ValidationHelper.GetString(ucSettingsKeyControlSelector.ControlPath, string.Empty);

        keyObj.KeyEditingControlPath = (string.IsNullOrEmpty(path.Trim()) ? null : path.Trim());

        // Update form control settings
        if (ucSettingsKeyControlSelector.IsFormControlSelected)
        {
            var formFieldInfo = new FormFieldInfo();
            ucControlSettings.SaveData();

            formFieldInfo.SettingsMacroTable = ucControlSettings.MacroTable;

            if ((ucControlSettings.FormData != null) && (ucControlSettings.FormData.ItemArray.Length > 0))
            {
                foreach (DataColumn column in ucControlSettings.FormData.Table.Columns)
                {
                    formFieldInfo.Settings[column.ColumnName] = ucControlSettings.FormData.Table.Rows[0][column.Caption];
                }
            }

            var settings = FormHelper.GetFormControlSettingsXml(formFieldInfo);
            keyObj.KeyFormControlSettings = settings;
        }
        else
        {
            keyObj.KeyFormControlSettings = null;
        }

        if (drpGeneration.Value >= 0)
        {
            keyObj.KeyLoadGeneration = drpGeneration.Value;
        }

        if (keyObj.KeyID == 0)
        {
            keyObj.KeyValue = DefaultValue;
        }

        if (chkKeyIsGlobal.Checked)
        {
            keyObj.SiteID = 0;
        }

        // If category changed set new order or if new set on the end of key list
        if (keyObj.KeyCategoryID != oldKeyCategoryID)
        {
            var keys = SettingsKeyInfoProvider.GetSettingsKeys(keyObj.KeyCategoryID)
                       .OrderByDescending("KeyOrder")
                       .Column("KeyOrder");

            keyObj.KeyOrder = keys.GetScalarResult(0) + 1;
        }

        SettingsKeyInfoProvider.SetSettingsKeyInfo(keyObj);

        // Update property
        mSettingsKeyObj = keyObj;

        return(keyObj.KeyID);
    }
    /// <summary>
    /// Creates new FormFieldInfo from given SettingKeyInfo.
    /// </summary>
    /// <param name="setting">Setting key info.</param>
    private FormFieldInfo CreateFormFieldInfo(SettingsKeyInfo setting)
    {
        var ffi = new FormFieldInfo
        {
            Name = setting.KeyName,
            DataType = setting.KeyType,
            FieldType = FormHelper.GetFormFieldDefaultControlType(setting.KeyType, false)
        };

        ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, setting.KeyDisplayName);
        ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, setting.KeyDescription);
        ffi.SetPropertyValue(FormFieldPropertyEnum.ExplanationText, setting.KeyExplanationText);
        ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, setting.KeyDefaultValue);

        return ffi;
    }
    /// <summary>
    /// Updates settings key for all sites (or only global if the IsGlobal checkbox is checked).
    /// </summary>
    /// <param name="siteKeyName">CodeName of the SettingsKey for the site</param>
    /// <param name="keyObj">Instance of the SettingsKey object</param>
    /// <param name="putNullValues">If set to <c>true</c> null value will be set as KeyValue</param>
    /// <returns>CodeName of the SettingsKey objects.</returns>
    private string UpdateAllSitesKey(string siteKeyName, SettingsKeyInfo keyObj, bool putNullValues)
    {
        int oldKeyCategoryID = keyObj.KeyCategoryID;

        keyObj.KeyName = txtKeyName.Text.Trim();
        keyObj.KeyDisplayName = txtKeyDisplayName.Text.Trim();
        keyObj.KeyDescription = txtKeyDescription.Text.Trim();
        keyObj.KeyType = drpKeyType.SelectedValue;
        keyObj.KeyCategoryID = mSelectedGroupId >= 0 ? mSelectedGroupId : drpCategory.SelectedCategory;
        keyObj.KeyIsGlobal = chkKeyIsGlobal.Checked;
        keyObj.KeyIsHidden = chkKeyIsHidden.Checked;
        keyObj.KeyIsCustom = mIsCustomSetting;
        if (putNullValues)
        {
            keyObj.KeyValue = DefaultValue;
        }
        keyObj.KeyValidation = (string.IsNullOrEmpty(txtKeyValidation.Text.Trim()) ? null : txtKeyValidation.Text.Trim());
        keyObj.KeyDefaultValue = (string.IsNullOrEmpty(DefaultValue) ? null : DefaultValue);

        string path = ValidationHelper.GetString(settingKeyControlSelector.ControlPath, string.Empty);
        keyObj.KeyEditingControlPath = (string.IsNullOrEmpty(path.Trim()) ? null : path.Trim());

        if (drpGeneration.Value >= 0)
        {
            keyObj.KeyLoadGeneration = drpGeneration.Value;
        }
        // Update information on setting key concerning application level
        if (chkKeyIsGlobal.Checked)
        {
            keyObj.SiteID = 0;
        }

        // If category changed set new order or if new set on the end of key list
        if (keyObj.KeyCategoryID != oldKeyCategoryID)
        {
            DataSet ds = SettingsKeyProvider.GetSettingsKeys(0, keyObj.KeyCategoryID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataTable keyTable = ds.Tables[0];
                keyTable.DefaultView.Sort = "KeyOrder DESC";
                keyTable = keyTable.DefaultView.ToTable();

                // Set new KeyOrder as last setings key
                keyObj.KeyOrder = ValidationHelper.GetInteger(keyTable.Rows[0]["KeyOrder"], 0) + 1;
            }
            else
            {
                // Move into empty category
                keyObj.KeyOrder = 1;
            }
        }
        SettingsKeyProvider.SetValue(keyObj);

        // Update all sites keys
        DataSet sites = SiteInfoProvider.GetSites(null, null, "SiteID");
        foreach (DataRow dr in sites.Tables[0].Rows)
        {
            int siteId = ValidationHelper.GetInteger(dr["SiteID"], 0);

            // Get site specific key information
            SettingsKeyInfo keySite = SettingsKeyProvider.GetSettingsKeyInfo(siteKeyName, siteId);
            if ((keySite == null) && (!keyObj.KeyIsGlobal))
            {
                keySite = new SettingsKeyInfo();
                // Default value for new key for site-specific setting is to inherit from global
                keySite.KeyDefaultValue = null;
            }

            if (!keyObj.KeyIsGlobal && (keySite != null))
            {
                keySite.KeyName = txtKeyName.Text;
                keySite.KeyDisplayName = txtKeyDisplayName.Text;
                keySite.KeyDescription = txtKeyDescription.Text;
                keySite.KeyValidation = txtKeyValidation.Text;
                keySite.KeyCategoryID = keyObj.KeyCategoryID;
                keySite.SiteID = siteId;
                keySite.KeyOrder = keyObj.KeyOrder;
                keySite.KeyType = drpKeyType.SelectedValue;
                keySite.KeyEditingControlPath = keyObj.KeyEditingControlPath;
                keySite.KeyIsHidden = chkKeyIsHidden.Checked;
                keySite.KeyIsCustom = mIsCustomSetting;

                if (drpGeneration.Value >= 0)
                {
                    keySite.KeyLoadGeneration = drpGeneration.Value;
                }
                if (putNullValues)
                {
                    keySite.KeyValue = null;
                }
                SettingsKeyProvider.SetValue(keySite);
            }
            else
            {
                // Remove the site specific key as setting key isn't local any more
                SettingsKeyProvider.DeleteKey(keySite);
            }
        }
        return keyObj.KeyName;
    }
Пример #37
0
    /// <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");
            }
        }
    }
 /// <summary>
 /// Gets <c>Image</c> instance for the input <c>SettingsKeyInfo</c> object.
 /// </summary>
 /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
 /// <param name="groupNo">Number representing index of the proccesing settings group</param>
 /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
 /// <returns><c>Image</c> object.</returns>
 private Image GetHelpImage(SettingsKeyInfo settingsKey, int groupNo, int keyNo)
 {
     Image i = new Image();
     i.EnableViewState = false;
     i.ID = string.Format(@"imgHelp{0}{1}", groupNo, keyNo);
     i.ImageUrl = GetImageUrl("CMSModules/CMS_Settings/help.png");
     ScriptHelper.AppendTooltip(i, ResHelper.LocalizeString(settingsKey.KeyDescription), null);
     return i;
 }
Пример #39
0
    /// <summary>
    /// Updates settings key for all sites (or only global if the IsGlobal checkbox is checked).
    /// </summary>
    /// <param name="siteKeyName">CodeName of the SettingsKey for the site</param>
    /// <param name="keyObj">Instance of the SettingsKey object</param>
    /// <param name="putNullValues">If set to <c>true</c> null value will be set as KeyValue</param>
    /// <returns>CodeName of the SettingsKey objects.</returns>
    private string UpdateAllSitesKey(string siteKeyName, SettingsKeyInfo keyObj, bool putNullValues)
    {
        int oldKeyCategoryID = keyObj.KeyCategoryID;

        keyObj.KeyName        = txtKeyName.Text.Trim();
        keyObj.KeyDisplayName = txtKeyDisplayName.Text.Trim();
        keyObj.KeyDescription = txtKeyDescription.Text.Trim();
        keyObj.KeyType        = drpKeyType.SelectedValue;
        keyObj.KeyCategoryID  = mSelectedGroupId >= 0 ? mSelectedGroupId : drpCategory.SelectedCategory;
        keyObj.KeyIsGlobal    = chkKeyIsGlobal.Checked;
        keyObj.KeyIsHidden    = chkKeyIsHidden.Checked;
        keyObj.KeyIsCustom    = mIsCustomSetting;
        if (putNullValues)
        {
            keyObj.KeyValue = DefaultValue;
        }
        keyObj.KeyValidation         = (string.IsNullOrEmpty(txtKeyValidation.Text.Trim()) ? null : txtKeyValidation.Text.Trim());
        keyObj.KeyDefaultValue       = (string.IsNullOrEmpty(DefaultValue) ? null : DefaultValue);
        keyObj.KeyEditingControlPath = (string.IsNullOrEmpty(txtFormControl.Text.Trim()) ? null : txtFormControl.Text.Trim());
        if (drpGeneration.Value >= 0)
        {
            keyObj.KeyLoadGeneration = drpGeneration.Value;
        }
        // Update information on setting key concerning application level
        if (chkKeyIsGlobal.Checked)
        {
            keyObj.SiteID = 0;
        }

        // If category changed set new order or if new set on the end of key list
        if (keyObj.KeyCategoryID != oldKeyCategoryID)
        {
            DataSet ds = SettingsKeyProvider.GetSettingsKeys(0, keyObj.KeyCategoryID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataTable keyTable = ds.Tables[0];
                keyTable.DefaultView.Sort = "KeyOrder DESC";
                keyTable = keyTable.DefaultView.ToTable();

                // Set new KeyOrder as last setings key
                keyObj.KeyOrder = ValidationHelper.GetInteger(keyTable.Rows[0]["KeyOrder"], 0) + 1;
            }
            else
            {
                // Move into empty category
                keyObj.KeyOrder = 1;
            }
        }
        SettingsKeyProvider.SetValue(keyObj);

        // Update all sites keys
        DataSet sites = SiteInfoProvider.GetSites(null, null, "SiteID");

        foreach (DataRow dr in sites.Tables[0].Rows)
        {
            int siteId = ValidationHelper.GetInteger(dr["SiteID"], 0);

            // Get site specific key information
            SettingsKeyInfo keySite = SettingsKeyProvider.GetSettingsKeyInfo(siteKeyName, siteId);
            if ((keySite == null) && (!keyObj.KeyIsGlobal))
            {
                keySite = new SettingsKeyInfo();
                // Default value for new key for site-specific setting is to inherit from global
                keySite.KeyDefaultValue = null;
            }

            if (!keyObj.KeyIsGlobal && (keySite != null))
            {
                keySite.KeyName               = txtKeyName.Text;
                keySite.KeyDisplayName        = txtKeyDisplayName.Text;
                keySite.KeyDescription        = txtKeyDescription.Text;
                keySite.KeyValidation         = txtKeyValidation.Text;
                keySite.KeyCategoryID         = keyObj.KeyCategoryID;
                keySite.SiteID                = siteId;
                keySite.KeyOrder              = keyObj.KeyOrder;
                keySite.KeyType               = drpKeyType.SelectedValue;
                keySite.KeyEditingControlPath = keyObj.KeyEditingControlPath;
                keySite.KeyIsHidden           = chkKeyIsHidden.Checked;
                keySite.KeyIsCustom           = mIsCustomSetting;

                if (drpGeneration.Value >= 0)
                {
                    keySite.KeyLoadGeneration = drpGeneration.Value;
                }
                if (putNullValues)
                {
                    keySite.KeyValue = null;
                }
                SettingsKeyProvider.SetValue(keySite);
            }
            else
            {
                // Remove the site specific key as setting key isn't local any more
                SettingsKeyProvider.DeleteKey(keySite);
            }
        }
        return(keyObj.KeyName);
    }
Пример #40
0
 /// <summary>
 /// Generate info text for given setting key
 /// </summary>
 /// <param name="ski">Setting key object</param>
 private String GenerateInfoText(SettingsKeyInfo ski)
 {
     return(String.Format(GetString(InfoTextResourceString), ResHelper.GetString(ski.KeyDisplayName)));
 }
 /// <summary>
 /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object.
 /// </summary>
 /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
 /// <param name="groupNo">Number representing index of the proccesing settings group</param>
 /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
 /// <returns><c>Label</c> object.</returns>
 private Label GetLabel(SettingsKeyInfo settingsKey, int groupNo, int keyNo)
 {
     Label l = new Label();
     l.EnableViewState = false;
     l.ID = string.Format(@"lblDispName{0}{1}", groupNo, keyNo);
     l.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(settingsKey.KeyDisplayName));
     l.Attributes.Add("style", "cursor: help;");
     ScriptHelper.AppendTooltip(l, ResHelper.LocalizeString(settingsKey.KeyDescription), null);
     return l;
 }
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        string controlNameOrPath = key.KeyEditingControlPath;
        if (string.IsNullOrEmpty(controlNameOrPath))
        {
            return null;
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(controlNameOrPath);
        if (formUserControl != null)
        {
            var formProperties = formUserControl.UserControlMergedParameters;

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    formUserControl = parentFormUserControl;
                }
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(FormUserControlInfoProvider.GetFormUserControlUrl(formUserControl)) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(controlNameOrPath, formProperties, false);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(controlNameOrPath) as FormEngineUserControl;
            }
            catch(Exception ex)
            {
                EventLogProvider.LogException("Settings", "LoadControl", ex);
            }
        }

        if (control == null)
        {
            return null;
        }

        control.ID = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        return control;
    }
 /// <summary>
 /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object.
 /// </summary>
 /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param>
 /// <param name="groupNo">Number representing index of the proccesing settings group</param>
 /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
 /// <returns><c>Label</c> object.</returns>
 private Label GetLabelKeyName(SettingsKeyInfo settingsKey, int groupNo, int keyNo)
 {
     Label l = new Label();
     l.EnableViewState = false;
     l.ID = string.Format(@"lblKeyName{0}{1}", groupNo, keyNo);
     l.Text = settingsKey.KeyName;
     l.Visible = false;
     return l;
 }
    /// <summary>
    /// Displays info label, if any module is disabled
    /// </summary>
    private bool DisplayErrorText()
    {
        GlobalObjects = ";" + GlobalObjects + ";";
        SiteObjects   = ";" + SiteObjects + ";";
        String invalidKeys    = String.Empty;
        bool   keyDisabled    = false;
        bool   isAnyKeySite   = false;
        bool   settingChecked = false;
        bool   showSite       = false;
        bool   showGlobal     = false;

        if (!String.IsNullOrEmpty(SettingsKeys))
        {
            // Iterate through all settings keys
            int i = 0;
            foreach (String key in SettingsKeys.Split(';'))
            {
                if (key != String.Empty)
                {
                    String objectKey    = ";" + key + ";";
                    bool   globalObject = GlobalObjects.Contains(objectKey);
                    bool   siteObject   = SiteObjects.Contains(objectKey);
                    String siteKeyName  = SiteName + "." + key;
                    String keyName      = (SiteOrGlobal || globalObject || KeyScope == DisabledModuleScope.Global) ? key : siteKeyName;

                    // If module disabled
                    if (!SettingsKeyProvider.GetBoolValue(keyName) || (siteObject && !SettingsKeyProvider.GetBoolValue(siteKeyName)))
                    {
                        // For siteorglobal settings check site setting separately
                        if (SiteOrGlobal && SettingsKeyProvider.GetBoolValue(siteKeyName))
                        {
                            settingChecked = true;
                            i++;
                            continue;
                        }

                        // If atleastone is checked, info error is set later
                        if (!AtLeastOne)
                        {
                            // If setting is global - hide site button
                            SettingsKeyInfo ski = SettingsKeyProvider.GetSettingsKeyInfo(key);
                            if ((ski != null) && (!ski.KeyIsGlobal))
                            {
                                isAnyKeySite = true;
                            }

                            // Get text (either from collection of text or from single text property)
                            String text = (InfoTexts.Count != 0 && InfoTexts.Count > i) ? InfoTexts[i] : InfoText;

                            // Add new text to label
                            lblText.Text += text;

                            // Add this key to collection of disabled keys
                            invalidKeys = key + ";";

                            // Make this info label visible
                            keyDisabled = true;

                            if (!siteObject && !globalObject)
                            {
                                showSite   = (KeyScope != DisabledModuleScope.Global);
                                showGlobal = (KeyScope != DisabledModuleScope.Site);
                            }
                            else
                            {
                                showSite   |= siteObject;
                                showGlobal |= globalObject;
                            }
                        }
                    }
                    else
                    {
                        settingChecked = true;
                    }
                }
                i++;
            }
        }

        // If atleastone is set, check if any setting is checked. If no, display warning message
        if (AtLeastOne && !settingChecked)
        {
            keyDisabled  = true;
            lblText.Text = InfoText;
        }

        // If parent panel is set, show(hide) it
        if (ParentPanel != null)
        {
            ParentPanel.Visible = keyDisabled;
        }

        // Show/hide this control if module disabled
        Visible = keyDisabled;

        // Show site button only if any key is site
        pnlSiteButton.Visible = isAnyKeySite;

        // Set result to property
        SettingsEnabled = !keyDisabled;

        pnlSiteButton.Visible   &= showSite;
        pnlGlobalButton.Visible &= showGlobal;

        return(!keyDisabled);
    }
 /// <summary>
 /// Gets <c>TextBox</c> control used for key value editing.
 /// </summary>
 /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance representing the current processing key</param>
 /// <param name="groupNo">Number representing index of the proccesing settings group</param>
 /// <param name="keyNo">Number representing index of the proccesing <c>SettingsKeyInfo</c></param>
 /// <param name="inheritChecked">Output parameter indicating whether the inherit <c>CheckBox</c> should be checked</param>
 /// <param name="chkInherit">Inherit <c>CheckBox</c> instance</param>
 /// <param name="inputControlID">Output parameter representing the ID of the edit control</param>
 /// <param name="value">Output parameter representing the value of the edit control</param>
 /// <returns><c>TextBox</c> object.</returns>
 private TextBox GetTextBox(SettingsKeyInfo settingsKey, int groupNo, int keyNo, out bool inheritChecked, CheckBox chkInherit, out string inputControlID, out string value)
 {
     TextBox tbox = new TextBox();
     tbox.ID = string.Format("txtKey{0}{1}", groupNo, keyNo);
     tbox.CssClass = "TextBoxField";
     tbox.EnableViewState = false;
     if ((settingsKey.KeyValue == null) && (mSiteId > 0))
     {
         inheritChecked = true;
         tbox.Text = SettingsKeyProvider.GetStringValue(settingsKey.KeyName);
     }
     else
     {
         inheritChecked = false;
         tbox.Text = ((chkInherit != null) && (Request.Form[chkInherit.UniqueID] == null)) ? settingsKey.KeyValue : SettingsKeyProvider.GetStringValue(settingsKey.KeyName);
     }
     tbox.Enabled = (URLHelper.IsPostback() && (chkInherit != null)) ? (Request.Form[chkInherit.UniqueID] == null) : !inheritChecked;
     inputControlID = tbox.ID;
     value = tbox.Text;
     return tbox;
 }
 /// <summary>
 /// Generate info text for given setting key
 /// </summary>
 /// <param name="ski">Setting key object</param>
 private String GenerateInfoText(SettingsKeyInfo ski)
 {
     return String.Format(GetString(InfoTextResourceString), ResHelper.GetString(ski.KeyDisplayName));
 }
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return null;
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(key.KeyEditingControlPath);
        if (formUserControl != null)
        {
            var fileName = "";
            var formProperties = "";

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    fileName = parentFormUserControl.UserControlFileName;
                    formProperties = formUserControl.UserControlMergedParameters;
                }
            }
            else
            {
                // Current user control info
                fileName = formUserControl.UserControlFileName;
                formProperties = formUserControl.UserControlParameters;
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(fileName) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(formUserControl.UserControlCodeName, formProperties, true);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(key.KeyEditingControlPath) as FormEngineUserControl;
            }
            catch
            {
            }
        }

        if (control == null)
        {
            return null;
        }

        control.ID = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return control;
        }

        // Set properties to the specific controls
        switch (key.KeyEditingControlPath.ToLowerCSafe())
        {
            // Class names selectors
            case "~/cmsformcontrols/classes/selectclassnames.ascx":
                control.SetValue("SiteID", 0);
                break;
        }

        return control;
    }