Example #1
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 #2
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("");
        }
Example #3
0
        private void bindPickedList(IList serviceData, IBlock block)
        {
            for (int i = 1; i < serviceData.Count; i++)
            {
                ContentPost post = serviceData[i] as ContentPost;

                IPageAdminSection sectionController = BinderUtils.GetPageSectionAdmin(post, ctx, "AdminSectionShow");
                String            typeIcon          = sectionController.GetSectionIcon(post.SectionId);

                String attIcon = post.Attachments > 0 ? BinderUtils.iconAttachment : "";

                if (strUtil.HasText(post.TitleHome))
                {
                    block.Set("post.Title", post.TitleHome);
                }
                else
                {
                    block.Set("post.Title", post.Title);
                }


                block.Set("post.Url", alink.ToAppData(post, ctx));
                block.Set("post.DataIcon", typeIcon);
                block.Set("post.AttachmentIcon", attIcon);
                block.Set("post.Created", post.Created.ToShortDateString());
                block.Next();
            }
        }
Example #4
0
        private String bindData(IBlock sectionBlock, ContentSection articleSection)
        {
            IPageAdminSection section    = BinderUtils.GetPageSectionAdmin(articleSection, ctx, "AdminSectionShow");
            ControllerBase    controller = section as ControllerBase;

            bindSettingLink(sectionBlock, section.GetSettingLink(articleSection.Id));
            section.AdminSectionShow(articleSection.Id);
            return(controller.utils.getActionResult());
        }
Example #5
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);
        }
Example #6
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 "";
        }
Example #7
0
        private List <XPost> getPostList(ContentSection section)
        {
            List <XPost> list = new List <XPost>();

            String adminSectionType = section.SectionType.Replace("Content.Section", "Content.Admin.Section");

            IPageAdminSection adminSection = ObjectContext.Create(adminSectionType) as IPageAdminSection;

            if (adminSection == null)
            {
                return(list);
            }

            ControllerBase controller = adminSection as ControllerBase;

            controller.ctx = ctx;

            List <ContentPost> posts = adminSection.GetSectionPosts(section.Id);

            foreach (ContentPost post in posts)
            {
                XPost x = new XPost();

                x.Title   = post.Title;
                x.Content = post.Content;
                x.Pic     = post.GetImgOriginal();
                x.Summary = post.Summary;

                x.TitleHome  = post.TitleHome;
                x.CategoryId = post.CategoryId;
                x.SourceLink = post.SourceLink;
                x.PickStatus = post.PickStatus;

                x.Width  = post.Width;
                x.Height = post.Height;

                list.Add(x);
            }
            return(list);
        }