示例#1
0
        public static string HtmlItemObject(this string defaultVal, HtmlItemFieldTypes fieldType, string itemCode = "", string fieldName = "")
        {
            string culture = System.Globalization.CultureInfo.CurrentCulture.ToString();


            if (string.IsNullOrEmpty(itemCode))
            {
                itemCode = "global";
            }
            if (string.IsNullOrEmpty(fieldName))
            {
                fieldName = "defaultVal";
            }


            return(defaultVal.HtmlItem(culture, itemCode, fieldName, fieldType));
        }
示例#2
0
        public static string HtmlItem(this string defaultVal, string culture, string itemCode, string fieldName, HtmlItemFieldTypes fieldType)
        {
            var htmlItem = ServiceFactory.HtmlItemManager.Get(new HtmlItem()
            {
                Code = itemCode, Culture = culture
            });

            if (htmlItem == null)
            {
                htmlItem = new HtmlItem()
                {
                    Code       = itemCode,
                    Culture    = culture,
                    ItemFields = new List <HtmlItemField>()
                };

                ServiceFactory.HtmlItemManager.Add(htmlItem);
            }

            var field = htmlItem.ItemFields.Where(f => f.FieldName.Equals(fieldName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();


            if (field != null)
            {
                if (fieldType != field.DataType)
                {
                    htmlItem.ItemFields.Remove(field);

                    var newField = new HtmlItemField()
                    {
                        ItemId    = htmlItem.Id,
                        FieldName = fieldName,
                        DataType  = fieldType,
                        DataValue = defaultVal,
                    };

                    htmlItem.ItemFields.Add(newField);

                    ServiceFactory.HtmlItemFieldManager.Update(newField, field);
                }
            }
            else
            {
                var newField = new HtmlItemField()
                {
                    ItemId    = htmlItem.Id,
                    FieldName = fieldName,
                    DataType  = fieldType,
                    DataValue = defaultVal,
                };
                htmlItem.ItemFields.Add(newField);

                ServiceFactory.HtmlItemFieldManager.Add(newField);
            }


            return(htmlItem[fieldName]);
        }
示例#3
0
        public static HtmlString HtmlItemScript(this string defaultVal, string itemCode = "", string fieldName = "")
        {
            HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.SCRIPT;

            return(new HtmlString(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName)));
        }
示例#4
0
        public static HtmlString HtmlItemImageUrl(this string defaultVal, string itemCode = "", string fieldName = "")
        {
            HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.IMAGE;

            return(new HtmlString(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName)));
        }
示例#5
0
        public static string HtmlItemString(this string defaultVal, string itemCode = "", string fieldName = "")
        {
            HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.TEXT;

            return(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName));
        }