Example #1
0
    /// <summary>
    /// Reloads the data in the control.
    /// </summary>
    protected void ReloadData()
    {
        if (drpField.Items.Count == 0)
        {
            // Load dropdownlist with fields of specified class
            FormInfo fi = FormHelper.GetFormInfo(ClassName, false);
            if (fi != null)
            {
                if (string.Equals(ClassName, "cms.user", StringComparison.InvariantCultureIgnoreCase))
                {
                    // Combine user fields with those of user settings
                    FormInfo coupledInfo = FormHelper.GetFormInfo("cms.usersettings", false);
                    if (coupledInfo != null)
                    {
                        fi.CombineWithForm(coupledInfo, false, null, false);
                    }
                }

                if (FieldDataType == FormFieldDataTypeEnum.Unknown)
                {
                    // Get all form fields
                    drpField.DataSource = fi.GetFields(true, true);
                }
                else
                {
                    // Get form fields of specific data type
                    drpField.DataSource = fi.GetFields(FieldDataType);
                }
                drpField.DataBind();
            }
            // Add '(none)' item
            drpField.Items.Insert(0, new ListItem(GetString("general.selectnone"), string.Empty));
        }
    }
Example #2
0
    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        this.ClassFields.ItemID = this.ItemID;
        this.ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        ArrayList     itemList  = null;
        FormFieldInfo formField = null;

        // Load DataClass
        dci = DataClassInfoProvider.GetDataClass(this.ItemID);

        if (dci != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(dci.ClassName, true);

            if (String.Compare(dci.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClass("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Count > 0)
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (object item in itemList)
            {
                if (item is FormFieldInfo)
                {
                    formField = ((FormFieldInfo)(item));
                    object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        ReloadControls();
    }
Example #3
0
    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        ClassFields.ItemID = ItemID;
        ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        List <IDataDefinitionItem> itemList = null;

        if (ClassInfo != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(ClassInfo.ClassName, true);

            if (CMSString.Compare(ClassInfo.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClassInfo("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Any())
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (var item in itemList)
            {
                var formField = item as FormFieldInfo;
                if (formField != null)
                {
                    object[] obj = { formField.Name, DataTypeManager.GetSystemType(TypeEnum.Field, formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        if (AdvancedMode)
        {
            ReloadControls();
        }
    }
    /// <summary>
    /// Copies custom fields from old version of form definition to the new form definition.
    /// </summary>
    /// <param name="oldVersionFi">Old version form definition</param>
    /// <param name="newVersionFi">New version form definition</param>
    /// <param name="overwrite">Indicates whether existing fields should be overwritten. Alternative form fields need to be overwritten due to the combination with upgraded class form.</param>
    private static void CopyCustomFields(FormInfo oldVersionFi, FormInfo newVersionFi, bool overwrite)
    {
        // Remove all system fields from old definition to get only custom fields
        oldVersionFi.RemoveFields(f => f.System);

        // Combine forms so that custom fields from old definition are appended to the new definition
        newVersionFi.CombineWithForm(oldVersionFi, new CombineWithFormSettings
        {
            IncludeCategories     = false,
            RemoveEmptyCategories = true,
            OverwriteExisting     = overwrite
        });
    }
    /// <summary>
    /// Reloads the data in the control.
    /// </summary>
    protected void ReloadData()
    {
        if (drpField.Items.Count == 0)
        {
            // Load dropdownlist with fields of specified class
            FormInfo fi = FormHelper.GetFormInfo(ClassName, false);
            if (fi != null)
            {
                if (CMSString.Equals(ClassName, "cms.user", true))
                {
                    // Combine user fields with those of user settings
                    FormInfo coupledInfo = FormHelper.GetFormInfo("cms.usersettings", false);
                    if (coupledInfo != null)
                    {
                        fi.CombineWithForm(coupledInfo, false);
                    }
                }

                IEnumerable <FormFieldInfo> fields;
                if (FieldDataType != CMS.DataEngine.FieldDataType.Unknown)
                {
                    fields = fi.GetFields(FieldDataType);
                }
                else
                {
                    fields = fi.GetFields(true, true);
                }

                foreach (var fieldInfo in fields)
                {
                    drpField.Items.Add(new ListItem(fieldInfo.GetDisplayName(MacroResolver.GetInstance()), fieldInfo.Name));
                }
            }

            if (AllowNone)
            {
                // Add '(none)' item
                drpField.Items.Insert(0, new ListItem(GetString("general.selectnone"), string.Empty));
            }
        }
    }
    /// <summary>
    /// Copies custom fields from old version of form definition to the new form definition.
    /// </summary>
    /// <param name="oldVersionFi">Old version form definition</param>
    /// <param name="newVersionFi">New version form definition</param>
    /// <param name="overwrite">Indicates whether existing fields should be overwritten. Alternative form fields need to be overwritten due to the combination with upgraded class form.</param>
    private static void CopyCustomFields(FormInfo oldVersionFi, FormInfo newVersionFi, bool overwrite)
    {
        // Remove all system fields from old definition to get only custom fields
        oldVersionFi.RemoveFields(f => f.System);

        // Combine forms so that custom fields from old definition are appended to the new definition
        newVersionFi.CombineWithForm(oldVersionFi, new CombineWithFormSettings
        {
            IncludeCategories = false,
            RemoveEmptyCategories = true,
            OverwriteExisting = overwrite
        });
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        ClassFields.ItemID = ItemID;
        ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        List<IField> itemList = null;

        if (ClassInfo != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(ClassInfo.ClassName, true);

            if (CMSString.Compare(ClassInfo.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClassInfo("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Any())
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (var item in itemList)
            {
                var formField = item as FormFieldInfo;
                if (formField != null)
                {
                    object[] obj = { formField.Name, DataTypeManager.GetSystemType(TypeEnum.Field, formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        if (AdvancedMode)
        {
            ReloadControls();
        }
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    /// <param name="setAutomatically">Indicates whether search options should be set automatically</param>
    public void ReloadSearch(bool setAutomatically)
    {
        ClassFields.ItemID = ItemID;
        ClassFields.ReloadData(setAutomatically, true);

        // Initialize properties
        List<IFormItem> itemList = null;
        FormFieldInfo formField = null;

        // Load DataClass
        dci = DataClassInfoProvider.GetDataClass(ItemID);

        if (dci != null)
        {
            // Load XML definition
            fi = FormHelper.GetFormInfo(dci.ClassName, true);

            if (CMSString.Compare(dci.ClassName, "cms.user", true) == 0)
            {
                plcImage.Visible = false;
                ClassFields.DisplaySetAutomatically = false;
                pnlIndent.Visible = true;

                document = DataClassInfoProvider.GetDataClass("cms.usersettings");
                if (document != null)
                {
                    FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true);
                    fi.CombineWithForm(fiSettings, true, String.Empty);
                }
            }

            // Get all fields
            itemList = fi.GetFormElements(true, true);
        }

        if (itemList != null)
        {
            if (itemList.Any())
            {
                pnlIndent.Visible = true;
            }

            // Store each field to array
            foreach (object item in itemList)
            {
                if (item is FormFieldInfo)
                {
                    formField = ((FormFieldInfo)(item));
                    object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) };
                    attributes.Add(obj);
                }
            }
        }

        ReloadControls();
    }
    /// <summary>
    /// Copies custom fields from old version of form definition to the new form definition.
    /// </summary>
    /// <param name="oldVersionFi">Old version form definition</param>
    /// <param name="newVersionFi">New version form definition</param>
    /// <param name="overwrite">Indicates whether existing fields should be overwritten. Alternative form fields need to be overwritten due to the combination with upgraded class form.</param>
    /// <param name="isSystemTable">Indicates whether the class is customizable.</param>
    private static void CopyCustomFields(FormInfo oldVersionFi, FormInfo newVersionFi, bool overwrite, bool isSystemTable)
    {
        // Remove all system fields from old definition to get only custom fields
        // Remove all dummy fields from old definition for non-customizable classes (Since v9 is condition f => f.System sufficient because dummy fields created in development mode are system)
        // * Dummy field in alternative forms are not marked as system in version < v9 and should be updated. Without this condition the old version of dummy field was used instead of new one.
        // * Dummy field is not removed from customizable classes due to possible customization.
        oldVersionFi.RemoveFields(f => f.System || (f.IsDummyField && !isSystemTable));

        // Combine forms so that custom fields from old definition are appended to the new definition
        newVersionFi.CombineWithForm(oldVersionFi, new CombineWithFormSettings
        {
            IncludeCategories = false,
            RemoveEmptyCategories = true,
            OverwriteExisting = overwrite
        });
    }