public static IHtmlControl GetNewsView(SiteState state, LightObject currentUser, TopicStorage topic, out string description) { LightObject news = topic.Topic; description = BasketballHlp.GetDescriptionForNews(news); DateTime localTime = (news.Get(ObjectType.ActFrom) ?? DateTime.UtcNow).ToLocalTime(); int publisherId = news.Get(NewsType.PublisherId); LightObject publisher = context.UserStorage.FindUser(publisherId); IHtmlControl editPanel = null; if (currentUser != null && (currentUser.Id == publisherId || currentUser.Get(BasketballUserType.IsModerator))) { editPanel = ViewNewsHlp.GetNewsEditPanel(state, topic); } IHtmlControl moderatorPanel = GetModeratorPanel(state, currentUser, topic, localTime); return(new HPanel( Decor.Title(news.Get(NewsType.Title)), new HLabel(localTime.ToString(Decor.timeFormat)).Block().FontBold(), new HTextView(news.Get(NewsType.Text)).PositionRelative().Overflow("hidden"), new HPanel( new HLabel("Добавил:").MarginRight(5), new HLink(UrlHlp.ShopUrl("user", publisherId), publisher?.Get(UserType.Login)) ), new HLink(news.Get(NewsType.OriginUrl), news.Get(NewsType.OriginName)), ViewTagHlp.GetViewTagsPanel(context.Tags.TagBox, topic.Topic), editPanel, moderatorPanel, ViewCommentHlp.GetCommentsPanel(context.MessageConnection, state, currentUser, topic, topic.MessageLink.AllRows) )); }
public static IHtmlControl GetTopicView(SiteState state, LightObject currentUser, TopicStorage topic, int pageNumber) { if (topic == null || topic.Topic == null) { return(null); } int? forumSectionId = topic.Topic.GetParentId(ForumSectionType.TopicLinks); LightSection forumSection = context.Store.Sections.FindSection(forumSectionId); if (forumSection == null) { return(null); } IHtmlControl editPanel = null; if (state.ModeratorMode) { editPanel = GetTopicRedoPanel(state, currentUser, forumSection, topic); } RowLink[] allMessages = topic.MessageLink.AllRows; RowLink[] pageMessages = ViewJumpHlp.GetPageItems(allMessages, forumMessageCountOnPage, pageNumber); if (pageMessages == null) { return(null); } return(new HPanel( Decor.Title(topic.Topic.Get(TopicType.Title)).MarginBottom(15), new HPanel( new HLink("/forum", "Форумы"), ArrowElement(), new HLink(UrlHlp.ShopUrl("page", forumSectionId), forumSection?.Get(SectionType.Title) ) ).MarginBottom(10), editPanel, ViewJumpHlp.JumpBar(string.Format("/topic/{0}", topic.TopicId), allMessages.Length, forumMessageCountOnPage, pageNumber ).MarginBottom(5), ViewCommentHlp.GetCommentsPanel(context.ForumConnection, state, currentUser, topic, pageMessages), ViewJumpHlp.JumpBar(string.Format("/topic/{0}", topic.TopicId), allMessages.Length, forumMessageCountOnPage, pageNumber ).MarginTop(10) )); }
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 GetCommentsPanel(IDataLayer commentConnection, SiteState state, LightObject currentUser, TopicStorage topic, RowLink[] pageMessages) { HPanel addPanel = null; if (currentUser != null) { HPanel editPanel = null; if (state.BlockHint == "commentAdd") { string commentValue = BasketballHlp.AddCommentFromCookie(); editPanel = new HPanel( new HTextArea("commentContent", commentValue).Width("100%").Height("10em").MarginTop(5).MarginBottom(5), Decor.Button("отправить") .OnClick(BasketballHlp.AddCommentToCookieScript("commentContent")) .Event("comment_add_save", "commentData", delegate(JsonData json) { lock (lockObj) { string content = json.GetText("commentContent"); if (StringHlp.IsEmpty(content)) { return; } if (BasketballHlp.IsDuplicate(topic, currentUser.Id, content)) { return; } InsertMessageAndUpdate(commentConnection, topic, currentUser, null, content); state.BlockHint = ""; BasketballHlp.ResetAddComment(); } } ), new HElementControl( h.Script(h.type("text/javascript"), "$('.commentContent').focus();"), "" ) ).EditContainer("commentData"); } addPanel = new HPanel( Decor.ButtonMini("оставить комментарий").FontBold().FontSize(12).Padding(2, 7). Event("comment_add", "", delegate { state.SetBlockHint("commentAdd"); } ), new HButton("", new HBefore().ContentIcon(11, 11).BackgroundImage(UrlHlp.ImageUrl("refresh.png")) ).Color("#9c9c9c").MarginLeft(10).Title("Загрузить новые комментарии") .Event("comments_refresh", "", delegate { }), editPanel ); } Dictionary <int, string> htmlRepresentByMessageId = topic.HtmlRepresentByMessageId; //RowLink[] allMessages = topic.MessageLink.AllRows; RowLink bottomMessage = null; if (pageMessages.Length > 0) { bottomMessage = pageMessages[Math.Max(0, pageMessages.Length - 2)]; } return(new HPanel( new HAnchor("comments"), new HLabel("Комментарии:").MarginTop(30).MarginBottom(20).FontSize("160%") .Hide(commentConnection == context.ForumConnection), new HPanel( new HLabel("Автор").PositionAbsolute().Top(0).Left(0) .BoxSizing().Width(100).Padding(7, 5, 5, 5), new HLabel("Сообщение").Block().Padding(7, 5, 5, 5).BorderLeft(Decor.columnBorder) ).PositionRelative().Align(null).PaddingLeft(100).Background("#dddddd").FontBold(), new HGrid <RowLink>(pageMessages, delegate(RowLink comment) { IHtmlControl commentBlock = ViewCommentHlp.GetCommentBlock( commentConnection, state, currentUser, topic, htmlRepresentByMessageId, comment ); if (bottomMessage == comment) { return new HPanel(new HAnchor("bottom"), commentBlock); } return commentBlock; }, new HRowStyle().Even(new HTone().Background(Decor.evenBackground)) ).BorderBottom(Decor.bottomBorder).MarginBottom(10), //new HAnchor("bottom"), addPanel )); }