Exemple #1
0
        // TODO
        //private void makeHtml( String ids ) {

        //    List<ContentPost> posts = postService.GetByIds( ids );
        //    foreach (ContentPost post in posts) {

        //        HtmlHelper.SetCurrentPost( ctx, post );

        //        HtmlHelper.DeleteDetailHtml( ctx );

        //        int sectionId = post.PageSection.Id;
        //        int recordCount = postService.CountBySection( sectionId );
        //        new HtmlListMaker().MakeHtml( ctx, sectionId, recordCount );

        //    }
        //}

        private void bindAdminList(DataPage <ContentPost> posts, bool isTrash)
        {
            IBlock block = getBlock("list");

            foreach (ContentPost post in posts.Results)
            {
                IPageAdminSection sectionController = BinderUtils.GetPageSectionAdmin(post, ctx, "AdminSectionShow");

                String typeIcon = BinderUtils.getTypeIcon(sectionController, post);
                String pickIcon = BinderUtils.getPickedIcon(post);
                String attIcon  = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.ImgIcon", typeIcon);
                block.Set("post.PickIcon", pickIcon);
                block.Set("post.AttachmentIcon", attIcon);

                block.Set("post.Title", strUtil.SubString(post.GetTitle(), 50));
                block.Set("post.TitleCss", post.Style);
                block.Set("post.TitleFull", post.Title);

                block.Set("post.SectionName", post.SectionName);

                block.Set("post.Url", post.SourceLink);
                block.Set("post.Link", alink.ToAppData(post));
                block.Set("post.PubDate", post.Created);

                if (post.Creator != null)
                {
                    block.Set("post.Submitter", string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", toUser(post.Creator), post.Creator.Name));
                }
                else
                {
                    block.Set("post.Submitter", "无");
                }

                block.Bind("post", post);

                String lnkEdit = isTrash ? "#" : sectionController.GetEditLink(post.Id);

                String lnkDelete = to(Delete, post.Id);
                if (isTrash)
                {
                    lnkDelete = to(DeleteSys, post.Id);
                }

                block.Set("post.EditUrl", lnkEdit);
                block.Set("post.DeleteUrl", lnkDelete);

                block.Set("post.RestoreUrl", to(Restore, post.Id));
                block.Set("post.EditTitleStyleUrl", to(EditTitleStyle, post.Id));

                block.Set("post.AttachmentLink", to(new AttachmentController().AdminList, post.Id));

                block.Next();
            }
            set("page", posts.PageBar);
        }
        private void bindPickedList(IList serviceData, IBlock block)
        {
            for (int i = 1; i < serviceData.Count; i++)
            {
                ContentPost a = serviceData[i] as ContentPost;

                String typeIcon = BinderUtils.getTypeIcon(a);
                String attIcon  = a.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.Title", a.Title);
                block.Set("post.Url", alink.ToAppData(a));
                block.Set("post.DataIcon", typeIcon);
                block.Set("post.AttachmentIcon", attIcon);
                block.Set("post.Created", a.Created.ToShortDateString());
                block.Next();
            }
        }
        private void bindAdminList(DataPage <ContentPost> posts, bool isTrash)
        {
            IBlock block = getBlock("list");


            foreach (ContentPost post in posts.Results)
            {
                String typeIcon = BinderUtils.getTypeIcon(post);
                String pickIcon = BinderUtils.getPickedIcon(post);
                String attIcon  = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                block.Set("post.ImgIcon", typeIcon);
                block.Set("post.PickIcon", pickIcon);
                block.Set("post.AttachmentIcon", attIcon);

                block.Set("post.Title", strUtil.SubString(post.GetTitle(), 50));
                block.Set("post.TitleCss", post.Style);
                block.Set("post.TitleFull", post.Title);

                //String sectionName = post.PageSection == null ? "" : post.PageSection.Title;
                //block.Set( "post.SectionName", sectionName );

                block.Set("post.Url", post.SourceLink);
                block.Set("post.Link", alink.ToAppData(post));
                block.Set("post.PubDate", post.Created);

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



                block.Bind("post", post);

                String lnkEdit = "";
                if (isTrash)
                {
                    lnkEdit = "#";
                }
                else if (post.HasImg())
                {
                    lnkEdit = to(new PostController().EditImg, post.Id);
                }
                else
                {
                    lnkEdit = to(new PostController().Edit, post.Id);
                }

                String lnkDelete = to(Delete, post.Id);
                if (isTrash)
                {
                    lnkDelete = to(DeleteTrue, post.Id);
                }

                block.Set("post.EditUrl", lnkEdit);
                block.Set("post.DeleteUrl", lnkDelete);

                block.Set("post.RestoreUrl", to(Restore, post.Id));
                block.Set("post.EditSectionUrl", to(EditSection, post.Id));
                block.Set("post.EditTitleStyleUrl", to(EditTitleStyle, post.Id));

                block.Set("post.AttachmentLink", to(new AttachmentController().AdminList, post.Id));


                block.Next();
            }
            set("page", posts.PageBar);
        }