Example #1
0
        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", "" );
            }
        }
Example #2
0
        public static void bindListItem(IBlock block, ContentPost post, MvcContext ctx)
        {
            if (post.PageSection != null)
            {
                block.Set("post.SectionName", post.PageSection.Title);
                block.Set("post.SectionUrl", clink.toSection(post.PageSection.Id, ctx));
            }

            IPageAdminSection sectionController = BinderUtils.GetPageSectionAdmin(post, ctx, "AdminSectionShow");

            String typeIcon = sectionController.GetSectionIcon(post.SectionId);

            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.ToString("yyyy-MM-dd HH:mm:ss"));
            block.Set("post.Hits", post.Hits);
            block.Set("post.Url", alink.ToAppData(post, ctx));

            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", "");
            }
        }
Example #3
0
        private void bindDetail(int id, ContentPost post)
        {
            set("post.Title", post.GetTitle());
            set("post.Author", post.Author);
            set("post.Created", post.Created);

            String tag     = post.Tag.List.Count > 0 ? tag = "tag: " + post.Tag.HtmlString : "";
            String src     = getSrc(post);
            String replies = getReplies(post);

            set("post.Tag", tag);
            set("post.Replies", replies);
            set("post.Hits", post.Hits);
            set("post.Source", src);

            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", "ÎÞ");
            }

            bindSummary(post);

            String content;

            String pageSeparator = getPageSeparator(post.Content);

            if (pageSeparator == null)
            {
                content = post.Content;
            }
            else
            {
                content = getPagedContent(post, pageSeparator);
            }

            if (post.HasImg())
            {
                content = string.Format("<div style=\"text-align:center;\"><img src=\"{0}\" />", post.GetImgMedium()) + "</div>" + content;
            }

            if (post.IsAttachmentLogin == 1 && ctx.viewer.IsLogin == false)
            {
                content += "<div class=\"downloadWarning\"><div>" + alang("downloadNeedLogin") + "</div></div>";
            }
            else
            {
                content = addAttachment(post, content);
            }

            set("post.Content", content);
        }
Example #4
0
        private void bindDetail( int id, ContentPost post )
        {
            set( "post.Title", post.GetTitle() );
            set( "post.Author", post.Author );
            set( "post.Created", post.Created );

            String tag = post.Tag.List.Count > 0 ? tag = "tag: " + post.Tag.HtmlString : "";
            String src = getSrc( post );
            String replies = getReplies( post );

            set( "post.Tag", tag );
            set( "post.Replies", replies );
            set( "post.Hits", post.Hits );
            set( "post.Source", src );

            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", "ÎÞ" );
            }

            bindSummary( post );

            String content;

            String pageSeparator = getPageSeparator( post.Content );
            if (pageSeparator == null) {
                content = post.Content;
            }
            else {
                content = getPagedContent( post, pageSeparator );
            }

            if (post.HasImg()) {
                content = string.Format( "<div style=\"text-align:center;\"><img src=\"{0}\" />", post.GetImgMedium() ) + "</div>" + content;
            }

            if (post.IsAttachmentLogin == 1 && ctx.viewer.IsLogin == false) {
                content += "<div class=\"downloadWarning\"><div>" + alang( "downloadNeedLogin" ) + "</div></div>";
            }
            else {
                content = addAttachment( post, content );
            }

            set( "post.Content", content );
        }
Example #5
0
        private void bindMetaInfo(ContentPost post)
        {
            ctx.Page.SetTitle(post.GetTitle(), ctx.app.Name);

            if (strUtil.HasText(post.MetaKeywords))
            {
                this.Page.Keywords = post.MetaKeywords;
            }
            else
            {
                this.Page.Keywords = post.Tag.TextString;
            }

            if (strUtil.HasText(post.MetaDescription))
            {
                this.Page.Description = post.MetaDescription;
            }
            else
            {
                this.Page.Description = post.Summary;
            }
        }
Example #6
0
        public virtual void Show(long id)
        {
            ContentPost post = postService.GetById(id, ctx.owner.Id);

            if (post == null)
            {
                echo(lang("exDataNotFound") + "=ContentPost");
                return;
            }

            ContentSection section = psService.GetFirstSectionByPost(post.Id);

            if (section == null)
            {
                echo(lang("exDataNotFound") + "=ContentSection");
                return;
            }

            // redirect
            if (strUtil.HasText(post.RedirectUrl))
            {
                redirectUrl(post.RedirectUrl);
                return;
            }


            //----------------------------------------------------------------------------------------------------

            // 1) location
            set("location", getLocation(post, section));

            // 2) detail
            set("detailContent", loadHtml(section.SectionType, "Show", post.Id));

            // 3) comment
            set("commentUrl", getCommentUrl(post));

            // 4) related posts
            loadRelatedPosts(post);

            // 5) prev/next
            bindPrevNext(post);

            // 6) other info, tag, src, summary
            String tag = post.Tag.List.Count > 0 ? tag = "tag: " + post.Tag.HtmlString : "";

            set("post.Tag", (post.Tag.List.Count > 0 ? tag = "tag: " + post.Tag.HtmlString : ""));
            set("post.Source", getSrc(post));
            set("post.Title", post.GetTitle());
            set("post.Replies", getReplies(post));
            set("post.Submitter", getSubmitter(post));
            bindSummary(post);

            // 7) digg
            set("lnkDiggUp", to(DiggUp, post.Id));
            set("lnkDiggDown", to(DiggDown, post.Id));

            // 9) 附件
            set("attachmentList", getAttachmentList(post));

            // 10) page meta,最后一个绑定,覆盖各 Section 自己的配置
            bindMetaInfo(post);

            // 11) 统计信息
            set("lnkStats", to(Stats, id));

            bind("post", post);
        }
Example #7
0
        private void bindMetaInfo( ContentPost post ) {

            ctx.Page.SetTitle( post.GetTitle(), ctx.app.Name );

            if (strUtil.HasText( post.MetaKeywords ))
                this.Page.Keywords = post.MetaKeywords;
            else
                this.Page.Keywords = post.Tag.TextString;

            if (strUtil.HasText( post.MetaDescription ))
                this.Page.Description = post.MetaDescription;
            else
                this.Page.Description = post.Summary;
        }