public static IHtmlControl GetCenter(HttpContext httpContext, SiteState state, LightObject currentUser, string kind, int?id, out string title, out string description, out SchemaOrg schema, out bool wideContent) { title = ""; description = ""; schema = null; wideContent = false; SiteSettings settings = context.SiteSettings; switch (kind) { case "": { title = store.SEO.Get(SEOType.MainTitle); description = store.SEO.Get(SEOType.MainDescription); LightSection main = store.Sections.FindMenu("main"); return(ViewHlp.GetMainView(state, currentUser)); } case "news": { if (!context.News.ObjectById.Exist(id)) { return(null); } TopicStorage topicStorage = context.NewsStorages.ForTopic(id ?? 0); LightKin topic = topicStorage.Topic; //string tagsDisplay; IHtmlControl view = ViewNewsHlp.GetNewsView(state, currentUser, topicStorage, out description); title = topic.Get(NewsType.Title); //string postfix = ""; //if (!StringHlp.IsEmpty(tagsDisplay)) // postfix = ". "; //description = string.Format("{0}{1}Живое обсуждение баскетбольных событий на basketball.ru.com", // tagsDisplay, postfix //); string logoUrl = settings.FullUrl("/images/logo.gif"); schema = new SchemaOrg("NewsArticle", settings.FullUrl(UrlHlp.ShopUrl("news", id)), title, new string[] { logoUrl }, topic.Get(ObjectType.ActFrom), topic.Get(ObjectType.ActTill), topic.Get(TopicType.OriginName), settings.Organization, logoUrl, description ); return(view); } case "article": { if (!context.Articles.ObjectById.Exist(id)) { return(null); } TopicStorage topicStorage = context.ArticleStorages.ForTopic(id ?? 0); LightKin topic = topicStorage.Topic; title = topic.Get(ArticleType.Title); description = topic.Get(ArticleType.Annotation); string logoUrl = settings.FullUrl("/images/logo.gif"); schema = new SchemaOrg("Article", settings.FullUrl(UrlHlp.ShopUrl("article", id)), title, new string[] { logoUrl }, topic.Get(ObjectType.ActFrom), topic.Get(ObjectType.ActTill), topic.Get(TopicType.OriginName), settings.Organization, logoUrl, description ); wideContent = topic.Get(ArticleType.WideContent); return(ViewArticleHlp.GetArticleView(state, currentUser, topicStorage)); } case "topic": { TopicStorage topic = context.Forum.TopicsStorages.ForTopic(id ?? 0); title = topic.Topic.Get(TopicType.Title); int pageNumber = 0; { string pageArg = httpContext.Get("page"); int messageCount = topic.MessageLink.AllRows.Length; if (pageArg == "last" && messageCount > 0) { pageNumber = BinaryHlp.RoundUp(messageCount, ViewForumHlp.forumMessageCountOnPage) - 1; } else { pageNumber = ConvertHlp.ToInt(pageArg) ?? 0; } } return(ViewForumHlp.GetTopicView(state, currentUser, topic, pageNumber)); } case "tags": { int?tagId = httpContext.GetUInt("tag"); int pageNumber = httpContext.GetUInt("page") ?? 0; return(ViewNewsHlp.GetTagView(state, currentUser, tagId, pageNumber, out title, out description)); } case "search": { return(ViewNewsHlp.GetFoundTagListView(state, out title)); } case "user": { LightObject user = context.UserStorage.FindUser(id ?? -1); if (user == null) { return(null); } title = string.Format("{0} - Basketball.ru.com", user.Get(UserType.Login)); return(ViewUserHlp.GetUserView(state, currentUser, user)); } case "page": { LightSection section = store.Sections.FindSection(id); title = FabricHlp.GetSeoTitle(section, section.Get(SectionType.Title)); description = FabricHlp.GetSeoDescription(section, section.Get(SectionType.Annotation)); int pageNumber = httpContext.GetUInt("page") ?? 0; string designKind = section.Get(SectionType.DesignKind); switch (designKind) { case "news": { int[] allNewsIds = context.News.AllObjectIds; return(ViewNewsHlp.GetNewsListView(state, currentUser, pageNumber)); } case "articles": return(ViewArticleHlp.GetArticleListView(state, currentUser, pageNumber)); case "forum": return(ViewForumHlp.GetForumView(state, currentUser, section)); case "forumSection": return(ViewForumHlp.GetForumSectionView(state, currentUser, section)); default: return(null); } } case "dialog": { if (currentUser == null) { return(null); } if (id == null) { return(ViewDialogueHlp.GetDialogueView(state, context.ForumConnection, context.UserStorage, currentUser, out title )); } LightObject collocutor = context.UserStorage.FindUser(id.Value); if (collocutor == null) { return(null); } return(ViewDialogueHlp.GetCorrespondenceView(state, context.ForumConnection, currentUser, collocutor, out title )); } case "passwordreset": title = "Восстановление пароля - basketball.ru.com"; return(ViewHlp.GetRestorePasswordView(state)); case "register": title = "Регистрация - basketball.ru.com"; return(ViewHlp.GetRegisterView(state)); case "confirmation": { title = "Подтверждение аккаунта"; int? userId = httpContext.GetUInt("id"); string hash = httpContext.Get("hash"); if (userId == null) { return(ViewUserHlp.GetMessageView( "Вам выслано письмо с кодом активации. Чтобы завершить процедуру регистрации, пройдите по ссылке, указанной в письме, и учётная запись будет активирована. Если вы не получили письмо, то попробуйте войти на сайт со своим логином и паролем. Тогда письмо будет отправлено повторно." )); } if (StringHlp.IsEmpty(hash)) { return(null); } LightObject user = context.UserStorage.FindUser(userId.Value); if (userId == null) { return(null); } if (!user.Get(UserType.NotConfirmed)) { return(ViewUserHlp.GetMessageView("Пользователь успешно активирован")); } string login = user.Get(UserType.Login); string etalon = UserHlp.CalcConfirmationCode(user.Id, login, "bbbin"); if (hash?.ToLower() != etalon?.ToLower()) { return(ViewUserHlp.GetMessageView("Неверный хэш")); } LightObject editUser = DataBox.LoadObject(context.UserConnection, UserType.User, user.Id); editUser.Set(UserType.NotConfirmed, false); editUser.Box.Update(); context.UserStorage.Update(); string xmlLogin = UserType.Login.CreateXmlIds("", login); HttpContext.Current.SetUserAndCookie(xmlLogin); state.RedirectUrl = "/"; return(new HPanel()); } } return(null); }
static 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), ) )); }