コード例 #1
0
    /// <summary>
    /// Creates category with variant attributes.
    /// </summary>
    /// <param name="optionsDs">Product options</param>
    private void SetVariantAttributes(IEnumerable <SKUInfo> optionsDs)
    {
        // Get attributes category index - just before representing category
        var attrPos = editForm.FormInformation.ItemsList.FindIndex(f =>
                                                                   (f is FormCategoryInfo) && ((FormCategoryInfo)f).CategoryName.EqualsCSafe("com.sku.representingcategory"));


        // Create attributes category
        var attCategory = new FormCategoryInfo()
        {
            CategoryName = "Attributes",
            IsDummy      = true,
        };

        attCategory.SetPropertyValue(FormCategoryPropertyEnum.Caption, HTMLHelper.HTMLEncode(GetString("com.variant.attributes")));
        editForm.FormInformation.AddFormItem(attCategory, attrPos++);

        foreach (var option in optionsDs)
        {
            if (option.Parent != null)
            {
                string categoryCodeName = option.Parent.Generalized.ObjectCodeName;
                options.Add(categoryCodeName, option);

                FormFieldInfo ffOption = new FormFieldInfo
                {
                    Name         = categoryCodeName,
                    AllowEmpty   = true,
                    Size         = 400,
                    FieldType    = FormFieldControlTypeEnum.LabelControl,
                    DataType     = FieldDataType.Text,
                    IsDummyField = true,
                };

                OptionCategoryInfo parentOptionCategory = (OptionCategoryInfo)option.Parent;

                ffOption.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(option.SKUName)));

                // Show category live site display name instead of category display name in case it is available
                ffOption.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(parentOptionCategory.CategoryTitle)));

                //Insert field to the form on specified position
                editForm.FormInformation.AddFormItem(ffOption, attrPos++);
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Creates category with variant attributes.
    /// </summary>
    /// <param name="optionsList">Product options</param>
    private void SetVariantAttributes(List <SKUInfo> optionsList)
    {
        // Get attributes category index - just before representing category
        var attrPos = editForm.FormInformation.ItemsList.FindIndex(f =>
                                                                   (f is FormCategoryInfo) && ((FormCategoryInfo)f).CategoryName.EqualsCSafe("com.sku.representingcategory"));


        // Create attributes category
        var attCategory = new FormCategoryInfo()
        {
            CategoryName = "Attributes",
            IsDummy      = true,
        };

        attCategory.SetPropertyValue(FormCategoryPropertyEnum.Caption, HTMLHelper.HTMLEncode(GetString("com.variant.attributes")));
        editForm.FormInformation.AddFormItem(attCategory, attrPos++);

        // Get variant categories
        var variantCategories = VariantHelper.GetProductVariantsCategories(ProductID, false);

        foreach (var category in variantCategories)
        {
            var option = optionsList.FirstOrDefault(o => o.SKUOptionCategoryID == category.CategoryID);

            if (option != null)
            {
                FormFieldInfo ffOption = new FormFieldInfo
                {
                    Name         = category.CategoryName,
                    AllowEmpty   = true,
                    Size         = 400,
                    FieldType    = FormFieldControlTypeEnum.LabelControl,
                    DataType     = FieldDataType.Text,
                    IsDummyField = true,
                };

                ffOption.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(option.SKUName)));

                // Show category live site display name instead of category display name in case it is available
                ffOption.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(category.CategoryTitle)));

                //Insert field to the form on specified position
                editForm.FormInformation.AddFormItem(ffOption, attrPos++);
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// Initializes the form.
    /// </summary>
    /// <param name="basicForm">Form</param>
    /// <param name="dr">Data row with the data</param>
    /// <param name="fi">Form info</param>
    private void InitForm(BasicForm basicForm, DataRow dr, FormInfo fi)
    {
        if (basicForm != null)
        {
            basicForm.DataRow = dr;
            if (webPartInstance != null)
            {
                basicForm.MacroTable = webPartInstance.MacroTable;
            }
            else
            {
                basicForm.MacroTable = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            }

            if (!RequestHelper.IsPostBack() && (webPartInstance != null))
            {
                fi = new FormInfo(fi.GetXmlDefinition());

                // Load the collapsed/un-collapsed state of categories
                var categories = fi.GetCategoryNames();
                foreach (string category in categories)
                {
                    FormCategoryInfo fci = fi.GetFormCategory(category);
                    if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, basicForm.ContextResolver), false) && ValidationHelper.GetBoolean(webPartInstance.GetValue("cat_open_" + category), false))
                    {
                        fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, "false");
                    }
                }
            }

            basicForm.SubmitButton.Visible = false;
            basicForm.SiteName             = SiteContext.CurrentSiteName;
            basicForm.FormInformation      = fi;
            basicForm.ShowPrivateFields    = true;
            basicForm.OnItemValidation    += formElem_OnItemValidation;
            basicForm.ReloadData();
        }
    }
コード例 #4
0
ファイル: Properties.aspx.cs プロジェクト: isatriya/kentico10
    protected void Page_Load(object sender, EventArgs e)
    {
        // Setup info/error message placeholder
        if (MessagesPlaceHolder != null)
        {
            MessagesPlaceHolder.UseRelativePlaceHolder = false;
            form.EnsureMessagesPlaceholder(MessagesPlaceHolder);
        }

        // Load default properties from XML
        XmlDocument xml = new XmlDocument();

        xml.Load(ResolveUrl(HttpContext.Current.Server.MapPath(PortalFormHelper.BEFOREPROPERTIESDEFINITION)));

        // Load UI element and element's page template (if any)
        mUIElementInfo = UIElementInfoProvider.GetUIElementInfo(QueryHelper.GetInteger("elementID", 0));

        if (mUIElementInfo != null)
        {
            PageTemplateInfo pti = null;
            if (mUIElementInfo.ElementType == UIElementTypeEnum.PageTemplate)
            {
                pti = PageTemplateInfoProvider.GetPageTemplateInfo(mUIElementInfo.ElementPageTemplateID);
            }

            form.Enabled = ((SystemContext.DevelopmentMode || mUIElementInfo.ElementIsCustom) && (!UIElementInfoProvider.AllowEditOnlyCurrentModule || (mUIElementInfo.ElementResourceID == QueryHelper.GetInteger("moduleId", 0))));

            // Create form info
            FormInfo fi = (pti != null) ? pti.PageTemplatePropertiesForm : PortalFormHelper.GetUIElementDefaultPropertiesForm(UIElementPropertiesPosition.Both);
            form.FormInformation = fi;

            // Load data row from properties
            DataRow dr = fi.GetDataRow();
            fi.LoadDefaultValues(dr);
            if ((mUIElementInfo == null) || !mUIElementInfo.IsApplication)
            {
                fi.RemoveFormField("DescriptionLink");
            }

            XmlData customData = new XmlData();

            // Load element properties
            XmlData data = new XmlData();
            data.AllowMacros = true;
            data.LoadData(mUIElementInfo.ElementProperties);

            form.MacroTable = data.MacroTable;

            // Fill template datarow with element's properties. If template does not contain such column, add it to custom
            foreach (String col in data.ColumnNames)
            {
                if (col.StartsWith(UIContextData.CATEGORYNAMEPREFIX, StringComparison.Ordinal))
                {
                    if (!RequestHelper.IsPostBack())
                    {
                        String           catName = col.Substring(UIContextData.CATEGORYNAMEPREFIX.Length);
                        FormCategoryInfo fci     = fi.GetFormCategory(catName);
                        if (fci != null)
                        {
                            fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, ValidationHelper.GetBoolean(data[col], false).ToString().ToLowerInvariant());
                        }
                    }
                }
                else
                {
                    if (dr.Table.Columns.Contains(col))
                    {
                        DataHelper.SetDataRowValue(dr, col, data[col]);
                    }
                    else
                    {
                        customData[col] = data[col];
                    }
                }
            }

            dr["CustomProperties"] = customData.GetData();

            form.DataRow = dr;
            form.LoadData(dr);
            form.FormInformation = fi;

            // Master page style for margin
            CurrentMaster.PanelContent.CssClass = "WebpartProperties PageContent";

            form.OnAfterSave += form_OnAfterSave;
        }
        else
        {
            EditedObject = null;
        }
    }
    /// <summary>
    /// Creates category with variant attributes.
    /// </summary>
    /// <param name="optionsDs">Product options</param>
    private void SetVariantAttributes(IEnumerable<SKUInfo> optionsDs)
    {
        // Get attributes category index - just before representing category
        var attrPos = editForm.FormInformation.ItemsList.FindIndex(f =>
            (f is FormCategoryInfo) && ((FormCategoryInfo)f).CategoryName.EqualsCSafe("com.sku.representingcategory"));

        // Create attributes category
        var attCategory = new FormCategoryInfo()
        {
            CategoryName = "Attributes",
            IsDummy = true,
        };

        attCategory.SetPropertyValue(FormCategoryPropertyEnum.Caption, HTMLHelper.HTMLEncode(GetString("com.variant.attributes")));
        editForm.FormInformation.AddFormItem(attCategory, attrPos++);

        foreach (var option in optionsDs)
        {
            if (option.Parent != null)
            {
                string categoryCodeName = option.Parent.Generalized.ObjectCodeName;
                options.Add(categoryCodeName, option);

                FormFieldInfo ffOption = new FormFieldInfo
                {
                    Name = categoryCodeName,
                    AllowEmpty = true,
                    Size = 400,
                    FieldType = FormFieldControlTypeEnum.LabelControl,
                    DataType = FieldDataType.Text,
                    IsDummyField = true,
                };

                OptionCategoryInfo parentOptionCategory = (OptionCategoryInfo)option.Parent;

                ffOption.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(option.SKUName)));

                // Show category live site display name instead of category display name in case it is available
                ffOption.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(parentOptionCategory.CategoryTitle)));

                //Insert field to the form on specified position
                editForm.FormInformation.AddFormItem(ffOption, attrPos++);
            }
        }
    }