public static IHtmlControl GetArticleView(SiteState state, LightObject currentUser, TopicStorage topic) { if (topic == null || topic.Topic == null) { return(null); } LightObject article = topic.Topic; DateTime localTime = (article.Get(ObjectType.ActFrom) ?? DateTime.UtcNow).ToLocalTime(); int publisherId = article.Get(NewsType.PublisherId); LightObject publisher = context.UserStorage.FindUser(publisherId); IHtmlControl editPanel = null; if (currentUser != null && (currentUser.Id == publisherId || currentUser.Get(BasketballUserType.IsModerator))) { editPanel = ViewArticleHlp.GetArticleEditPanel(state, topic); } string author = article.Get(ArticleType.Author); int commentCount = topic.MessageLink.AllRows.Length; string articleUrl = UrlHlp.ShopUrl("article", article.Id); return(new HPanel( Decor.Title(article.Get(NewsType.Title)), new HPanel( new HLabel(string.Format("{0},", author)).FontBold().MarginRight(5).Hide(StringHlp.IsEmpty(author)), new HLabel(article.Get(ArticleType.OriginName)) .FontBold().MarginRight(5), new HLabel(string.Format("| {0}", localTime.ToString("dd MMMM yyyy"))) ).FontSize("90%"), new HPanel( new HLabel("Комментарии:").Color(Decor.minorColor), ViewNewsHlp.GetCommentElement(commentCount, articleUrl) ).FontSize("90%"), //new HLabel(localTime.ToString(Decor.timeFormat)).Block().FontBold(), new HTextView(article.Get(NewsType.Text)), new HLabel("Автор:").MarginRight(5).Hide(StringHlp.IsEmpty(author)), new HLabel(author).FontBold().MarginRight(5).Hide(StringHlp.IsEmpty(author)), new HLabel("|").MarginRight(5).Hide(StringHlp.IsEmpty(author)), new HLink(article.Get(NewsType.OriginUrl), article.Get(NewsType.OriginName)), new HPanel( new HLabel("Добавил:").MarginRight(5), new HLink(UrlHlp.ShopUrl("user", publisherId), publisher?.Get(UserType.Login)) ).MarginTop(5), editPanel, ViewCommentHlp.GetCommentsPanel(context.MessageConnection, state, currentUser, topic, topic.MessageLink.AllRows) )); }
public static IHtmlControl[] GetArticleItems(SiteState state, IEnumerable <LightObject> articleList) { List <IHtmlControl> items = new List <IHtmlControl>(); foreach (LightObject article in articleList) { DateTime localTime = (article.Get(ObjectType.ActFrom) ?? DateTime.UtcNow).ToLocalTime(); int commentCount = context.ArticleStorages.ForTopic(article.Id).MessageLink.AllRows.Length; string articleUrl = UrlHlp.ShopUrl("article", article.Id); string imageUrl = UrlHlp.ImageUrl(article.Id, false); string author = article.Get(ArticleType.Author); string annotationWithLink = string.Format( "{0} <a href='{1}'><img src='/images/full.gif'></img></a>", article.Get(ArticleType.Annotation), articleUrl ); items.Add( new HPanel( new HPanel( new HLink(articleUrl, article.Get(NewsType.Title) ).FontSize("14.4px").FontBold(), ViewNewsHlp.GetCommentElement(commentCount, articleUrl) ).FontSize("90%"), new HXPanel( new HPanel( new HPanel().InlineBlock().Size(Decor.ArticleThumbWidth, Decor.ArticleThumbHeight) .Background(imageUrl, "no-repeat", "center").CssAttribute("background-size", "100%") .MarginTop(2).MarginBottom(5) ), new HPanel( new HPanel( new HLabel(string.Format("{0},", author)).MarginRight(5).Hide(StringHlp.IsEmpty(author)), new HLabel(article.Get(ArticleType.OriginName)), new HLabel("//").MarginLeft(5).MarginRight(5), new HLabel(localTime.ToString("dd MMMM yyyy")) ).FontSize("90%").MarginBottom(7).MarginTop(2), new HTextView( annotationWithLink ) ).PaddingLeft(20) ) ).Padding(1).BorderBottom("1px solid #e0dede").MarginBottom(5) ); } return(items.ToArray()); }