Пример #1
0
        public static IHtmlControl GetAddPanel(BasketballContext context, SiteState state,
                                               LightObject user, LightObject collocutor, bool sendFromUserView)
        {
            if (user == null)
            {
                return(null);
            }

            if (user.Id == collocutor.Id)
            {
                return(null);
            }

            IHtmlControl editPanel = null;

            if (state.BlockHint == "messageAdd")
            {
                string commentValue = BasketballHlp.AddCommentFromCookie();

                editPanel = new HPanel(
                    new HTextArea("messageContent", commentValue).BoxSizing().Width("100%")
                    .Height("10em").MarginTop(5).MarginBottom(5),
                    Decor.Button("отправить")
                    .OnClick(BasketballHlp.AddCommentToCookieScript("messageContent"))
                    .Event("message_add_save", "messageData",
                           delegate(JsonData json)
                {
                    string content = json.GetText("messageContent");
                    if (StringHlp.IsEmpty(content))
                    {
                        return;
                    }

                    DialogueHlp.SendMessage(context, user.Id, collocutor.Id, content);

                    state.BlockHint = "";

                    BasketballHlp.ResetAddComment();

                    if (sendFromUserView)
                    {
                        state.Operation.Message = "Сообщение успешно отправлено";
                    }
                }
                           ),
                    new HElementControl(
                        h.Script(h.type("text/javascript"), "$('.messageContent').focus();"),
                        ""
                        )
                    ).EditContainer("messageData");
            }

            HButton moderatorButton = null;
            HPanel  moderatorPanel  = null;

            if (!sendFromUserView)
            {
                moderatorButton = new HButton("",
                                              std.BeforeAwesome(@"\f1e2", 0)
                                              ).PositionAbsolute().Right(5).Top(0)
                                  .Title("Модерирование личных сообщений").FontSize(14)
                                  .Color(state.BlockHint == correspondenceModeration ? Decor.redColor : Decor.disabledColor)
                                  .Event("correspondence_moderation_set", "", delegate
                {
                    state.SetBlockHint(correspondenceModeration);
                });

                if (state.BlockHint == correspondenceModeration)
                {
                    bool lockedCollocutor = user.Get(BasketballUserType.LockedUserIds, collocutor.Id);
                    moderatorPanel = new HPanel(
                        Decor.ButtonMidi(!lockedCollocutor ? "Заблокировать собеседника" : "Разблокировать собеседника")
                        .Event("collocutor_locked", "", delegate
                    {
                        LightObject editUser = DataBox.LoadObject(context.UserConnection, UserType.User, user.Id);
                        editUser.Set(BasketballUserType.LockedUserIds, collocutor.Id, !lockedCollocutor);
                        editUser.Box.Update();
                        context.UserStorage.Update();
                    }),
                        new HSpoiler(Decor.ButtonMidi("Удаление переписки").Block().FontBold(false),
                                     new HPanel(
                                         Decor.ButtonMidi("Удалить? (без подтверждения)")
                                         .MarginTop(5).MarginLeft(10)
                                         .Event("correspondence_delete", "", delegate
                    {
                        context.ForumConnection.GetScalar("",
                                                          "Delete From correspondence Where user_id = @userId and collocutor_id = @collocutorId",
                                                          new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                          );

                        context.ForumConnection.GetScalar("",
                                                          "Delete From dialogue Where user_id = @userId and collocutor_id = @collocutorId",
                                                          new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                          );

                        context.UpdateUnreadDialogs();
                    })
                                         )
                                     ).MarginTop(10)
                        ).MarginTop(10);
                }
            }

            bool locked = user.Get(BasketballUserType.LockedUserIds, collocutor.Id) ||
                          collocutor.Get(BasketballUserType.LockedUserIds, user.Id);

            return(new HPanel(
                       new HPanel(
                           Decor.ButtonMidi("Написать сообщение")
                           .Hide(locked)
                           .Event("message_add", "", delegate
            {
                state.SetBlockHint("messageAdd");
            }
                                  ),
                           new HLabel("Вы не можете отправить сообщение этому пользователю").Hide(!locked)
                           .MarginLeft(10).Color(Decor.subtitleColor),
                           moderatorButton
                           ).PositionRelative(),
                       editPanel,
                       moderatorPanel
                       ).MarginTop(10).MarginBottom(10));
        }
Пример #2
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);
        }
Пример #3
0
        public static IHtmlControl GetCorrespondenceView(SiteState state,
                                                         IDataLayer forumConnection, LightObject user, LightObject collocutor, out string title)
        {
            title = "Личные сообщения";

            int pageIndex    = state.Option.Get(OptionType.CorrespondencePageIndex);
            int messageCount = DatabaseHlp.RowCount(forumConnection, "", "correspondence",
                                                    "user_id = @userId and collocutor_id = @collocutorId",
                                                    new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                    );
            int pageCount = BinaryHlp.RoundUp(messageCount, 5);

            HButton prevButton = null;

            if (pageCount - 1 > pageIndex)
            {
                prevButton = Decor.ButtonMidi("предыдущие").Event("page_prev", "",
                                                                  delegate
                {
                    state.Option.Set(OptionType.CorrespondencePageIndex, pageIndex + 1);
                }
                                                                  );
            }

            HButton nextButton = null;

            if (pageIndex > 0)
            {
                nextButton = Decor.ButtonMidi("следующие").Event("page_next", "",
                                                                 delegate
                {
                    state.Option.Set(OptionType.CorrespondencePageIndex, pageIndex - 1);
                }
                                                                 );
            }

            TableLink messageLink = DialogueHlp.LoadCorrespondenceLink(forumConnection,
                                                                       string.Format("user_id = @userId and collocutor_id = @collocutorId order by create_time desc limit 5 offset {0}",
                                                                                     pageIndex * 5
                                                                                     ),
                                                                       new DbParameter("userId", user.Id), new DbParameter("collocutorId", collocutor.Id)
                                                                       );

            RowLink[]           messages      = messageLink.AllRows;
            List <IHtmlControl> messageBlocks = new List <IHtmlControl>();

            if (prevButton != null || nextButton != null)
            {
                messageBlocks.Add(
                    new HPanel(
                        new HPanel(prevButton), new HPanel(nextButton)
                        ).MarginTop(5).MarginBottom(5)
                    );
            }

            for (int i = messages.Length - 1; i >= 0; --i)
            {
                //if (i == 2)
                //  messageBlocks.Add(new HAnchor("bottom"));

                messageBlocks.Add(GetMessageBlock(forumConnection, state, user, collocutor, messages[i], i));
            }

            IHtmlControl addPanel = GetAddPanel(context, state, user, collocutor, false);

            return(new HPanel(
                       GetCorrespondenceHeader(state, user, collocutor),
                       new HPanel(
                           messageBlocks.ToArray()
                           ).BorderBottom(Decor.bottomBorder),
                       addPanel
                       ));
        }
        private HElement GetDebugResponse(SessionData sessionData)
        {
            HMultipleElements ret = new HMultipleElements();

            ret += new HText($"Current Response Count: {StringResponses.Count} ({CurrentStringResponseCacheSize * sizeof(char)} bytes).");

            if (MaximumStringResponseCacheSize > 0)
            {
                ret += new HText($"Cache Fillrate: {CurrentStringResponseCacheSize} / {MaximumStringResponseCacheSize} = {((CurrentStringResponseCacheSize / MaximumStringResponseCacheSize) * 100f):0.000}%.");

                string request;

                using (StringResponseLock.LockRead())
                {
                    if (sessionData.HttpHeadVariables.TryGetValue("key", out request))
                    {
                        ret += new HButton("Back to all entries", "?all=true");

                        ResponseCacheEntry <string> response;

                        if (StringResponses.TryGetValue(request, out response))
                        {
                            ret += new HHeadline($"Entry '{request}'", 2);
                            ret += new HText("Requested Times: " + response.Count);
                            ret += new HText("Response Length: " + response.Response.Length);
                            ret += new HText("Last Requested: " + response.LastRequestedDateTime);
                            ret += new HText("Last Updated Times: " + response.LastUpdatedDateTime);
                            ret += new HText("Lifetime: " + response.RefreshTime);

                            ret += new HLine();
                            ret += new HText("Contents:");

                            ret += new HText(response.Response)
                            {
                                Class = "code"
                            };
                        }
                        else
                        {
                            ret += new HText($"The requested entry '{request}' could not be found.")
                            {
                                Class = "error"
                            };
                        }
                    }
                    else if (sessionData.HttpHeadVariables.ContainsKey("all"))
                    {
                        ret += new HTable((from e in StringResponses
                                           select new object[] { e.Key, e.Value.Count, e.Value.Response.Length, e.Value.LastRequestedDateTime, e.Value.LastUpdatedDateTime, e.Value.RefreshTime, new HLink("Show Contents", "?key=" + e.Key.EncodeUrl()) }
                                           ).OrderByDescending(e => (int)(ulong)e[1] * (int)e[2]))
                        {
                            TableHeader = new string[] { "Key", "Request Count", "Response Length", "Last Request Time", "Last Updated Time", "Lifetime", "Contents" }
                        };
                    }
                    else
                    {
                        ret += new HButton("Show all entries (might take a long time to load)", HButton.EButtonType.button, "?all=true");
                    }
                }
            }

            return(ret);
        }
Пример #5
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));
        }
Пример #6
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"));
        }
Пример #7
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));
        }