static IHtmlControl GetTopicRedoPanel(SiteState state, LightObject currentUser, LightSection forumSection, TopicStorage topic) { string blockHint = string.Format("topic_edit_{0}", topic.TopicId); IHtmlControl redoPanel = null; if (state.BlockHint == blockHint) { redoPanel = new HPanel( new HPanel( Decor.Button("Удалить тему").Event("delete_topic", "", delegate { int messageCount = topic.MessageLink.AllRows.Length; if (!state.Operation.Validate(messageCount > 1, "Тема с комментариями не может быть удалена")) { return; } MessageHlp.DeleteTopicMessages(context.ForumConnection, topic.Topic.Id); BasketballHlp.DeleteTopic(context.FabricConnection, topic.TopicId); topic.UpdateTopic(); topic.UpdateMessages(); context.UpdateLastComments(true); context.Forum.ForSection(forumSection.Id).Update(); state.RedirectUrl = "/"; } ) ).Align(false), Decor.PropertyEdit("editTopicTitle", "Заголовок темы", topic.Topic.Get(TopicType.Title)), Decor.Button("Переименовать тему") .Event("save_topic_edit", "editTopicData", delegate(JsonData json) { string title = json.GetText("editTopicTitle"); WebOperation operation = state.Operation; if (!operation.Validate(title, "Не задан заголовок")) { return; } LightObject editTopic = DataBox.LoadObject(context.FabricConnection, TopicType.Topic, topic.TopicId); editTopic.SetWithoutCheck(TopicType.Title, title); editTopic.Box.Update(); context.Forum.ForSection(forumSection.Id).Update(); topic.UpdateTopic(); state.BlockHint = ""; }, topic.TopicId ) ).EditContainer("editTopicData") .Padding(5, 10).MarginTop(5).Background(Decor.pageBackground); } return(new HPanel( Decor.Button("Редактировать") .Event("topic_edit", "", delegate { state.SetBlockHint(blockHint); } ), redoPanel ).MarginTop(5).MarginBottom(10)); }
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)); }