private void bindAddList( int postId, ContentPost post, List<ContentImg> imgList ) { set( "section.Name", post.PageSection.Title ); set( "post.EditListInfo", to( EditListInfo, postId ) ); IBlock block = getBlock( "list" ); foreach (ContentImg img in imgList) { block.Set( "img.Url", img.GetImgUrl() ); block.Set( "img.Thumb", img.GetThumb() ); block.Set( "img.Description", strUtil.CutString( img.Description, 8 ) ); block.Set( "img.DeleteUrl", to( DeleteImg, img.Id ) ); String setLogoCmd = string.Empty; if (img.ImgUrl.Equals( post.ImgLink )) { setLogoCmd = "<span style='font-weight:bold;color:red;'>" + alang( "currentCover" ) + "</span>"; } else { setLogoCmd = string.Format( "<a href='{0}' class=\"putCmd cmd\">" + alang( "setCover" ) + "</a>", to( SetLogo, img.Id ) ); } block.Set( "img.SetLogo", setLogoCmd ); block.Next(); } int upCounts = 3; IBlock upblock = getBlock( "upList" ); for (int i = 1; i < (upCounts + 1); i++) { upblock.Set( "photoIndex", i ); upblock.Next(); } }
public static String getPickedIcon( ContentPost post ) { if (post.PickStatus == PickStatus.Picked) return iconPicked; if (post.PickStatus == PickStatus.Focus) return iconFocus; return ""; }
private void bindSectionShow( List<ContentPost> posts, ContentPost img ) { IBlock block = getBlock( "list" ); foreach (ContentPost post in posts) { BinderUtils.bindPostSingle( block, post, ctx ); block.Next(); } IBlock imgBlock = getBlock( "img" ); if (img != null) { imgBlock.Set( "ipost.TitleCss", img.Style ); String content = strUtil.HasText( img.Summary ) ? img.Summary : strUtil.ParseHtml( img.Content, 50 ); imgBlock.Set( "ipost.Content", content ); int width = img.Width <= 0 ? 120 : img.Width; int height = img.Height <= 0 ? 90 : img.Height; imgBlock.Set( "ipost.Width", width ); imgBlock.Set( "ipost.Height", height ); imgBlock.Set( "ipost.Url", alink.ToAppData( img, ctx ) ); imgBlock.Bind( "ipost", img ); imgBlock.Next(); } }
public static void bindListItem( IBlock block, ContentPost post, MvcContext ctx ) { block.Set( "post.SectionName", post.PageSection.Title ); block.Set( "post.SectionUrl", ctx.to( new SectionController().Show, post.PageSection.Id ) ); String typeIcon = BinderUtils.getTypeIcon( post ); block.Set( "post.ImgIcon", typeIcon ); String att = post.Attachments > 0 ? "<img src=\"" + strUtil.Join( sys.Path.Img, "attachment.gif" ) + "\"/>" : ""; block.Set( "post.AttachmentIcon", att ); block.Set( "post.TitleCss", post.Style ); block.Set( "post.Title", strUtil.SubString( post.GetTitle(), 50 ) ); block.Set( "post.Created", post.Created ); block.Set( "post.Hits", post.Hits ); block.Set( "post.Url", alink.ToAppData( post ) ); if (post.Creator != null) { block.Set( "post.Submitter", string.Format( "<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember( post.Creator ), post.Creator.Name ) ); } else { block.Set( "post.Submitter", "" ); } }
private void bindEditCmd( IBlock block, ContentPost post ) { String lnkEdit = ""; lnkEdit = to( AddImgList, post.Id ); block.Set( "post.EditUrl", lnkEdit ); }
private void bindSectionShow( ContentSection section, ContentPost video ) { set( "m.Title", section.Title ); if (video == null) { set( "video.Content", "" ); set( "video.TitleFull", "" ); set( "video.Title", "" ); set( "video.Url", "" ); } else { String content = WebHelper.GetFlash( video.SourceLink, video.Width, video.Height ); set( "video.Content", content ); set( "video.TitleFull", video.Title ); if (strUtil.HasText( video.TitleHome )) set( "video.Title", video.TitleHome ); else set( "video.Title", video.Title ); set( "video.Url", alink.ToAppData( video ) ); } }
private void transSectionOne( ContentPost x ) { if (x.PageSection == null || x.PageSection.Id <= 0) return; int sectionId = x.PageSection.Id; ContentPostSection ps = hasTrans( x, sectionId ); if (ps != null) { ps.SaveStatus = x.SaveStatus; ps.update(); } else { ContentPostSection newPs = new ContentPostSection(); newPs.Post = x; newPs.Section = x.PageSection; newPs.SaveStatus = x.SaveStatus; newPs.insert(); logger.Info( "transSectionOne=> postId=" + x.Id + ", sectionId=" + x.PageSection.Id ); } }
private String getStatus( ContentPost post ) { if (post.HasImg()==false) return ""; return "<img src=\""+strUtil.Join( sys.Path.Img, "img.gif" )+"\" />"; }
private void bindSectionShow( int sectionId, ContentPost video ) { set( "addUrl", to( Add, sectionId ) ); set( "listUrl", to( AdminList, sectionId ) ); if (video == null) { set( "post.Content", "" ); set( "post.Title", "" ); } else { String content = WebHelper.GetFlash( video.SourceLink, video.Width, video.Height ); set( "post.Content", content ); if (strUtil.HasText( video.TitleHome )) set( "post.Title", video.TitleHome ); else set( "post.Title", video.Title ); } IBlock editlinkBlock = getBlock( "editlink" ); if (video != null) { editlinkBlock.Set( "post.EditUrl", to( Edit, video.Id ) ); editlinkBlock.Next(); } }
public override bool BeforeAction( MvcContext ctx ) { ContentPost post = postService.GetById( ctx.route.id, ctx.owner.Id ); _contentPost = post; return base.BeforeAction( ctx ); }
private void bindEditInfo( long postId, ContentPost post ) { set( "section.Name", post.SectionName ); set( "section.Id", post.SectionId ); set( "post.Author", post.Author ); set( "post.SourceLink", post.SourceLink ); set( "post.Style", post.Style ); set( "post.OrderId", post.OrderId ); set( "post.Content", post.Content ); set( "post.Created", post.Created ); set( "post.Hits", post.Hits ); set( "post.OrderId", post.OrderId ); set( "post.RedirectUrl", post.RedirectUrl ); set( "post.MetaKeywords", post.MetaKeywords ); set( "post.MetaDescription", post.MetaDescription ); set( "post.Summary", post.Summary ); set( "post.SourceLink", post.SourceLink ); set( "post.Style", post.Style ); set( "post.TagList", post.Tag.TextString ); String val = AccessStatusUtil.GetRadioList( post.AccessStatus ); set( "post.AccessStatus", val ); set( "post.IsCloseComment", Html.CheckBox( "IsCloseComment", lang( "closeComment" ), "1", cvt.ToBool( post.CommentCondition ) ) ); }
private void bindAttachments( ContentPost post ) { set( "addLink", to( new AttachmentController().Add, post.Id ) ); set( "sortAction", to( new AttachmentController().SaveSort, post.Id ) ); ContentPost topic = postService.GetById( post.Id, ctx.owner.Id ); List<ContentAttachment> attachList = attachService.GetAttachmentsByPost( post.Id ); String cmd; if (topic.IsAttachmentLogin == 1) { String lockImg = strUtil.Join( sys.Path.Img, "edit.gif" ); cmd = alang( "currentDownloadPermission" ); cmd += string.Format( "<img src=\"{1}\" /> <a href=\"{0}\" class=\"frmBox\">", to( new AttachmentController().SetPermission, post.Id ), lockImg ); cmd += lang( "edit" ) + "</a>"; } else { String lockImg = strUtil.Join( sys.Path.Img, "lock.gif" ); cmd = string.Format( "<img src=\"{1}\" /> <a href=\"{0}\" class=\"frmBox\">" + alang( "setDownloadPermission" ) + "</a>", to( new AttachmentController().SetPermission, post.Id ), lockImg ); } set( "cmd", cmd ); bindAttachments( attachList ); }
private void bindShow( ContentPost post, DataPage<ContentImg> imgPage ) { ctx.SetItem( "ContentPost", post ); set( "post.Title", post.Title ); set( "post.Content", post.Content ); set( "post.CreateTime", post.Created ); set( "post.ReplyCount", post.Replies ); set( "post.Hits", post.Hits ); set( "post.Source", post.SourceLink ); if (post.Creator != null) { set( "post.Submitter", string.Format( "<a href=\"{0}\" target=\"_blank\">{1}</a>", Link.ToMember( post.Creator ), post.Creator.Name ) ); } else { set( "post.Submitter", "нч" ); } IBlock block = getBlock( "list" ); foreach (ContentImg img in imgPage.Results) { block.Set( "img.Url", img.GetImgUrl() ); block.Set( "img.Description", img.Description ); block.Next(); } String postLink = alink.ToAppData( post ); String pageBar = ObjectPage.GetPageBarByLink( postLink, imgPage.PageCount, imgPage.Current ); set( "page", pageBar ); }
private void bindSectionShow( int sectionId, List<ContentPost> posts, ContentPost first ) { IBlock block = getBlock( "nav" ); int width = first.Width - 20; int height = first.Height; set( "first.Width", width ); set( "first.Height", height ); foreach (ContentPost photo in posts) { block.Set( "photo.Width", width ); block.Set( "photo.Height", height ); block.Set( "photo.TitleFull", photo.Title ); if (strUtil.HasText( photo.TitleHome )) block.Set( "photo.Title", photo.TitleHome ); else block.Set( "photo.Title", photo.Title ); block.Set( "photo.ImgUrl", photo.GetImgMedium() ); block.Set( "photo.Link", alink.ToAppData( photo ) ); block.Bind( "photo", photo ); block.Next(); } }
private void bindSectionShow( long sectionId, ContentPost video ) { int vWidth = 320; int vHeight = 240; set( "addUrl", to( new VideoController().Add, sectionId ) + "?width=" + vWidth + "&height=" + vHeight ); set( "listUrl", to( new VideoController().AdminList, sectionId ) ); if (video == null) { set( "post.Content", "" ); set( "post.Title", "" ); } else { String content = WebHelper.GetFlash( video.SourceLink, video.Width, video.Height ); set( "post.Content", content ); if (strUtil.HasText( video.TitleHome )) set( "post.Title", video.TitleHome ); else set( "post.Title", video.Title ); } IBlock editlinkBlock = getBlock( "editlink" ); if (video != null) { editlinkBlock.Set( "post.EditUrl", to( new VideoController().Edit, video.Id ) ); editlinkBlock.Next(); } }
private void bindFocus( IBlock fblock, ContentPost article ) { fblock.Set( "article.Title", strUtil.SubString( article.Title, 19 ) ); fblock.Set( "article.SummaryInfo", strUtil.CutString( article.Summary, 100 ) ); fblock.Set( "article.Url", alink.ToAppData( article, ctx ) ); fblock.Next(); }
private void bindSectionShow( int sectionId, int imgcat, List<ContentPost> posts, ContentPost first ) { set( "sectionId", sectionId ); set( "addUrl", Link.To( new PostController().Add, sectionId ) + "?categoryId=" + imgcat ); set( "listUrl", Link.To( new ListController().AdminList, sectionId ) + "?categoryId=" + imgcat ); int slideWidth = first == null ? 300 : first.Width; int slideHeight = first == null ? 220 : first.Height; set( "slideWidth", slideWidth ); set( "slideHeight", slideHeight ); IBlock block = getBlock( "nav" ); foreach (ContentPost photo in posts) { block.Set( "photo.TitleFull", photo.Title ); if (strUtil.HasText( photo.TitleHome )) block.Set( "photo.Title", photo.TitleHome ); else block.Set( "photo.Title", photo.Title ); block.Set( "photo.ImgUrl", photo.GetImgMedium() ); String lnk = photo.HasImg() ? Link.To( new PostController().EditImg, photo.Id ) : "#"; block.Set( "photo.Link", lnk ); block.Next(); } }
public static ContentPost SetPostValue( ContentPost post, MvcContext ctx ) { post.Author = strUtil.CutString( ctx.Post( "Author" ), 100 ); post.Title = strUtil.CutString( ctx.Post( "Title" ), 100 ); post.TitleHome = strUtil.CutString( ctx.Post( "TitleHome" ), 100 ); post.Content = ctx.PostHtml( "Content" ); post.Summary = ctx.Post( "Summary" ); post.SourceLink = strUtil.CutString( ctx.Post( "SourceLink" ), 250 ); post.AccessStatus = cvt.ToInt( ctx.Post( "AccessStatus" ) ); post.CommentCondition = cvt.ToInt( ctx.Post( "IsCloseComment" ) ); post.Hits = ctx.PostInt( "Hits" ); post.Created = ctx.PostTime( "Created" ); post.MetaKeywords = strUtil.CutString( ctx.Post( "MetaKeywords" ), 250 ); post.MetaDescription = strUtil.CutString( ctx.Post( "MetaDescription" ), 250 ); post.RedirectUrl = strUtil.CutString( ctx.Post( "RedirectUrl" ), 250 ); post.PickStatus = ctx.PostInt( "PickStatus" ); post.SaveStatus = 0; post.Ip = ctx.Ip; post.Style = strUtil.CutString( ctx.Post( "Style" ), 250 ); post.OrderId = ctx.PostInt( "OrderId" ); post.ImgLink = sys.Path.GetPhotoRelative( ctx.Post( "ImgLink" ) ); post.Width = ctx.PostInt( "Width" ); post.Height = ctx.PostInt( "Height" ); return post; }
public static void PostUpdate( ContentPost post ) { HtmlJobItem item = new HtmlJobItem(); item.Name = typeof( JobProcessor ).FullName; item.Method = getMethodName( new JobProcessor().AfterPostUpdate ); item.PostId = post.Id; cdb.insert( item ); }
// 处理需要翻页的详细页 private void makeDetailPages( ContentPost post, List<String> pagedUrls ) { _post = post; foreach (String url in pagedUrls) { String addrPaged = url; String htmlPaged = makeHtml( addrPaged ); String htmlPath = getPath( post, PageHelper.GetPageNoByUrl( url ) ); file.Write( htmlPath, htmlPaged ); logger.Info( "make html done=>" + htmlPath ); } }
public virtual void Delete( ContentPost post ) { _post = post; String htmlPath = getPath( post ); if (file.Exists( htmlPath )) { file.Delete( htmlPath ); logger.Info( "delete html done=>" + htmlPath ); } }
public static ContentPost ValidateTitleBody( ContentPost post, MvcContext ctx ) { if (strUtil.IsNullOrEmpty( post.Title )) ctx.errors.Add( lang.get( "exTitle" ) ); if (strUtil.IsNullOrEmpty( post.Content ) && strUtil.IsNullOrEmpty( post.SourceLink )) ctx.errors.Add( ctx.controller.alang( "exContentLink" ) ); return post; }
private void bindEditInfo( int postId, ContentPost post ) { set( "post.DeleteUrl", Link.To( new ListController().Delete, postId ) ); set( "module.Name", post.PageSection.Title ); set( "module.Id", post.PageSection.Id ); set( "post.Title", post.Title ); set( "post.SourceLink", post.SourceLink ); set( "post.Style", post.Style ); set( "post.OrderId", post.OrderId ); set( "post.Content", post.Content ); }
// 在第一条存入头条 private static void addFocusFirst( List<ContentPost> list, ContentPost post, List<ContentPost> mylist ) { if (post != null) { mylist.Add( post ); return; } if (list.Count > 0) { mylist.Add( list[0] ); } }
public static String getTypeIcon( IPageAdminSection sectionController, ContentPost post ) { String typeIcon = sectionController.GetSectionIcon( post.SectionId ); if (strUtil.HasText( typeIcon )) return typeIcon; if (post.TypeName == typeof( ContentVideo ).FullName) return iconVideo; if (post.TypeName == typeof( ContentImg ).FullName) return iconPic; if (post.TypeName == typeof( ContentPoll ).FullName) return iconPoll; if (post.HasImg()) return iconPic; return ""; }
private void bindSectionShow( long sectionId, ContentPost textPost ) { String content = textPost == null ? "" : textPost.Content; set( "post.Content", content ); IBlock editlinkBlock = getBlock( "editlink" ); if (textPost != null) { editlinkBlock.Set( "post.EditUrl", to( Edit, textPost.Id ) ); editlinkBlock.Next(); } set( "addUrl", to( Add, sectionId ) ); set( "listUrl", to( AdminList, sectionId ) ); }
private void bindShow( ContentPost post ) { ctx.SetItem( "ContentPost", post ); set( "post.Title", post.Title ); set( "post.CreateTime", post.Created ); set( "post.ReplyCount", post.Replies ); set( "post.Source", post.SourceLink ); set( "post.Hits", post.Hits ); String siteUrl = new UrlInfo( post.SourceLink ).SiteUrl; set( "post.Source", siteUrl ); String val = WebHelper.GetFlash( post.SourceLink, 500, 400 ); set( "post.Content", val ); }
// TODO 侧边栏使用ajax方式?如果相关数据更新,则只是侧边栏失效 // 评论使用iframe方式 public void AddPost( ContentPost post ) { // 首页缓存移除 removeCacheSingle( controller.to( new ContentController().Index ) ); // 最新列表页标记过期 String recentKey = "content_recent_" + post.AppId; cacheHelper.SetTimestamp( recentKey, DateTime.Now ); // 列表页标记过期 String listKey = "content_list_" + post.PageSection.Id; cacheHelper.SetTimestamp( listKey, DateTime.Now ); }
private void bindEditInfo( int postId, ContentPost post ) { set( "module.Id", post.PageSection.Id ); set( "module.Name", post.PageSection.Title ); set( "post.Title", post.Title ); set( "post.TitleHome", post.TitleHome ); set( "post.SourceLink", post.SourceLink ); set( "post.ImgLink", post.ImgLink ); set( "post.Style", post.Style ); set( "post.OrderId", post.OrderId ); set( "post.DeleteUrl", to( Delete, postId ) + "?categoryId=" + ctx.GetInt( "categoryId" ) ); }
public virtual void Process( ContentPost post ) { _post = post; base.CheckDir(); List<String> pagedUrls = new List<String>(); // 翻页的链接 String addr = alink.ToAppData( post ); String html = makeHtml( addr, pagedUrls ); file.Write( getPath( post ), html ); if (pagedUrls.Count > 0) { makeDetailPages( post, pagedUrls ); } }
public virtual void SectionShow(long sectionId) { ContentSection s = sectionService.GetById(sectionId, ctx.app.Id); if (s == null) { throw new Exception(lang("exDataNotFound") + "=>page section:" + sectionId); } List <ContentPost> posts = this.postService.GetBySection(sectionId, 4); ContentPost first = posts.Count > 0 ? posts[0] : null; bindSectionShow(sectionId, posts, first); }
private void saveLinkPicSingle(string picUrl, string picDesc, ContentPost post, int i) { ContentImg img = new ContentImg(); img.Post = post; img.ImgUrl = picUrl; img.Description = picDesc; imgService.CreateImg(img); if ((i == 1) && post.HasImg() == false) { post.ImgLink = img.ImgUrl; imgService.UpdateImgLogo(post); } }
public void UpdateTitleStyle(int id) { String titleStyle = strUtil.SqlClean(FormController.GetTitleStyle(ctx), 100); ContentPost post = postService.GetById(id, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } postService.UpdateTitleStyle(post, titleStyle); echoToParentPart(lang("opok")); HtmlHelper.SetPostToContext(ctx, post); }
//-------------------------------------------------------------------------------------------------------------------------- public void EditListInfo(int postId) { view("EditListInfo"); ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } target(UpdateListInfo, postId); bindListEdit(postId, post); }
public virtual List <ContentPost> GetBySection(int sectionId, int count) { List <ContentPostSection> psList = ContentPostSection .find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by PostId desc") .list(count); if (psList.Count == 0) { // 兼容旧版 return(ContentPost.find("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal).list(count)); } return(populatePost(psList)); }
//--------------------------------------------------------------------------------------------- private ContentPost GetById(int postId) { ContentPost post = db.findById <ContentPost>(postId); if (post == null) { return(null); } if (post.SaveStatus != SaveStatus.Normal) { return(null); } return(post); }
public virtual void Delete(long postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } postService.Delete(post); echoRedirectPart(lang("opok")); HtmlHelper.SetPostToContext(ctx, post); }
public void Show(int id) { ContentPost post = postService.GetById(id, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } postService.AddHits(post); bindShow(post); }
public static ContentPost ValidateTitleBody(ContentPost post, MvcContext ctx) { if (strUtil.IsNullOrEmpty(post.Title)) { ctx.errors.Add(lang.get("exTitle")); } if (strUtil.IsNullOrEmpty(post.Content) && strUtil.IsNullOrEmpty(post.SourceLink)) { ctx.errors.Add(ctx.controller.alang("exContentLink")); } return(post); }
private void loadComment(ContentPost post) { ContentApp app = ctx.app.obj as ContentApp; if (post.CommentCondition == CommentCondition.Close || app.GetSettingsObj().AllowComment == 0) { set("commentSection", ""); return; } ctx.SetItem("createAction", to(new ContentCommentController().Create, post.Id)); ctx.SetItem("commentTarget", post); load("commentSection", new ContentCommentController().ListAndForm); }
public virtual List <DataTagShip> GetRelatedDatas(ContentPost post) { List <Tag> tags = post.Tag.List; List <DataTagShip> results = new List <DataTagShip>(); foreach (Tag t in tags) { List <DataTagShip> list = DataTagShip.find("TagId=" + t.Id + "").list(); mergeTagDatas(results, list, post); } return(results); }
public void Delete(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } postService.Delete(post); // ɾ³ý»ØÊÕÕ¾ echoRedirect(lang("opok")); HtmlHelper.SetPostToContext(ctx, post); }
public virtual int CountBySection(int sectionId) { int count = ContentPostSection.count("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal); // 兼容旧版 if (count == 0) { return(ContentPost.count("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal)); } else { return(count); } }
// 在第一条存入头条 private static void addFocusFirst(List <ContentPost> list, ContentPost post, List <ContentPost> mylist) { if (post != null) { mylist.Add(post); return; } if (list.Count > 0) { mylist.Add(list[0]); } }
//-------------------------------------------------------------------------------------------------------- public void Create() { ContentPost post = ContentValidator.Validate(ctx); ContentValidator.ValidateArticle(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), 1); } else { echoToParentPart(lang("opok")); } }
public virtual ContentPost GetFirstPost(int appId, int sectionId) { ContentPost result = db.find <ContentPost>("PageSection.Id=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by Id desc").first(); if (result == null) { return(null); } if (result.AppId != appId) { return(null); } return(result); }
public void Delete(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } postService.Delete(post); echoRedirectPart(lang("opok")); }
public void CreateImgList(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } if (ctx.GetFiles().Count <= 0) { errors.Add(alang("plsUpImg")); run(AddImgList, postId); return; } for (int i = 0; i < ctx.GetFiles().Count; i++) { Result result = Uploader.SaveImg(ctx.GetFiles()[i]); if (result.HasErrors) { errors.Join(result); } else { ContentImg img = new ContentImg(); img.Post = post; img.ImgUrl = result.Info.ToString(); img.Description = ctx.Post("Text" + (i + 1)); imgService.CreateImg(img); if ((i == 0) && post.HasImg() == false) { post.ImgLink = img.ImgUrl; imgService.UpdateImgLogo(post); } } } if (errors.Errors.Count >= ctx.GetFiles().Count) { errors.Errors.Clear(); errors.Add(alang("plsUpImg")); run(AddImgList, postId); } else { redirect(AddImgList, postId); } }
private void bindListEdit(int postId, ContentPost post) { set("section.Name", post.PageSection.Title); set("post.Title", post.Title); set("post.TitleHome", post.TitleHome); set("post.Content", post.Content); set("post.OrderId", post.OrderId); set("post.ImgListUrl", to(AddImgList, postId)); set("post.IsCloseComment", Html.CheckBox("IsCloseComment", lang("closeComment"), "1", cvt.ToBool(post.CommentCondition))); editor("Content", post.Content, "190px"); }
public void Delete(int id) { ContentPost post = topicService.GetById(id, ctx.owner.Id); if (post != null) { topicService.Delete(post); } pollService.DeleteByTopicId(id); echoRedirect(lang("opok")); HtmlHelper.SetPostToContext(ctx, post); }
public void DeletePostPic(int id) { ContentPost post = postService.GetById(id, ctx.owner.Id); if (post == null) { echoText("data not found"); return; } wojilu.Drawing.Img.DeleteImgAndThumb(post.GetImgUrl()); echoAjaxOk(); }
public virtual void Edit(long postId) { view("Edit"); ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } target(Update, postId); bindEditInfo(postId, post); }
private void loadRelatedPosts(ContentPost post) { List <DataTagShip> list = postService.GetRelatedDatas(post, 21); IBlock block = getBlock("related"); List <IAppData> addList = new List <IAppData>(); foreach (DataTagShip dt in list) { if (dt.DataId == post.Id && dt.TypeFullName.Equals(typeof(ContentPost).FullName)) { continue; } EntityInfo ei = Entity.GetInfo(dt.TypeFullName); if (ei == null) { continue; } IAppData obj = ndb.findById(ei.Type, dt.DataId) as IAppData; if (obj == null) { continue; } if (hasAdded(addList, obj)) { continue; } block.Set("p.Title", obj.Title); String lnkPost = ""; if (obj is ContentPost) { lnkPost = alink.ToAppData(obj, ctx); // 暂时只有 ContentPost 支持 Html 静态页面生成 } else { lnkPost = alink.ToAppData(obj); } block.Set("p.Link", lnkPost); block.Set("p.Created", obj.Created); block.Next(); } }
private string getCommentUrl(ContentPost post) { if (post.CommentCondition == CommentCondition.Close) { return("#"); } return(t2(new wojilu.Web.Controller.Open.CommentController().List) + "?url=" + alink.ToAppData(post, ctx) + "&dataType=" + typeof(ContentPost).FullName + "&dataTitle=" + post.Title + "&dataUserId=" + post.Creator.Id + "&dataId=" + post.Id + "&appId=" + post.AppId); }
//------------------------------------------------------------- public void AddImgList(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } target(CreateImgList, postId); List <ContentImg> imgList = imgService.GetImgList(postId); bindAddList(postId, post, imgList); }
// TODO 侧边栏使用ajax方式?如果相关数据更新,则只是侧边栏失效 // 评论使用iframe方式 public void AddPost(ContentPost post) { // 首页缓存移除 removeCacheSingle(controller.to(new ContentController().Index)); // 最新列表页标记过期 String recentKey = "content_recent_" + post.AppId; cacheHelper.SetTimestamp(recentKey, DateTime.Now); // 列表页标记过期 String listKey = "content_list_" + post.PageSection.Id; cacheHelper.SetTimestamp(listKey, DateTime.Now); }
public void Show(int postId) { ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } int currentPage = ctx.route.page; DataPage <ContentImg> imgPage = imgService.GetImgPage(postId, currentPage); bindShow(post, imgPage); }
public void SectionShow(int sectionId) { int postcat = PostCategory.Post; int imgcat = PostCategory.Img; int imgPostCat = PostCategory.ImgPost; List <ContentPost> posts = postService.GetTopBySectionAndCategory(sectionId, postcat); ContentPost img = imgService.GetTopImg(sectionId, imgPostCat, ctx.app.Id); List <ContentPost> imgs = this.imgService.GetByCategory(sectionId, imgcat, ctx.app.Id, 4); bindPosts(posts); bindTopImg(img); bindImgs(imgs); }
public virtual void Edit(long postId) { view("Edit"); ContentPost post = postService.GetById(postId, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } target(Update, postId); set("section.Title", post.SectionName); set("Content", post.Content); }
public virtual DataPage <ContentPost> GetPageBySection(int sectionId, int pageSize) { DataPage <ContentPostSection> list = ContentPostSection.findPage("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal + " order by PostId desc", pageSize); DataPage <ContentPost> xResult = list.Convert <ContentPost>(populatePost(list.Results)); // 兼容旧版 if (xResult.RecordCount == 0) { return(ContentPost.findPage("SectionId=" + sectionId + " and SaveStatus=" + SaveStatus.Normal, pageSize)); } else { return(xResult); } }