Exemple #1
0
        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);
        }
Exemple #2
0
        static IHtmlControl GetNewsEditPanel(SiteState state, TopicStorage topic)
        {
            LightObject news = topic.Topic;

            string blockHint = string.Format("news_edit_{0}", news.Id);

            IHtmlControl redoPanel = null;

            if (state.BlockHint == blockHint)
            {
                IHtmlControl deletePanel = null;
                if (state.ModeratorMode)
                {
                    deletePanel = DeleteTopicPanel(state, topic);
                }

                if (state.Tag == null)
                {
                    state.Tag = ViewTagHlp.GetTopicDisplayTags(context.Tags.TagBox, topic.Topic);
                }

                redoPanel = new HPanel(
                    deletePanel,
                    Decor.PropertyEdit("newsTitle", "Заголовок новости", news.Get(NewsType.Title)),
                    new HPanel(
                        HtmlHlp.CKEditorCreate("newsText", news.Get(NewsType.Text), "300px", true)
                        ),
                    ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, false),
                    Decor.PropertyEdit("newsOriginName", "Источник", news.Get(NewsType.OriginName)),
                    Decor.PropertyEdit("newsOriginUrl", "Ссылка", news.Get(NewsType.OriginUrl)),
                    Decor.Button("Изменить новость").CKEditorOnUpdateAll().MarginTop(10)
                    .Event("save_news_edit", "editNewsData",
                           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;
                    }

                    LightKin editNews = DataBox.LoadKin(context.FabricConnection, NewsType.News, news.Id);

                    editNews.SetWithoutCheck(NewsType.Title, title);

                    editNews.Set(NewsType.Text, text);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    editNews.Set(ObjectType.ActTill, DateTime.UtcNow);

                    ViewTagHlp.SaveTags(context, state, editNews);

                    editNews.Box.Update();

                    context.UpdateNews();
                    context.NewsStorages.ForTopic(news.Id).UpdateTopic();

                    state.BlockHint = "";
                },
                           news.Id
                           )
                    ).EditContainer("editNewsData")
                            .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            return(new HPanel(
                       Decor.Button("Редактировать")
                       .Event("news_edit", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       redoPanel
                       ).MarginTop(10));
        }
Exemple #3
0
        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
                       ));
        }
Exemple #4
0
        public static Func <object, JsonData[], HttpRequestMessage, HtmlResult <HElement> > HViewCreator(
            string kind, int?id)
        {
            return(delegate(object _state, JsonData[] jsons, HttpRequestMessage context)
            {
                SiteState state = _state as SiteState;
                if (state == null)
                {
                    state = new SiteState();
                }

                LinkInfo link = null;
                if (kind == "news" || kind == "user" || (kind == "novosti" && id != null) ||
                    kind == "article" || kind == "topic" || kind == "tags" || kind == "dialog" || kind == "confirmation")
                {
                    link = new LinkInfo("", kind, id);
                }
                else
                {
                    if (StringHlp.IsEmpty(kind))
                    {
                        link = new LinkInfo("", "", null);
                    }
                    else if (id == null)
                    {
                        link = store.Links.FindLink(kind, "");
                        if (link == null)
                        {
                            link = store.Links.FindLink("page", kind);
                        }
                    }
                }

                if (link == null)
                {
                    return new HtmlResult
                    {
                        RawResponse = new HttpResponseMessage()
                        {
                            StatusCode = HttpStatusCode.NotFound
                        }
                    };
                }

                if (jsons.Length > 0)
                {
                    state.AccessTime = DateTime.UtcNow;
                }

                foreach (JsonData json in jsons)
                {
                    try
                    {
                        if (state.IsRattling(json))
                        {
                            continue;
                        }

                        try
                        {
                            string command = json.JPath("data", "command")?.ToString();
                            if (command != null && StringHlp.IsEmpty(state.BlockHint))
                            {
                                if (command.StartsWith("save_"))
                                {
                                    object id1 = json.JPath("data", "id1");

                                    string hint = command.Substring(5);
                                    if (id != null)
                                    {
                                        hint = string.Format("{0}_{1}", hint, id1);
                                    }
                                    state.BlockHint = hint;

                                    Logger.AddMessage("Restore: {0}", hint);
                                }
                                else if (command == "tag_add" && kind == "")
                                {
                                    state.BlockHint = "news_add";

                                    Logger.AddMessage("Restore: news_add");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteException(ex);
                        }

                        state.Operation.Reset();

                        HElement cachePage = Page(HttpContext.Current, state, link.Kind, link.Id);

                        hevent eventh = cachePage.FindEvent(json, true);
                        if (eventh != null)
                        {
                            eventh.Execute(json);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex);
                        state.Operation.Message = string.Format("Непредвиденная ошибка: {0}", ex.Message);
                    }
                }

                HElement page = Page(HttpContext.Current, state, link.Kind, link.Id);
                if (page == null)
                {
                    return new HtmlResult
                    {
                        RawResponse = new HttpResponseMessage()
                        {
                            StatusCode = HttpStatusCode.NotFound
                        }
                    };
                }
                return HtmlHlp.FirstHtmlResult(page, state, TimeSpan.FromHours(1));
            });
        }
Exemple #5
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),
                           )
                   ));
        }
Exemple #6
0
        static IHtmlControl GetArticleEditPanel(SiteState state, TopicStorage topic)
        {
            LightObject article = topic.Topic;

            string blockHint = string.Format("article_edit_{0}", article.Id);

            IHtmlControl redoPanel = null;

            if (state.BlockHint == blockHint)
            {
                IHtmlControl deletePanel = null;
                if (state.ModeratorMode)
                {
                    deletePanel = ViewNewsHlp.DeleteTopicPanel(state, topic);
                }

                redoPanel = new HPanel(
                    deletePanel,
                    new HPanel(
                        Decor.PropertyEdit("editArticleTitle", "Заголовок статьи", article.Get(NewsType.Title)),
                        new HPanel(
                            new HLabel("Аннотация").FontBold(),
                            new HTextArea("editArticleAnnotation", article.Get(NewsType.Annotation))
                            .Width("100%").Height("4em").MarginBottom(5)
                            ),
                        new HPanel(
                            new HInputCheck(
                                "editArticleWideContent", article.Get(ArticleType.WideContent),
                                new HAfter().Content("Таблицы шире колонки статьи").MarginLeft(18).MarginBottom(1)
                                ).NoWrap()
                            ).MarginBottom(5),
                        HtmlHlp.CKEditorCreate("editArticleText", article.Get(NewsType.Text), "300px", true),
                        Decor.PropertyEdit("editArticleAuthor", "Автор", article.Get(ArticleType.Author)),
                        Decor.PropertyEdit("editArticleOriginName", "Источник (без префикса http://)", article.Get(NewsType.OriginName)),
                        Decor.PropertyEdit("editArticleOriginUrl", "Ссылка (с префиксом http://)", article.Get(NewsType.OriginUrl)),
                        Decor.Button("Сохранить статью").CKEditorOnUpdateAll().MarginTop(10).MarginBottom(10)
                        .Event("save_article_edit", "editArticleData",
                               delegate(JsonData json)
                {
                    string title      = json.GetText("editArticleTitle");
                    string annotation = json.GetText("editArticleAnnotation");
                    bool wideContent  = json.GetBool("editArticleWideContent");
                    string text       = json.GetText("editArticleText");
                    string author     = json.GetText("editArticleAuthor");
                    string originName = json.GetText("editArticleOriginName");
                    string originUrl  = json.GetText("editArticleOriginUrl");

                    WebOperation operation = state.Operation;

                    if (!operation.Validate(title, "Не задан заголовок"))
                    {
                        return;
                    }

                    if (!operation.Validate(text, "Не задан текст"))
                    {
                        return;
                    }

                    LightObject editNews = DataBox.LoadObject(context.FabricConnection, ArticleType.Article, article.Id);

                    editNews.SetWithoutCheck(NewsType.Title, title);

                    editNews.Set(ArticleType.WideContent, wideContent);
                    editNews.Set(NewsType.Annotation, annotation);
                    editNews.Set(NewsType.Text, text);
                    editNews.Set(ArticleType.Author, author);
                    editNews.Set(NewsType.OriginName, originName);
                    editNews.Set(NewsType.OriginUrl, originUrl);

                    editNews.Set(ObjectType.ActTill, DateTime.UtcNow);

                    editNews.Box.Update();

                    context.UpdateArticles();
                    context.ArticleStorages.ForTopic(article.Id).UpdateTopic();

                    state.BlockHint = "";
                },
                               article.Id
                               )
                        ).EditContainer("editArticleData"),
                    new HPanel(
                        EditElementHlp.GetImageThumb(article.Id)
                        ),
                    new HPanel(
                        EditElementHlp.GetDescriptionImagesPanel(state.Option, article.Id)
                        )
                    ).Padding(5, 10).MarginTop(10).Background(Decor.pageBackground);
            }

            return(new HPanel(
                       Decor.Button("Редактировать")
                       .Event("article_edit", "", delegate
            {
                state.SetBlockHint(blockHint);
            }
                              ),
                       redoPanel
                       ).MarginTop(5));
        }