Example #1
0
        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)
                       ));
        }
        static IHtmlControl GetActualPublicationPanel(SiteState state)
        {
            return(new HPanel(
                       Decor.Subtitle("Обсуждаемое").MarginBottom(10).MarginTop(5),
                       new HGrid <RowLink>(context.LastPublicationComments,
                                           delegate(RowLink comment)
            {
                int topicId = comment.Get(MessageType.ArticleId);

                TopicStorage topic = null;
                string url = "";
                if (context.News.ObjectById.Exist(topicId))
                {
                    topic = context.NewsStorages.ForTopic(topicId);
                    url = UrlHlp.ShopUrl("news", topic?.TopicId);
                }
                else if (context.Articles.ObjectById.Exist(topicId))
                {
                    topic = context.ArticleStorages.ForTopic(topicId);
                    url = UrlHlp.ShopUrl("article", topic?.TopicId);
                }

                if (topic == null || topic.Topic == null)
                {
                    return new HPanel();
                }

                int userId = comment.Get(MessageType.UserId);
                LightObject user = context.UserStorage.FindUser(userId);

                DateTime localTime = comment.Get(MessageType.CreateTime).ToLocalTime();
                string replyUrl = string.Format("{0}#reply{1}", url, comment.Get(MessageType.Id));

                return new HPanel(
                    new HPanel(
                        new HLabel(localTime.ToString("HH:mm")).MarginRight(5)
                        .Title(localTime.ToString(Decor.timeFormat)),
                        new HLabel(user?.Get(UserType.Login))
                        ),
                    new HLink(url,
                              topic.Topic.Get(TopicType.Title)
                              ).MarginRight(5),
                    new HLink(
                        replyUrl, "",
                        new HBefore().ContentIcon(13, 13).Background("/images/full.gif", "no-repeat", "bottom").VAlign(-2)
                        //new HImage("/images/full.gif").VAlign(-2)
                        )
                    //ViewNewsHlp.GetCommentElement(topic.MessageLink.AllRows.Length, url)
                    ).MarginBottom(6);
            },
                                           new HRowStyle()
                                           ).FontSize("90%")
                       ).Padding(15, 15, 10, 15).MarginBottom(5).Background(Decor.pageBackground));
        }
Example #3
0
 static IHtmlControl GetRedoAvatarPanel(LightObject user)
 {
     return(new HPanel(
                new HFileUploader("/avatarupload", "Выбрать аватар", user.Id),
                Decor.Button("Удалить аватар").MarginTop(5).Event("avatar_delete", "",
                                                                  delegate
     {
         File.Delete(UrlHlp.ImagePath(Path.Combine("users", user.Id.ToString(), "avatar.png")));
     }
                                                                  )
                ).MarginTop(5));
 }
Example #4
0
        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"));
        }
Example #5
0
        public static IHtmlControl AvatarBlock(LightObject user)
        {
            string imageUrl = UrlHlp.ImageUrl(string.Format("users/{0}/avatar.png", user.Id));

            if (imageUrl.EndsWith("placeholder.png"))
            {
                imageUrl = UrlHlp.ImageUrl("no_avatar.gif");
            }

            return(new HPanel().InlineBlock().Size(Decor.AvatarSize, Decor.AvatarSize)
                   .Background(imageUrl, "no-repeat", "center").CssAttribute("background-size", "100%"));
        }
Example #6
0
        public static IHtmlControl[] GetNewsItems(SiteState state, IEnumerable <LightHead> newsList)
        {
            List <IHtmlControl> items = new List <IHtmlControl>();

            DateTime prevTime = DateTime.MinValue;

            foreach (LightHead news in newsList)
            {
                DateTime localTime        = (news.Get(ObjectType.ActFrom) ?? DateTime.UtcNow).ToLocalTime();
                DateTime currentLocalTime = DateTime.UtcNow.ToLocalTime();
                bool     isFixed          = localTime.Date > currentLocalTime.AddDays(1);

                if (prevTime.Date != localTime.Date)
                {
                    prevTime = localTime.Date;

                    if (!isFixed)
                    {
                        string dateFormat = localTime.Year == currentLocalTime.Year ?
                                            BasketballHlp.shortDateFormat : BasketballHlp.longDateFormat;

                        items.Add(
                            new HPanel(
                                new HLabel(localTime.ToString(dateFormat)).FontBold()
                                ).Padding(1).MarginTop(15).MarginBottom(4)
                            );
                    }
                    else
                    {
                        items.Add(
                            new HPanel().Height(15)
                            );
                    }
                }

                int    commentCount = context.NewsStorages.ForTopic(news.Id).MessageLink.AllRows.Length;
                string newsUrl      = UrlHlp.ShopUrl("news", news.Id);

                IHtmlControl commentElement = GetCommentElement(commentCount, newsUrl);

                items.Add(
                    new HPanel(
                        new HLabel(localTime.ToString("HH:mm")).MarginLeft(5).MarginRight(10),
                        new HLink(newsUrl,
                                  news.Get(NewsType.Title)
                                  ).FontBold(isFixed),
                        commentElement
                        ).FontSize("90%").Padding(1)
                    );
            }

            return(items.ToArray());
        }
Example #7
0
        public static IHtmlControl GetMenu(SiteState state, LightObject currentUser, string kind, int?id, bool isForum)
        {
            LightSection main = store.Sections.FindMenu("main");

            List <IHtmlControl> items = new List <IHtmlControl>();

            foreach (LightSection section in main.Subsections)
            {
                bool   isSelected = kind == "page" && id == section.Id;
                string designKind = section.Get(SectionType.DesignKind);
                if (designKind == "news" && kind == "news")
                {
                    isSelected = true;
                }
                //hack захардкодена статья с правилами
                else if (designKind == "articles" && kind == "article" && id != 118210)
                {
                    isSelected = true;
                }
                else if (designKind == "forum" && isForum)
                {
                    isSelected = true;
                }
                else if (designKind == "rules" && id == 118210)
                {
                    isSelected = true;
                }

                string url = designKind != "rules" ? UrlHlp.ShopUrl("page", section.Id) :
                             section.Get(SectionType.Link);

                items.Add(
                    ViewHeaderHlp.GetMenuItem(state, section, url, isSelected)
                    );
            }

            if (state.EditMode)
            {
                items.Add(DecorEdit.AdminGroupPanel(true, main.Id));
            }

            items.Add(GetSearchPanel(state));

            return(new HPanel(
                       new HPanel(
                           items.ToArray()
                           ),
                       GetDialogItem(state, currentUser, kind)
                       ).PositionRelative().Align(true).Padding(3, 60, 2, 2).Background(Decor.menuBackground)
                   .Media(360, new HStyle().PaddingRight(20)));
        }
Example #8
0
        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)
                       ));
        }
Example #9
0
        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());
        }
Example #10
0
        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)
                       ));
        }
Example #11
0
        static IHtmlControl GetInnerCommentElement(int commentCount, string newsUrl)
        {
            HBefore before = new HBefore().ContentIcon(9, 11).BackgroundImage(UrlHlp.ImageUrl("page.gif"))
                             .VAlign(-2).MarginRight(5);

            if (commentCount == 0)
            {
                return(new HLabel(commentCount, before).Color("#9c9c9c"));
            }

            return(new HPanel(
                       new HLink(string.Format("{0}#comments", newsUrl),
                                 commentCount.ToString(), before
                                 )
                       ).InlineBlock());
        }
Example #12
0
        public static IHtmlControl GetForumView(SiteState state, LightObject currentUser, LightSection forum)
        {
            return(new HPanel(
                       Decor.Title("Форумы").MarginBottom(15),
                       new HGrid <LightSection>(forum.Subsections,
                                                delegate(LightSection subSection)
            {
                TopicStorage lastTopic = GetLastTopicForForumSection(subSection);
                RowLink lastMessage = lastTopic == null ? null : _.Last(lastTopic.MessageLink.AllRows);
                LightObject lastUser = FindUserForMessage(lastMessage);

                return new HPanel(
                    new HPanel(
                        new HLink(UrlHlp.ShopUrl("page", subSection.Id),
                                  subSection.Get(SectionType.Title)
                                  ).FontBold()
                        ).RelativeWidth(50).PaddingLeft(5).VAlign(true).PaddingTop(15)
                    .MediaTablet(new HStyle().Block().Width("auto")),
                    new HPanel(
                        new HPanel(
                            new HLink(UrlHlp.ShopUrl("topic", lastTopic?.TopicId),
                                      lastTopic?.Topic.Get(TopicType.Title)
                                      )
                            ).MarginTop(7).MarginBottom(3),
                        new HPanel(
                            new HLink(UrlHlp.ShopUrl("user", lastUser?.Id),
                                      lastUser?.Get(UserType.Login)
                                      ),
                            new HLabel(
                                lastMessage?.Get(MessageType.CreateTime).ToLocalTime().ToString(Decor.timeFormat)
                                ).MarginLeft(7).MarginRight(7),
                            new HLink(
                                string.Format("{0}?page=last#bottom", UrlHlp.ShopUrl("topic", lastTopic?.TopicId)),
                                new HImage("/images/full.gif")
                                ).Hide(lastMessage == null)
                            ).MarginBottom(7)
                        ).RelativeWidth(50).Padding(0, 5).Height(45).BorderLeft(Decor.columnBorder)
                    .MediaTablet(new HStyle().Width("auto").Border("none"))
                    );
            },
                                                new HRowStyle().Even(new HTone().Background(Decor.evenBackground))
                                                ).BorderBottom(Decor.bottomBorder).MarginBottom(10),
                       DecorEdit.AdminGroupPanel(state.EditMode, forum.Id)
                       ));
        }
Example #13
0
        static IHtmlControl GetDialogItem(SiteState state, LightObject currentUser, string kind)
        {
            if (currentUser == null)
            {
                return(null);
            }

            RowLink unreadRow = context.UnreadDialogLink.FindRow(DialogReadType.UnreadByUserId, currentUser.Id);
            HAfter  after     = null;

            if (unreadRow != null)
            {
                after = new HAfter().Content(unreadRow.Get(DialogReadType.Count).ToString())
                        .Align(null).MarginLeft(8).FontBold().TextDecoration("none")
                        .InlineBlock().BoxSizing().Size(20, 20).LineHeight(18)
                        .BorderRadius("50%").Background(Decor.redColor);
            }

            HPanel labelPanel = new HPanel(
                new HLabel("Личные сообщения", after, new HHover().TextDecoration("none"))
                .Padding(7, 17, 8, 17).LineHeight(20).TextDecoration("underline")
                .Media(600, new HStyle().Display("none")),
                new HLabel("", std.BeforeAwesome(@"\f086", 0).FontSize(20).VAlign(-2), after)
                .Padding(7, 17, 8, 17).LineHeight(20)
                .Display("none").Media(600, new HStyle().InlineBlock())
                ).InlineBlock();

            if (kind != "dialog")
            {
                labelPanel.Color(Decor.menuColor);
            }
            else
            {
                labelPanel.Color(Decor.menuSelectedColor).FontBold().Background(Decor.menuSelectedBackground);
            }

            return(new HPanel(
                       new HLink(UrlHlp.ShopUrl("dialog", null),
                                 labelPanel
                                 )
                       ).InlineBlock().PositionAbsolute().Right(2).Top(3));
        }
Example #14
0
        public static IHtmlControl GetReclameColumnView(SiteState state)
        {
            LightSection main = context.Store.Sections.FindMenu("main");

            return(new HPanel(
                       new HGrid <LightKin>(main.Units, delegate(LightKin unit)
            {
                return new HPanel(
                    new HLink(unit.Get(UnitType.Link),
                              new HImage(UrlHlp.ImageUrl(unit.Id, true))
                              .Alt(unit.Get(UnitType.ImageAlt)).Title(unit.Get(UnitType.Annotation))
                              ).TargetBlank(),
                    DecorEdit.AdminUnitRedoIcon(state.EditMode, unit.Id)
                    ).PositionRelative().MarginBottom(5);
            },
                                            new HRowStyle()
                                            ),
                       DecorEdit.AdminUnitPanel(state.EditMode, main.Id)
                       ).Width(220));
        }
Example #15
0
        public static IHtmlControl GetFooterView(bool isMain)
        {
            return(new HPanel(
                       new HPanel(
                           new HPanel(
                               new HLabel("Создание сайта —").MarginRight(5).Color("#646565"),
                               new HLink("http://webkrokus.ru", "webkrokus.ru").TargetBlank()
                               ).PositionAbsolute().Top("50%").Left(0).MarginTop(-7),
                           std.Upbutton(UrlHlp.ImageUrl("upbutton.png")).Right(20),
                           HtmlHlp.UpbuttonScript(100, 26)
                           ).PositionRelative().Height(46).PaddingRight(8).Align(false)
                       //new HPanel(
                       //  new HLink("#top",
                       //    new HLabel("Наверх").FontBold(),
                       //    new HBefore().ContentIcon(10, 15).BackgroundImage(UrlHlp.ImageUrl("footer_upstair.png"))
                       //    .VAlign(-3).MarginRight(5)
                       //  ),
                       //  new HPanel(
                       //    new HLabel("Создание сайта —").MarginRight(5).Color("#646565"),
                       //    new HLink("http://webkrokus.ru", "КРОКУС").TargetBlank()
                       //  ).PositionAbsolute().Top(0).Right(10)
                       //    .MediaSmartfon(new HStyle().Right(5))
                       //).PositionRelative().WidthLimit("", isMain ? "930px" : "1020px")
                       ).Align(true).Background(Decor.panelBackground)
                   .MarginLeft(12).MarginRight(12).PaddingLeft(25).PaddingBottom(10)
                   .MediaTablet(new HStyle().PaddingLeft(10).MarginLeft(0).MarginRight(0)));

            //return new HPanel(
            //  new HPanel(
            //    new HLabel("Создание сайта –").Block(),
            //    new HPanel(
            //      new HLabel("web-студия").MarginRight(5),
            //      new HLabel("Крокус")
            //    )
            //  ).InlineBlock().Align(true).MarginTop(10).MarginRight(30)
            //).Align(false).Height(60).PositionRelative().Background(Decor.menuBackground)
            //.Color(Decor.menuColor).LineHeight(16);
        }
Example #16
0
 public static IHtmlControl GetHeader(HttpContext httpContext, SiteState state,
                                      LightObject currentUser, string kind, int?id, bool isForum)
 {
     return(new HPanel(
                new HPanel(
                    new HLink("/",
                              new HPanel(
                                  new HImage(UrlHlp.ImageUrl("logo.gif"))
                                  .MediaTablet(new HStyle().Display("none")),
                                  new HImage(UrlHlp.ImageUrl("ball.jpg")).Display("none")
                                  .MediaTablet(new HStyle().InlineBlock())
                                  )
                              ).PositionAbsolute().Top(11).Left(15)
                    .MediaSmartfon(new HStyle().Left(5)),
                    ViewHeaderHlp.GetAuthBlock(httpContext, state, currentUser)
                    ).PositionRelative().BoxSizing().Height(55).Align(false)
                .Padding(11, 15).MarginLeft(12).MarginRight(12)
                .Background(Decor.panelBackground)
                .MediaTablet(new HStyle().MarginLeft(0).MarginRight(0))
                .MediaSmartfon(new HStyle().PaddingLeft(5).PaddingRight(5)),
                ViewHeaderHlp.GetMenu(state, currentUser, kind, id, isForum)
                ));
 }
Example #17
0
 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));
 }
Example #18
0
        public static IHtmlControl GetForumSectionView(SiteState state, LightObject currentUser, LightSection section)
        {
            LightHead[] topics = context.Forum.ForSection(section.Id).Topics;

            IHtmlControl addPanel = null;

            if (currentUser != null)
            {
                addPanel = GetTopicAddPanel(state, currentUser, section);
            }

            return(new HPanel(
                       Decor.Title(section.Get(SectionType.Title)).MarginBottom(15),
                       new HPanel(
                           new HLink("/forum", "Форумы")
                           ).MarginBottom(25),
                       //new HPanel(
                       //  new HLink("/forum", "Форумы"),
                       //  ArrowElement(),
                       //  new HLabel(section.Get(SectionType.Title))
                       //).MarginBottom(10),
                       addPanel,
                       new HGrid <LightHead>(topics, delegate(LightHead topic)
            {
                TopicStorage topicStorage = context.Forum.TopicsStorages.ForTopic(topic.Id);
                //int publisherId = topicStorage.Topic.Get(TopicType.PublisherId);
                //LightObject user = context.UserStorage.FindUser(publisherId);

                RowLink lastMessage = _.Last(topicStorage.MessageLink.AllRows);
                LightObject lastUser = FindUserForMessage(lastMessage);

                return new HPanel(
                    new HPanel(
                        new HLink(string.Format("{0}?page=last", UrlHlp.ShopUrl("topic", topic.Id)),
                                  topic.Get(TopicType.Title)
                                  ).FontBold()
                        ).RelativeWidth(55).Padding(8, 5, 9, 5).BorderRight(Decor.columnBorder)
                    .MediaTablet(new HStyle().Block().Width("auto")),
                    //new HPanel(
                    //  new HLink(UrlHlp.ShopUrl("user", publisherId),
                    //    user?.Get(UserType.Login)
                    //  ).FontBold()
                    //).Align(null),
                    new HPanel(
                        new HLabel(topicStorage.MessageLink.AllRows.Length)
                        ).Align(null).RelativeWidth(10).PaddingTop(8).PaddingBottom(9).BorderRight(Decor.columnBorder)
                    .MediaTablet(new HStyle().Width(50).PaddingTop(0)),
                    new HPanel(
                        new HLink(UrlHlp.ShopUrl("user", lastUser?.Id),
                                  lastUser?.Get(UserType.Login)
                                  ),
                        new HLabel(
                            lastMessage?.Get(MessageType.CreateTime).ToLocalTime().ToString(Decor.timeFormat)
                            ).MarginLeft(7).MarginRight(7),
                        new HLink(
                            string.Format("{0}?page=last#bottom", UrlHlp.ShopUrl("topic", topic.Id)),
                            new HImage("/images/full.gif")
                            )
                        ).RelativeWidth(35).Padding(0, 5)
                    .MediaTablet(new HStyle().Width("auto"))
                    );
            },
                                             new HRowStyle().Even(new HTone().Background(Decor.evenBackground))
                                             ).BorderBottom(Decor.bottomBorder).MarginBottom(10)
                       ));
        }
Example #19
0
 static IHtmlControl ArrowElement()
 {
     return(new HImage(UrlHlp.ImageUrl("arrow.png")).MarginLeft(5).MarginRight(5).MarginBottom(2));
 }
Example #20
0
        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
                       ));
        }
Example #21
0
        public BasketballContext(string rootPath,
                                 EditorSelector sectionEditorSelector, EditorSelector unitEditorSelector,
                                 IDataLayer userConnection, IDataLayer fabricConnection,
                                 IDataLayer messageConnection, IDataLayer forumConnection)
        {
            this.rootPath              = rootPath;
            this.imagesPath            = Path.Combine(RootPath, "Images");
            this.userConnection        = userConnection;
            this.fabricConnection      = fabricConnection;
            this.messageConnection     = messageConnection;
            this.forumConnection       = forumConnection;
            this.sectionEditorSelector = sectionEditorSelector;
            this.unitEditorSelector    = unitEditorSelector;

            this.userStorage     = new UserStorage(userConnection);
            this.NewsStorages    = new TopicStorageCache(fabricConnection, messageConnection, NewsType.News);
            this.ArticleStorages = new TopicStorageCache(fabricConnection, messageConnection, ArticleType.Article);
            this.Forum           = new ForumStorageCache(fabricConnection, forumConnection);

            string settingsPath = Path.Combine(rootPath, "SiteSettings.config");

            if (!File.Exists(settingsPath))
            {
                this.siteSettings = new SiteSettings();
            }
            else
            {
                this.siteSettings = XmlSerialization.Load <SiteSettings>(settingsPath);
            }

            this.pull = new TaskPull(
                new ThreadLabel[] { Labels.Service },
                TimeSpan.FromMinutes(15)
                );

            this.newsCache = new Cache <Tuple <ObjectHeadBox, LightHead[]>, long>(
                delegate
            {
                ObjectHeadBox newsBox = new ObjectHeadBox(fabricConnection,
                                                          string.Format("{0} order by act_from desc", DataCondition.ForTypes(NewsType.News))
                                                          );

                int[] allNewsIds = newsBox.AllObjectIds;

                List <LightHead> actualNews = new List <LightHead>();
                for (int i = 0; i < Math.Min(22, allNewsIds.Length); ++i)
                {
                    int newsId = allNewsIds[i];
                    actualNews.Add(new LightHead(newsBox, newsId));
                }

                return(_.Tuple(newsBox, actualNews.ToArray()));
            },
                delegate { return(newsChangeTick); }
                );

            this.articlesCache = new Cache <Tuple <ObjectBox, LightObject[]>, long>(
                delegate
            {
                ObjectBox articleBox = new ObjectBox(fabricConnection,
                                                     string.Format("{0} order by act_from desc", DataCondition.ForTypes(ArticleType.Article))
                                                     );

                int[] allArticleIds = articleBox.AllObjectIds;

                ObjectBox actualBox = new ObjectBox(FabricConnection,
                                                    string.Format("{0} order by act_from desc limit 5", DataCondition.ForTypes(ArticleType.Article))
                                                    );

                List <LightObject> actualArticles = new List <LightObject>();
                foreach (int articleId in actualBox.AllObjectIds)
                {
                    actualArticles.Add(new LightObject(actualBox, articleId));
                }

                return(_.Tuple(articleBox, actualArticles.ToArray()));
            },
                delegate { return(articleChangeTick); }
                );

            this.lightStoreCache = new Cache <IStore, long>(
                delegate
            {
                LightObject contacts = DataBox.LoadOrCreateObject(fabricConnection,
                                                                  ContactsType.Contacts, ContactsType.Kind.CreateXmlIds, "main");

                LightObject seo = DataBox.LoadOrCreateObject(fabricConnection,
                                                             SEOType.SEO, SEOType.Kind.CreateXmlIds, "main");

                SectionStorage sections = SectionStorage.Load(fabricConnection);

                WidgetStorage widgets = WidgetStorage.Load(fabricConnection, siteSettings.DisableScripts);

                RedirectStorage redirects = RedirectStorage.Load(fabricConnection);

                SiteStore store = new SiteStore(sections, null, widgets, redirects, contacts, seo);
                store.Links.AddLink("register", null);
                store.Links.AddLink("passwordreset", null);

                return(store);
            },
                delegate { return(dataChangeTick); }
                );

            this.lastPublicationCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = messageConnection.GetTable("",
                                                             "Select Distinct article_id From message order by create_time desc limit 10"
                                                             );

                List <RowLink> lastComments = new List <RowLink>(10);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    if (News.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = NewsStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                    else if (Articles.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = ArticleStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(publicationCommentChangeTick); }
                );

            this.lastForumCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = forumConnection.GetTable("",
                                                           "Select Distinct article_id From message order by create_time desc limit 7"
                                                           );

                List <RowLink> lastComments = new List <RowLink>(7);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    TopicStorage topic  = Forum.TopicsStorages.ForTopic(topicId);
                    RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                    if (lastMessage != null)
                    {
                        lastComments.Add(lastMessage);
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(forumCommentChangeTick); }
                );

            this.tagsCache = new Cache <TagStore, long>(
                delegate
            {
                ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

                return(new TagStore(tagBox));
            },
                delegate { return(tagChangeTick); }
                );

            //this.tagsCache = new Cache<Tuple<ObjectHeadBox, Dictionary<string, int>>, long>(
            //  delegate
            //  {
            //    ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

            //    Dictionary<string, int> tagIdByKey = new Dictionary<string, int>();
            //    foreach (int tagId in tagBox.AllObjectIds)
            //    {
            //      string tagName = TagType.DisplayName.Get(tagBox, tagId);
            //      if (StringHlp.IsEmpty(tagName))
            //        continue;

            //      string tagKey = tagName.ToLower();
            //      tagIdByKey[tagKey] = tagId;
            //    }

            //    return _.Tuple(tagBox, tagIdByKey);
            //  },
            //  delegate { return tagChangeTick; }
            //);

            this.unreadDialogCache = new Cache <TableLink, long>(
                delegate
            {
                return(DialogueHlp.LoadUnreadLink(forumConnection));
            },
                delegate { return(unreadChangeTick); }
                );

            Pull.StartTask(Labels.Service,
                           SiteTasks.SitemapXmlChecker(this, rootPath,
                                                       delegate(LinkInfo[] sectionlinks)
            {
                List <LightLink> allLinks = new List <LightLink>();
                allLinks.AddRange(
                    ArrayHlp.Convert(sectionlinks, delegate(LinkInfo link)
                {
                    return(new LightLink(link.Directory, null));
                })
                    );

                foreach (int articleId in Articles.AllObjectIds)
                {
                    LightHead article = new LightHead(Articles, articleId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("article", articleId),
                                      article.Get(ObjectType.ActTill) ?? article.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                foreach (int newsId in News.AllObjectIds)
                {
                    LightHead news = new LightHead(News, newsId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("news", newsId),
                                      news.Get(ObjectType.ActTill) ?? news.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                //foreach (int tagId in Tags.AllObjectIds)
                //{
                //  LightHead tag = new LightHead(Tags, tagId);
                //  allLinks.Add(
                //    new LightLink(string.Format("/tags?tag={0}", tagId)
                //    )
                //  );
                //}

                return(allLinks.ToArray());
            }
                                                       )
                           );
        }
Example #22
0
        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);
        }
Example #23
0
        public static IHtmlControl GetActualArticleBlock(SiteState state, LightObject currentUser)
        {
            IHtmlControl[] items = ViewArticleHlp.GetArticleItems(state, context.ActualArticles);

            HPanel editBlock = null;

            if (state.BlockHint == "articleAdd")
            {
                editBlock = new HPanel(
                    Decor.PropertyEdit("addArticleTitle", "Заголовок статьи"),
                    Decor.Button("Добавить статью").MarginTop(10)
                    .Event("article_add_save", "addArticleData",
                           delegate(JsonData json)
                {
                    string title = json.GetText("addArticleTitle");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    ObjectBox editBox = new ObjectBox(context.FabricConnection, "1=0");

                    int addArticleId = editBox.CreateObject(
                        ArticleType.Article, ArticleType.Title.CreateXmlIds(title), DateTime.UtcNow
                        );
                    LightObject editArticle = new LightObject(editBox, addArticleId);

                    editArticle.Set(ArticleType.PublisherId, currentUser.Id);

                    editBox.Update();
                    context.UpdateArticles();

                    state.BlockHint = "";

                    state.RedirectUrl = UrlHlp.ShopUrl("article", addArticleId);
                }
                           )
                    ).EditContainer("addArticleData")
                            .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            HButton addButton = null;

            if (currentUser != null && !BasketballHlp.NoRedactor(currentUser))
            {
                addButton = Decor.Button("Добавить").Hide(currentUser == null).MarginLeft(10)
                            .Event("article_add", "", delegate
                {
                    state.SetBlockHint("articleAdd");
                }
                                   );
            }

            return(new HPanel(
                       Decor.Subtitle("Статьи").MarginBottom(12),
                       new HPanel(
                           items.ToArray()
                           ),
                       new HPanel(
                           new HLink("/stati",
                                     "Все статьи",
                                     new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2)
                                     ).FontBold(),
                           addButton
                           ).MarginTop(15),
                       editBlock
                       ).MarginTop(10));
        }
Example #24
0
        public static IHtmlControl GetActualNewsBlock(SiteState state, LightObject currentUser)
        {
            IHtmlControl[] items = ViewNewsHlp.GetNewsItems(state, context.ActualNews);

            HPanel editBlock = null;
            string editHint  = "news_add";

            if (state.BlockHint == editHint)
            {
                if (state.Tag == null)
                {
                    state.Tag = new List <string>();
                }

                string unsaveText = BasketballHlp.AddCommentFromCookie();

                editBlock = new HPanel(
                    Decor.PropertyEdit("newsTitle", "Заголовок новости"),
                    new HPanel(
                        HtmlHlp.CKEditorCreate("newsText", unsaveText, "300px", true)
                        ),
                    ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, true),
                    Decor.PropertyEdit("newsOriginName", "Источник"),
                    Decor.PropertyEdit("newsOriginUrl", "Ссылка"),
                    Decor.Button("Добавить новость").MarginTop(10) //.CKEditorOnUpdateAll()
                    .OnClick(string.Format("CK_updateAll(); {0}", BasketballHlp.AddCommentToCookieScript("newsText")))
                    .Event("save_news_add", "addNewsData",
                           delegate(JsonData json)
                {
                    string title      = json.GetText("newsTitle");
                    string text       = json.GetText("newsText");
                    string originName = json.GetText("newsOriginName");
                    string originUrl  = json.GetText("newsOriginUrl");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    ParentBox editBox = new ParentBox(context.FabricConnection, "1=0");

                    int addNewsId        = editBox.CreateObject(NewsType.News, NewsType.Title.CreateXmlIds(title), DateTime.UtcNow);
                    LightParent editNews = new LightParent(editBox, addNewsId);

                    editNews.Set(NewsType.PublisherId, currentUser.Id);
                    editNews.Set(NewsType.Text, text);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    ViewTagHlp.SaveTags(context, state, editNews);

                    editBox.Update();

                    context.UpdateNews();

                    state.BlockHint = "";
                    state.Tag       = null;

                    BasketballHlp.ResetAddComment();
                }
                           )
                    ).EditContainer("addNewsData").Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            IHtmlControl addButton = null;

            if (currentUser != null && !BasketballHlp.NoRedactor(currentUser))
            {
                addButton = Decor.Button("Добавить").MarginLeft(10)
                            .Event("news_add", "", delegate
                {
                    state.Tag = null;
                    state.SetBlockHint(editHint);
                }
                                   );
            }

            return(new HPanel(
                       Decor.Subtitle("Новости"),
                       new HPanel(
                           items.ToArray()
                           ),
                       new HPanel(
                           new HLink("/novosti",
                                     "Все новости",
                                     new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2)
                                     ).FontBold(),
                           addButton
                           ).MarginTop(15),
                       editBlock
                       ));
        }
Example #25
0
        static HElement Page(HttpContext httpContext, SiteState state, string kind, int?id)
        {
            UserHlp.DirectAuthorization(httpContext, SiteContext.Default.SiteSettings);

            LightObject currentUser = UserHlp.GetCurrentUser(httpContext, SiteContext.Default.UserStorage);

            if (currentUser != null && (BasketballHlp.IsBanned(currentUser) || currentUser.Get(UserType.NotConfirmed)))
            {
                currentUser = null;
                httpContext.Logout();
            }

            state.EditMode = httpContext.IsInRole("edit");
            state.SeoMode  = httpContext.IsInRole("seo");
            state.UserMode = currentUser != null;

            int[] foundTagIds = state.Option.Get(OptionType.FoundTagIds);
            if (foundTagIds != null && foundTagIds.Length > 0)
            {
                kind = "search";
                id   = null;
            }

            IHtmlControl adminSectionPanel = null;

            if (kind == "page")
            {
                LightSection section = store.Sections.FindSection(id);
                adminSectionPanel = DecorEdit.AdminSectionPanel(
                    state.EditMode, state.SeoMode, kind, section, false
                    );
            }

            IHtmlControl dialogBox = null;

            if (!StringHlp.IsEmpty(state.Operation.Message))
            {
                dialogBox = DecorEdit.GetDialogBox(state);
            }

            bool isForum = kind == "topic";

            if (kind == "page")
            {
                LightSection pageSection = store.Sections.FindSection(id);
                string       designKind  = pageSection.Get(SectionType.DesignKind);
                if (pageSection != null && (designKind == "forum" || designKind == "forumSection"))
                {
                    isForum = true;
                }
            }


            string    title       = "";
            string    description = "";
            SchemaOrg schema      = null;
            bool      wideContent;

            IHtmlControl centerView = ViewHlp.GetCenter(httpContext,
                                                        state, currentUser, kind, id, out title, out description, out schema, out wideContent
                                                        );

            if (centerView == null && StringHlp.IsEmpty(state.RedirectUrl))
            {
                return(null);
            }

            BasketballContext context = (BasketballContext)SiteContext.Default;

            try
            {
                if (currentUser != null && kind == "dialog" && id != null)
                {
                    if (context.UnreadDialogLink.FindRow(DialogReadType.UnreadByUserId, currentUser.Id) != null)
                    {
                        DialogueHlp.MarkReadCorrespondence(context.ForumConnection, currentUser.Id, id.Value);
                        context.UpdateUnreadDialogs();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
            }

            HEventPanel mainPanel = new HEventPanel(
                new HPanel(
                    new HAnchor("top"),
                    DecorEdit.AdminMainPanel(SiteContext.Default.SiteSettings, httpContext),
                    ViewHeaderHlp.GetHeader(httpContext, state, currentUser, kind, id, isForum),
                    adminSectionPanel,
                    new HPanel(
                        new HPanel(
                            centerView,
                            new HPanel(
                                ViewRightColumnHlp.GetRightColumnView(state, isForum).InlineBlock().MarginRight(15)
                                .MediaLaptop(new HStyle().Block().MarginRight(0))
                                .MediaTablet(new HStyle().InlineBlock().MarginRight(15))
                                .MediaSmartfon(new HStyle().Width("100%").MarginRight(0)),
                                ViewRightColumnHlp.GetReclameColumnView(state).InlineBlock().VAlign(true)
                                ).Hide(wideContent).PositionAbsolute().Top(13).Right(15)
                            .MediaTablet(new HStyle().Position("static").MarginTop(15))
                            //.MediaSmartfon(new HStyle().Width("100%"))
                            ).PositionRelative().Align(true)
                        .Padding(15).PaddingRight(485)
                        .WidthLimit("", kind == "" ? "727px" : "892px")
                        .MediaLaptop(new HStyle().PaddingRight(250))
                        .MediaTablet(new HStyle().PaddingRight(15))
                        .MediaSmartfon(new HStyle().PaddingLeft(5).PaddingRight(5))
                        ).MarginLeft(12).MarginRight(12).PaddingBottom(160).Background(Decor.panelBackground)
                    .BoxSizing().HeightLimit("900px", "")
                    .MediaTablet(new HStyle().MarginLeft(0).MarginRight(0))
                    ),
                ViewHlp.GetFooterView(kind == ""),
                dialogBox
                //popupPanel
                ).Width("100%").BoxSizing().Align(null).Background(Decor.pageBackground)
                                    .Padding(1)
                                    .FontFamily("Tahoma").FontSize(12); //.Color(Decor.textColor);

            if (!StringHlp.IsEmpty(state.PopupHint) || dialogBox != null)
            {
                mainPanel.OnClick(";");
                mainPanel.Event("popup_reset", "", delegate
                {
                    state.PopupHint = "";
                    state.Operation.Reset();
                });
            }

            StringBuilder css = new StringBuilder();

            std.AddStyleForFileUploaderButtons(css);

            HElement mainElement = mainPanel.ToHtml("main", css);

            SiteSettings settings = SiteContext.Default.SiteSettings;

            //string blockHint = state.BlockHint;
            //bool withCkeditor = false;
            //if (!StringHlp.IsEmpty(blockHint))
            //{
            //  withCkeditor = blockHint == "news_add" || blockHint.StartsWith("article_edit_") ||
            //    blockHint.StartsWith("news_edit_");
            //}
            //bool withFileuploader = kind == "user" || withCkeditor;

            return(h.Html
                   (
                       h.Head(
                           h.Element("title", title),
                           h.MetaDescription(description),
                           h.LinkCss(UrlHlp.FileUrl("/css/static.css")),
                           h.LinkShortcutIcon("/images/favicon.ico"),
                           h.Meta("viewport", "width=device-width"),
                           //h.LinkCss("/css/font-awesome.css"),
                           //h.LinkCss("/css/fileuploader.css"),
                           h.LinkScript("/scripts/fileuploader.js"),
                           h.LinkScript("/ckeditor/ckeditor.js?v=4113"),
                           HtmlHlp.CKEditorUpdateAll(),
                           h.Raw(store.SeoWidgets.WidgetsCode),
                           HtmlHlp.SchemaOrg(schema),
                           h.OpenGraph("type", "website"),
                           h.OpenGraph("title", title),
                           h.OpenGraph("url", description),
                           h.OpenGraph("site_name", settings.Organization),
                           h.OpenGraph("image", settings.FullUrl("/images/logo_mini.jpg"))
                           ),
                       h.Body(
                           h.Css(h.Raw(css.ToString())),
                           h.Div(
                               HtmlHlp.RedirectScript(state.RedirectUrl)
                               ),
                           //h.Div(
                           //  withFileuploader ? h.LinkScript("/scripts/fileuploader.js") : null,
                           //  withCkeditor ? h.LinkScript("/ckeditor/ckeditor.js") : null,
                           //  withCkeditor ? HtmlHlp.CKEditorUpdateAll() : null
                           //),
                           mainElement
                           //withEditor ? h.Script(h.type("text/javascript"), "console.log('withScript');") : null,
                           //!withFileuploader && withEditor ? h.LinkScript("/scripts/fileuploader.js") : null,
                           //withEditor ? h.LinkScript("/ckeditor/ckeditor.js") : null,
                           //withEditor ? HtmlHlp.CKEditorUpdateAll() : null
                           //HtmlHlp.SchemaOrg(schema),
                           )
                   ));
        }
Example #26
0
        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"));
        }
Example #27
0
        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);
        }
Example #28
0
        public static IHtmlControl GetCommentElement(int commentCount, string newsUrl)
        {
            IHtmlControl innerElement = GetInnerCommentElement(commentCount, newsUrl);

            return(new HPanel(
                       new HLabel("(").MarginLeft(5),
                       innerElement,
                       new HLabel(")"),
                       new HLink(string.Format("{0}#bottom", newsUrl),
                                 "", new HBefore().ContentIcon(5, 10).BackgroundImage(UrlHlp.ImageUrl("bottom.png")).VAlign(-2)
                                 ).PaddingLeft(3).PaddingRight(3).MarginLeft(5).Title("к последним комментариям").Hide(commentCount < 4)
                       ).InlineBlock());
        }
Example #29
0
        public static IHtmlControl GetAuthBlock(HttpContext httpContext, SiteState state, LightObject currentUser)
        {
            HImage keyImage = new HImage(UrlHlp.ImageUrl("key.gif")).MarginRight(8).VAlign(false);

            if (currentUser == null)
            {
                return(new HPanel(
                           keyImage,
                           new HTextEdit("authLogin").Width(90).MarginRight(5),
                           new HPasswordEdit("authPassword").Width(90).MarginRight(5),
                           Decor.Button("Войти").Event("user_login", "loginData", delegate(JsonData json)
                {
                    string login = json.GetText("authLogin");
                    string password = json.GetText("authPassword");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(login, "Введите логин"))
                    {
                        return;
                    }

                    if (!operation.Validate(password, "Введите пароль"))
                    {
                        return;
                    }

                    string xmlLogin = UserType.Login.CreateXmlIds("", login);
                    LightObject user = SiteContext.Default.UserStorage.FindUser(xmlLogin);
                    if (!operation.Validate(user == null, "Логин не найден"))
                    {
                        return;
                    }
                    if (!operation.Validate(user.Get(UserType.Password) != password, "Неверный пароль"))
                    {
                        return;
                    }

                    if (!operation.Validate(user.Get(UserType.NotConfirmed), "Ваш аккаунт не подтвержден через электронную почту. Письмо для подтверждения выслано вам на почту еще раз."))
                    {
                        try
                        {
                            BasketballHlp.SendRegistrationConfirmation(user.Id, login, user.Get(UserType.Email));
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteException(ex);
                        }
                        return;
                    }

                    if (!operation.Validate(BasketballHlp.IsBanned(user),
                                            string.Format("Вы заблокированы до {0} и не можете войти на сайт",
                                                          user.Get(BasketballUserType.BannedUntil)?.ToLocalTime().ToString("dd-MM-yyyy HH:mm")
                                                          )
                                            ))
                    {
                        return;
                    }


                    httpContext.SetUserAndCookie(xmlLogin);
                }
                                                       ),
                           new HPanel(
                               new HPanel(new HLink("/register", "Регистрация"))
                               .MediaSmartfon(new HStyle().InlineBlock()),
                               new HPanel(new HLink("/passwordreset", "Забыли пароль"))
                               .MediaSmartfon(new HStyle().InlineBlock().MarginLeft(10))
                               ).Align(true).InlineBlock().MarginLeft(5).FontSize("80%").VAlign(false)
                           .MediaSmartfon(new HStyle().Block().MarginLeft(18))
                           ).EditContainer("loginData").PositionRelative().InlineBlock().MarginTop(10)
                       .MediaTablet(new HStyle().MarginTop(5))
                       .MediaSmartfon(new HStyle().MarginTop(0)));
            }

            HButton moderatorButton = null;

            if (currentUser.Get(BasketballUserType.IsModerator))
            {
                moderatorButton = new HButton("",
                                              std.BeforeAwesome(@"\f1e2", 0)
                                              ).Title("Режим модерирования").MarginRight(3).MarginLeft(5).FontSize(14)
                                  .Color(state.ModeratorMode ? Decor.redColor : Decor.disabledColor)
                                  .Event("moderator_mode_set", "", delegate
                {
                    state.ModeratorMode = !state.ModeratorMode;
                });
            }

            return(new HPanel(
                       keyImage,
                       new HLabel("Здравствуйте,").MarginRight(5),
                       new HLink(UrlHlp.ShopUrl("user", currentUser.Id), currentUser.Get(UserType.FirstName)).FontBold(),
                       new HLabel("!"),
                       moderatorButton,
                       Decor.Button("Выйти").MarginLeft(5).Event("user_logout", "", delegate(JsonData json)
            {
                httpContext.Logout();
            }
                                                                 )
                       ).InlineBlock().MarginTop(10));
        }