예제 #1
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)));
        }
예제 #2
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)
                ));
 }
예제 #3
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),
                           )
                   ));
        }