Beispiel #1
0
        private static MvcHtmlString VersionClassifierField(this HtmlHelper source, string name, string value, Field field, Article article, ArticleVersion version = null, bool forceReadOnly = true, string valueToMerge = null)
        {
            var name1 = version?.GetAggregatedContent(value)?.Name;

            if (!StringComparer.InvariantCultureIgnoreCase.Equals(value, valueToMerge) && article.ViewType == ArticleViewType.CompareVersions)
            {
                var name2       = version?.VersionToMerge.GetAggregatedContent(valueToMerge)?.Name;
                var mergedValue = ArticleVersion.Merge(Formatter.ProtectHtml(name1), Formatter.ProtectHtml(name2));
                return(source.VersionText(name, mergedValue));
            }

            Article aggregatedArticle = null;
            var     classifierValue   = Converter.ToInt32(value, 0);

            if (article.ViewType != ArticleViewType.Virtual)
            {
                aggregatedArticle = version?.AggregatedArticles.SingleOrDefault(n => n.ContentId == classifierValue);
            }

            var sb = new StringBuilder(source.BeginClassifierFieldComponent(name, value, field, article, aggregatedArticle, out var _));

            if (forceReadOnly)
            {
                sb.Append(source.VersionText(name, name1));
            }
            else
            {
                var contentListHtmlAttrs = new Dictionary <string, object> {
                    { "class", "dropDownList classifierContentList" }
                };
                sb.Append(source.DropDownList(name, source.List(ArticleViewModel.GetAggregatableContentsForClassifier(field, value)), FieldStrings.SelectContent, contentListHtmlAttrs).ToHtmlString());
            }

            sb.Append(EndClassifierFieldComponent());
            return(MvcHtmlString.Create(sb.ToString()));
        }