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)); }
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]); }
public static HtmlString HtmlItemScript(this string defaultVal, string itemCode = "", string fieldName = "") { HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.SCRIPT; return(new HtmlString(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName))); }
public static HtmlString HtmlItemImageUrl(this string defaultVal, string itemCode = "", string fieldName = "") { HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.IMAGE; return(new HtmlString(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName))); }
public static string HtmlItemString(this string defaultVal, string itemCode = "", string fieldName = "") { HtmlItemFieldTypes fieldType = HtmlItemFieldTypes.TEXT; return(defaultVal.HtmlItemObject(fieldType, itemCode, fieldName)); }