public static IHtmlControl GetUserView(SiteState state, LightObject currentUser, LightObject user) { string communityMember = user.Get(BasketballUserType.CommunityMember); bool isModerator = user.Get(BasketballUserType.IsModerator); DateTime?bannedUntil = user.Get(BasketballUserType.BannedUntil); DateTime?noRedactorUntil = user.Get(BasketballUserType.NotRedactorUntil); string bannedUntilStr = ""; if (bannedUntil != null && bannedUntil > DateTime.UtcNow) { bannedUntilStr = bannedUntil.Value.ToLocalTime().ToString(Decor.timeFormat); } string noRedactorUntilStr = ""; if (noRedactorUntil != null && noRedactorUntil > DateTime.UtcNow) { noRedactorUntilStr = noRedactorUntil.Value.ToLocalTime().ToString(Decor.timeFormat); } IHtmlControl[] rows = new IHtmlControl[] { UserField("Имя", ValueLabel(user.Get(UserType.FirstName)).FontBold()), UserField("Дата регистрации", ValueLabel(user.Get(ObjectType.ActFrom)?.ToLocalTime().ToString(Decor.timeFormat)) ), !StringHlp.IsEmpty(communityMember) ? UserField("На basketball.ru c", ValueLabel(communityMember)) : null, UserField("Страна", ValueLabel(user.Get(BasketballUserType.Country))), UserField("Город", ValueLabel(user.Get(BasketballUserType.City))), UserField("Интересы", ValueLabel(user.Get(BasketballUserType.Interests))), UserField("О себе", ValueLabel(user.Get(BasketballUserType.AboutMe))), UserField("Статус", ValueLabel("Модератор").FontBold()).Hide(!isModerator), UserField("Заблокирован до", ValueLabel(bannedUntilStr).FontBold()).Hide(StringHlp.IsEmpty(bannedUntilStr)), UserField("Не добавляет до", ValueLabel(noRedactorUntilStr).FontBold()).Hide(StringHlp.IsEmpty(noRedactorUntilStr)) }; int i = -1; foreach (IHtmlControl row in rows) { if (row == null) { continue; } ++i; if (i % 2 == 0) { row.Background(Decor.pageBackground); } } IHtmlControl redoAvatarPanel = null; IHtmlControl editPanel = null; if (currentUser != null && currentUser.Id == user.Id) { redoAvatarPanel = GetRedoAvatarPanel(user); editPanel = GetUserEditPanel(state, user); } IHtmlControl adminPanel = null; if (state.EditMode) { adminPanel = GetAdminPanel(user); } IHtmlControl moderatorPanel = null; if (state.ModeratorMode) { moderatorPanel = GetModeratorPanel(user); } return(new HPanel( Decor.Title(user.Get(UserType.Login)), new HPanel( AvatarBlock(user).PositionAbsolute().Left(12).Top("50%").MarginTop(-25), new HPanel( rows ).Padding(1).Border("1px solid #eeeeee") ).PositionRelative().BoxSizing().WidthLimit("", "480px").PaddingLeft(74), ViewDialogueHlp.GetAddPanel(context, state, currentUser, user, true), redoAvatarPanel, editPanel, adminPanel, moderatorPanel )); }
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); }