예제 #1
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);
        }
예제 #2
0
        protected override IMemberApp createPortalApp()
        {
            // 1、创建app
            IMemberApp ret = base.createApp();

            // 2、创建section
            foreach (XSection section in xapp.SectionList)
            {
                ContentSection s;

                // 聚合区块
                if (section.ServiceId > 0)
                {
                    s               = createSectionMashup(section.Name, section.ServiceId, section.TemplateId, section.LayoutStr);
                    s.CssClass      = section.CssClass;
                    s.ListCount     = section.ListCount;
                    s.ServiceParams = section.ServiceParams;
                    s.update();

                    // 添加内容区块
                }
                else
                {
                    s           = createSection(section.Name, section.TypeFullName, section.LayoutStr);
                    s.CssClass  = section.CssClass;
                    s.ListCount = section.ListCount;
                    s.update();

                    for (int i = section.PostList.Count - 1; i >= 0; i--)
                    {
                        XPost post = section.PostList[i];

                        ContentPost newPost = createPost(s, post.Title, post.TitleHome, post.Content, post.Pic, post.SourceLink, post.CategoryId, post.Width, post.Height);

                        if (strUtil.HasText(post.Summary))
                        {
                            newPost.Summary = post.Summary;
                        }

                        if (post.PickStatus > 0)
                        {
                            newPost.PickStatus = post.PickStatus;
                        }

                        if (strUtil.HasText(post.Summary) || post.PickStatus > 0)
                        {
                            newPost.update();
                        }
                    }
                }

                // 自定义模板
                if (strUtil.HasText(section.TemplateCustom))
                {
                    ContentCustomTemplate cs = new ContentCustomTemplate();
                    cs.Content   = section.TemplateCustom;
                    cs.OwnerId   = this.app.OwnerId;
                    cs.OwnerType = this.app.OwnerType;
                    cs.OwnerUrl  = this.app.OwnerUrl;
                    cs.Name      = "" + DateTime.Now.ToShortDateString();
                    cs.Creator   = ctx.viewer.obj as User;
                    tplService.Insert(cs);

                    s.CustomTemplateId = cs.Id;
                    s.update("CustomTemplateId");
                }
            }

            return(ret);
        }