static IHtmlControl GetDialogBlock(IDataLayer forumConnection, UserStorage userStorage, LightObject user, RowLink dialog, int messageIndex) { LightObject collocutor = userStorage.FindUser(dialog.Get(DialogueType.CollocutorId)); if (collocutor == null) { return(null); } bool read = dialog.Get(DialogueType.Unread); bool inbox = dialog.Get(DialogueType.Inbox); LightObject author = inbox ? collocutor : user; DateTime localTime = dialog.Get(DialogueType.ModifyTime).ToLocalTime(); HBefore before = null; if (!inbox) { before = std.BeforeAwesome(@"\f112", 8); } IHtmlControl messageBlock = new HPanel("", new IHtmlControl[] { new HPanel( ViewUserHlp.AvatarBlock(collocutor) ).PositionAbsolute().Left(0).Top(0).Padding(7, 5, 10, 5), new HPanel( new HPanel( new HLabel(collocutor.Get(UserType.Login)).FontBold(), new HLabel(collocutor.Get(UserType.FirstName)).MarginLeft(5), new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).PositionAbsolute().Right(5) .FontSize("90%").Color(Decor.minorColor) ).PositionRelative().MarginBottom(6), new HLabel( //BasketballHlp.PreViewComment(dialog.Get(DialogueType.Content)), dialog.Get(DialogueType.Content), before ).Block().PaddingBottom(15).BorderBottom("1px solid silver").MarginBottom(5) .FontBold(read).Color(read ? Decor.textColor : Decor.minorColor) .Width("100%").NoWrap().Overflow("hidden").CssAttribute("text-overflow", "ellipsis") ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5) }, new HHover().Background(Decor.pageBackground) ).PositionRelative().PaddingLeft(64).BorderTop("2px solid #fff").Color(Decor.textColor); //if (messageIndex % 2 != 0) // messageBlock.Background(Decor.evenBackground); return(new HLink(string.Format("{0}", UrlHlp.ShopUrl("dialog", collocutor.Id)), messageBlock, new HHover().Background(Decor.pageBackground) ).TextDecoration("none")); }
static IHtmlControl GetCorrespondenceHeader(SiteState state, LightObject user, LightObject collocutor) { return(new HPanel( new HPanel( new HLink(UrlHlp.ShopUrl("dialog"), new HLabel("Назад", std.BeforeAwesome(@"\f104", 8).FontSize(26).FontBold(false).VAlign(-4) ).Color(Decor.minorColor).FontBold() ) ).InlineBlock().PositionAbsolute().Left(5).Top(10), new HPanel( new HLink(UrlHlp.ShopUrl("user", collocutor?.Id), collocutor?.Get(UserType.Login) ).FontBold(), new HLabel(collocutor?.Get(UserType.FirstName)).Block() ).Padding(7, 5, 10, 5), new HPanel( new HLink(UrlHlp.ShopUrl("user", collocutor?.Id), ViewUserHlp.AvatarBlock(collocutor).Size(32, 32) ) ).PositionAbsolute().Right(5).Top(5) ).PositionRelative().Align(null).BorderBottom(Decor.buttonBorder) .PaddingLeft(50).PaddingRight(50)); }
public static IHtmlControl GetCenter(HttpContext httpContext, SiteState state, LightObject currentUser, string kind, int?id, out string title, out string description, out SchemaOrg schema, out bool wideContent) { title = ""; description = ""; schema = null; wideContent = false; SiteSettings settings = context.SiteSettings; switch (kind) { case "": { title = store.SEO.Get(SEOType.MainTitle); description = store.SEO.Get(SEOType.MainDescription); LightSection main = store.Sections.FindMenu("main"); return(ViewHlp.GetMainView(state, currentUser)); } case "news": { if (!context.News.ObjectById.Exist(id)) { return(null); } TopicStorage topicStorage = context.NewsStorages.ForTopic(id ?? 0); LightKin topic = topicStorage.Topic; //string tagsDisplay; IHtmlControl view = ViewNewsHlp.GetNewsView(state, currentUser, topicStorage, out description); title = topic.Get(NewsType.Title); //string postfix = ""; //if (!StringHlp.IsEmpty(tagsDisplay)) // postfix = ". "; //description = string.Format("{0}{1}Живое обсуждение баскетбольных событий на basketball.ru.com", // tagsDisplay, postfix //); string logoUrl = settings.FullUrl("/images/logo.gif"); schema = new SchemaOrg("NewsArticle", settings.FullUrl(UrlHlp.ShopUrl("news", id)), title, new string[] { logoUrl }, topic.Get(ObjectType.ActFrom), topic.Get(ObjectType.ActTill), topic.Get(TopicType.OriginName), settings.Organization, logoUrl, description ); return(view); } case "article": { if (!context.Articles.ObjectById.Exist(id)) { return(null); } TopicStorage topicStorage = context.ArticleStorages.ForTopic(id ?? 0); LightKin topic = topicStorage.Topic; title = topic.Get(ArticleType.Title); description = topic.Get(ArticleType.Annotation); string logoUrl = settings.FullUrl("/images/logo.gif"); schema = new SchemaOrg("Article", settings.FullUrl(UrlHlp.ShopUrl("article", id)), title, new string[] { logoUrl }, topic.Get(ObjectType.ActFrom), topic.Get(ObjectType.ActTill), topic.Get(TopicType.OriginName), settings.Organization, logoUrl, description ); wideContent = topic.Get(ArticleType.WideContent); return(ViewArticleHlp.GetArticleView(state, currentUser, topicStorage)); } case "topic": { TopicStorage topic = context.Forum.TopicsStorages.ForTopic(id ?? 0); title = topic.Topic.Get(TopicType.Title); int pageNumber = 0; { string pageArg = httpContext.Get("page"); int messageCount = topic.MessageLink.AllRows.Length; if (pageArg == "last" && messageCount > 0) { pageNumber = BinaryHlp.RoundUp(messageCount, ViewForumHlp.forumMessageCountOnPage) - 1; } else { pageNumber = ConvertHlp.ToInt(pageArg) ?? 0; } } return(ViewForumHlp.GetTopicView(state, currentUser, topic, pageNumber)); } case "tags": { int?tagId = httpContext.GetUInt("tag"); int pageNumber = httpContext.GetUInt("page") ?? 0; return(ViewNewsHlp.GetTagView(state, currentUser, tagId, pageNumber, out title, out description)); } case "search": { return(ViewNewsHlp.GetFoundTagListView(state, out title)); } case "user": { LightObject user = context.UserStorage.FindUser(id ?? -1); if (user == null) { return(null); } title = string.Format("{0} - Basketball.ru.com", user.Get(UserType.Login)); return(ViewUserHlp.GetUserView(state, currentUser, user)); } case "page": { LightSection section = store.Sections.FindSection(id); title = FabricHlp.GetSeoTitle(section, section.Get(SectionType.Title)); description = FabricHlp.GetSeoDescription(section, section.Get(SectionType.Annotation)); int pageNumber = httpContext.GetUInt("page") ?? 0; string designKind = section.Get(SectionType.DesignKind); switch (designKind) { case "news": { int[] allNewsIds = context.News.AllObjectIds; return(ViewNewsHlp.GetNewsListView(state, currentUser, pageNumber)); } case "articles": return(ViewArticleHlp.GetArticleListView(state, currentUser, pageNumber)); case "forum": return(ViewForumHlp.GetForumView(state, currentUser, section)); case "forumSection": return(ViewForumHlp.GetForumSectionView(state, currentUser, section)); default: return(null); } } case "dialog": { if (currentUser == null) { return(null); } if (id == null) { return(ViewDialogueHlp.GetDialogueView(state, context.ForumConnection, context.UserStorage, currentUser, out title )); } LightObject collocutor = context.UserStorage.FindUser(id.Value); if (collocutor == null) { return(null); } return(ViewDialogueHlp.GetCorrespondenceView(state, context.ForumConnection, currentUser, collocutor, out title )); } case "passwordreset": title = "Восстановление пароля - basketball.ru.com"; return(ViewHlp.GetRestorePasswordView(state)); case "register": title = "Регистрация - basketball.ru.com"; return(ViewHlp.GetRegisterView(state)); case "confirmation": { title = "Подтверждение аккаунта"; int? userId = httpContext.GetUInt("id"); string hash = httpContext.Get("hash"); if (userId == null) { return(ViewUserHlp.GetMessageView( "Вам выслано письмо с кодом активации. Чтобы завершить процедуру регистрации, пройдите по ссылке, указанной в письме, и учётная запись будет активирована. Если вы не получили письмо, то попробуйте войти на сайт со своим логином и паролем. Тогда письмо будет отправлено повторно." )); } if (StringHlp.IsEmpty(hash)) { return(null); } LightObject user = context.UserStorage.FindUser(userId.Value); if (userId == null) { return(null); } if (!user.Get(UserType.NotConfirmed)) { return(ViewUserHlp.GetMessageView("Пользователь успешно активирован")); } string login = user.Get(UserType.Login); string etalon = UserHlp.CalcConfirmationCode(user.Id, login, "bbbin"); if (hash?.ToLower() != etalon?.ToLower()) { return(ViewUserHlp.GetMessageView("Неверный хэш")); } LightObject editUser = DataBox.LoadObject(context.UserConnection, UserType.User, user.Id); editUser.Set(UserType.NotConfirmed, false); editUser.Box.Update(); context.UserStorage.Update(); string xmlLogin = UserType.Login.CreateXmlIds("", login); HttpContext.Current.SetUserAndCookie(xmlLogin); state.RedirectUrl = "/"; return(new HPanel()); } } return(null); }
static IHtmlControl GetMessageBlock(IDataLayer forumConnection, SiteState state, LightObject user, LightObject collocutor, RowLink message, int messageIndex) { int messageId = message.Get(CorrespondenceType.Id); LightObject author = message.Get(CorrespondenceType.Inbox) ? collocutor : user; DateTime localTime = message.Get(CorrespondenceType.CreateTime).ToLocalTime(); IHtmlControl deleteElement = null; if (state.BlockHint == "correspondence_moderation") { deleteElement = new HButton("", std.BeforeAwesome(@"\f00d", 0) ).MarginLeft(5).Color(Decor.redColor).Title("удалить комментарий") .Event("delete_message", "", delegate { forumConnection.GetScalar("", "Delete From correspondence Where id = @messageId", new DbParameter("messageId", messageId) ); }, messageId ); } IHtmlControl messageBlock = new HPanel("", new IHtmlControl[] { new HPanel( ViewUserHlp.AvatarBlock(author) ).PositionAbsolute().Left(0).Top(0).Padding(7, 5, 10, 5), new HPanel( new HPanel( //new HLabel(author.Get(UserType.Login)).FontBold(), new HLink(UrlHlp.ShopUrl("user", author.Id), author.Get(UserType.FirstName) ).FontBold(), //new HLabel(author.Get(UserType.FirstName)).MarginLeft(5), new HPanel( new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).FontSize("90%").Color(Decor.minorColor), deleteElement ).InlineBlock().PositionAbsolute().Right(5) ).PositionRelative().MarginBottom(6), new HTextView( BasketballHlp.PreViewComment(message.Get(CorrespondenceType.Content)) ).Block().PaddingBottom(15).BorderBottom("1px solid silver").MarginBottom(5) ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5) } ).PositionRelative().PaddingLeft(64).BorderTop("2px solid #fff").Color(Decor.textColor); //IHtmlControl messageBlock = new HXPanel( // new HPanel( // new HLink(UrlHlp.ShopUrl("user", author.Id), // author.Get(UserType.Login) // ).FontBold(), // new HLabel(author.Get(UserType.FirstName)).Block() // .MediaTablet(new HStyle().InlineBlock().MarginLeft(5)), // new HPanel( // ViewUserHlp.AvatarBlock(author) // ).MarginTop(5) // .MediaTablet(new HStyle().Display("none")) // ).BoxSizing().WidthLimit("100px", "").Padding(7, 5, 10, 5) // .MediaTablet(new HStyle().Block().PaddingBottom(0).PaddingRight(110)), // new HPanel( // new HPanel( // new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).MarginRight(5) // .MediaTablet(new HStyle().MarginBottom(5)), // deleteElement // ).Align(false).FontSize("90%").Color(Decor.minorColor), // new HTextView( // BasketballHlp.PreViewComment(message.Get(CorrespondenceType.Content)) // ).PaddingBottom(15).MarginBottom(5).BorderBottom("1px solid silver") // ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5) // .MediaTablet(new HStyle().Block().MarginTop(-19)) //).BorderTop("2px solid #fff"); if (messageIndex % 2 != 0) { messageBlock.Background(Decor.evenBackground); } return(messageBlock); }
public static IHtmlControl GetCommentBlock(IDataLayer commentConnection, SiteState state, LightObject currentUser, TopicStorage topic, Dictionary <int, string> htmlRepresentByMessageId, RowLink comment) { LightObject user = context.UserStorage.FindUser(comment.Get(MessageType.UserId)); DateTime localTime = comment.Get(MessageType.CreateTime).ToLocalTime(); IHtmlControl whomBlock = GetWhomBlock(state, context.UserStorage, topic, htmlRepresentByMessageId, comment); int commentId = comment.Get(MessageType.Id); string answerHint = string.Format("answer_{0}", commentId); IHtmlControl answerBlock = null; if (currentUser != null && state.BlockHint == answerHint) { string commentValue = BasketballHlp.AddCommentFromCookie(); answerBlock = new HPanel( new HTextArea("answerContent", commentValue).Width("100%").Height("10em").MarginTop(5).MarginBottom(5), Decor.Button("отправить") .OnClick(BasketballHlp.AddCommentToCookieScript("answerContent")) .Event("save_answer", "answerContainer", delegate(JsonData json) { lock (lockObj) { string content = json.GetText("answerContent"); if (StringHlp.IsEmpty(content)) { return; } if (BasketballHlp.IsDuplicate(topic, currentUser.Id, content)) { return; } InsertMessageAndUpdate(commentConnection, topic, currentUser, commentId, content); state.BlockHint = ""; BasketballHlp.ResetAddComment(); } }, commentId ), new HElementControl( h.Script(h.type("text/javascript"), "$('.answerContent').focus();"), "" ) ).EditContainer("answerContainer"); } IHtmlControl editBlock = null; if (currentUser != null && currentUser.Id == user?.Id) { editBlock = new HPanel( ); } string redoHint = string.Format("redo_{0}", commentId); HButton redoButton = null; if (currentUser != null && currentUser.Id == user?.Id) { redoButton = Decor.ButtonMini("редактировать").Event("comment_redo", "", delegate(JsonData json) { state.SetBlockHint(redoHint); }, commentId ); } IHtmlControl redoBlock = null; if (currentUser != null && state.BlockHint == redoHint) { redoBlock = new HPanel( new HTextArea("redoContent", comment.Get(MessageType.Content)) .Width("100%").Height("10em").MarginTop(5).MarginBottom(5), Decor.Button("изменить").Event("save_redo", "redoContainer", delegate(JsonData json) { string content = json.GetText("redoContent"); if (StringHlp.IsEmpty(content)) { return; } //content = BasketballHlp.PreSaveComment(content); commentConnection.GetScalar("", "Update message Set content=@content, modify_time=@time Where id=@id", new DbParameter("content", content), new DbParameter("time", DateTime.UtcNow), new DbParameter("id", commentId) ); topic.UpdateMessages(); state.BlockHint = ""; }, commentId ), new HElementControl( h.Script(h.type("text/javascript"), "$('.redoContent').focus();"), "" ) ).EditContainer("redoContainer"); } IHtmlControl deleteElement = null; if (state.ModeratorMode) { deleteElement = new HButton("", std.BeforeAwesome(@"\f00d", 0) ).MarginLeft(5).Color(Decor.redColor).Title("удалить комментарий") .Event("delete_comment", "", delegate { MessageHlp.DeleteMessage(commentConnection, commentId); topic.UpdateMessages(); context.UpdateLastComments(commentConnection == context.ForumConnection); }, commentId ); } string topicType = topic.Topic.Get(ObjectType.TypeId) == NewsType.News ? "news" : "article"; string anchor = string.Format("reply{0}", commentId); return(new HXPanel( new HAnchor(anchor), new HPanel( new HLink(UrlHlp.ShopUrl("user", user?.Id), user?.Get(UserType.Login) ).FontBold(), new HLabel(user?.Get(UserType.FirstName)).Block() .MediaTablet(new HStyle().InlineBlock().MarginLeft(5)), new HPanel( ViewUserHlp.AvatarBlock(user) ).MarginTop(5) .MediaTablet(new HStyle().Display("none")) ).BoxSizing().WidthLimit("100px", "").Padding(7, 5, 10, 5) .MediaTablet(new HStyle().Block().PaddingBottom(0).PaddingRight(110)), new HPanel( new HPanel( new HLabel(localTime.ToString("dd.MM.yyyy HH:mm")).MarginRight(5) .MediaTablet(new HStyle().MarginBottom(5)), new HLink(string.Format("/{0}/{1}#{2}", topicType, topic.TopicId, anchor), "#").TextDecoration("none") .Hide(commentConnection == context.ForumConnection), deleteElement ).Align(false).FontSize("90%").Color(Decor.minorColor), whomBlock, new HTextView( DictionaryHlp.GetValueOrDefault(htmlRepresentByMessageId, commentId) ).PaddingBottom(15).MarginBottom(5).BorderBottom("1px solid silver"), new HPanel( Decor.ButtonMini("ответить").Event("comment_answer", "", delegate { state.SetBlockHint(answerHint); }, commentId ), redoButton ).Hide(currentUser == null), answerBlock, redoBlock ).BoxSizing().Width("100%").BorderLeft(Decor.columnBorder).Padding(7, 5, 5, 5) .MediaTablet(new HStyle().Block().MarginTop(-19)) ).BorderTop("2px solid #fff")); }