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%")); }
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()); }
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()); }
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)); }
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); }
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) )); }
static IHtmlControl ArrowElement() { return(new HImage(UrlHlp.ImageUrl("arrow.png")).MarginLeft(5).MarginRight(5).MarginBottom(2)); }
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 )); }
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()); }
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)); }
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 )); }
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)); }