Exemple #1
0
        public static void SaveAttributes(IAttributes attributes, SiteInfo siteInfo, List <TableStyleInfo> styleInfoList, NameValueCollection formCollection, List <string> dontAddAttributesLowercase)
        {
            if (dontAddAttributesLowercase == null)
            {
                dontAddAttributesLowercase = new List <string>();
            }

            foreach (var styleInfo in styleInfoList)
            {
                if (dontAddAttributesLowercase.Contains(styleInfo.AttributeName.ToLower()))
                {
                    continue;
                }
                //var theValue = GetValueByForm(styleInfo, siteInfo, formCollection);

                var theValue  = formCollection[styleInfo.AttributeName] ?? string.Empty;
                var inputType = styleInfo.InputType;
                if (inputType == InputType.TextEditor)
                {
                    theValue = ContentUtility.TextEditorContentEncode(siteInfo, theValue);
                    theValue = UEditorUtils.TranslateToStlElement(theValue);
                }

                if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl)
                {
                    theValue = AttackUtils.FilterSqlAndXss(theValue);
                }

                attributes.Set(styleInfo.AttributeName, theValue);
                //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, styleInfo.AttributeName, theValue);

                if (styleInfo.Additional.IsFormatString)
                {
                    var formatString    = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatU"]);
                    var formatColor     = formCollection[styleInfo.AttributeName + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);

                    attributes.Set(ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString);
                    //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString);
                }

                if (inputType == InputType.Image || inputType == InputType.File || inputType == InputType.Video)
                {
                    var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    attributes.Set(attributeName, formCollection[attributeName]);
                    //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, attributeName, formCollection[attributeName]);
                }
            }
        }