public void SavePost(int sectionId) { if (shouldApprove(ctx.viewer.obj)) { saveTempPost(sectionId, null); if (ctx.HasErrors) { echoError(); } return; } ContentPost post = ContentValidator.SetValueBySection(sectionService.GetById(sectionId, ctx.app.Id), ctx); ContentValidator.ValidateTitleBody(post, ctx); if (strUtil.HasText(post.ImgLink)) { post.CategoryId = PostCategory.Img; post.Width = 100; post.Height = 85; } if (ctx.HasErrors) { run(SubmitPost, sectionId); } else { postService.Insert(post, ctx.Post("TagList")); echoRedirect("发布成功,谢谢", to(new ContentController().Index)); } }
//-------------------------------------------------------------------------------------------------------- public void Create() { ContentPost post = ContentValidator.SetValue(ctx); ContentValidator.ValidateTitleBody(post, ctx); String sectionIds = ctx.PostIdList("postSection"); if (strUtil.IsNullOrEmpty(sectionIds)) { errors.Add("请选择区块"); } int[] arrAttachmentIds = cvt.ToIntArray(ctx.PostIdList("attachmentIds")); // 图片默认值处理 if (strUtil.HasText(post.ImgLink)) { if (post.Width <= 0) { post.Width = 100; post.Height = 85; } } if (ctx.HasErrors) { echoError(); return; } // 处理远程图片 if (ctx.PostIsCheck("isDowloadPic") == 1) { post.Content = wojilu.Net.PageLoader.ProcessPic(post.Content, ""); } postService.Insert(post, sectionIds, ctx.Post("TagList")); attachService.UpdateAtachments(arrAttachmentIds, post); if (ctx.GetInt("fromList") > 0) { echoRedirectPart(lang("opok"), to(List, 0), 1); } else { echoToParentPart(lang("opok")); } HtmlHelper.SetPostToContext(ctx, post); }
public void Update(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoError(lang("exDataNotFound")); return; } String sectionIds = ctx.PostIdList("postSection"); if (strUtil.IsNullOrEmpty(sectionIds)) { echoError("请选择区块"); return; } ContentValidator.SetPostValue(post, ctx); ContentValidator.ValidateTitleBody(post, ctx); if (errors.HasErrors) { run(Edit, postId); } else { if (ctx.PostIsCheck("saveContentPic") == 1) { post.Content = wojilu.Net.PageLoader.ProcessPic(post.Content, null); } postService.Update(post, sectionIds, ctx.Post("TagList")); echoToParentPart(lang("opok")); } }