Пример #1
0
        private void bindAdminList( ContentSection section, DataPage<ContentPost> posts )
        {
            set( "section.Title", section.Title );
            IBlock block = getBlock( "list" );

            String icon = string.Format( "<img src=\"{0}\"/> ", strUtil.Join( sys.Path.Img, "img.gif" ) );

            foreach (ContentPost post in posts.Results) {

                String imgIcon = post.HasImg() ? icon : "";
                block.Set( "post.ImgIcon", imgIcon );

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

                block.Set( "post.OrderId", post.OrderId );
                block.Set( "post.Url", post.SourceLink );
                block.Set( "post.Link", strUtil.CutString( post.SourceLink, 100 ) );
                block.Set( "post.PubDate", post.Created );

                String attachments = post.Attachments > 0 ? "<img src='" + strUtil.Join( sys.Path.Img, "attachment.gif" ) + "'/>" : "";
                block.Set( "post.Attachments", attachments );

                if (post.HasImg())
                    block.Set( "post.EditUrl", to( new PostController().EditImg, post.Id ) );
                else
                    block.Set( "post.EditUrl", to( new PostController().Edit, post.Id ) );

                block.Set( "post.DeleteUrl", to( Delete, post.Id ) );
                block.Next();
            }
            set( "page", posts.PageBar );
        }
        public void Bind( ContentSection section, IList serviceData )
        {
            TemplateUtil.loadTemplate( this, section, ctService );

            //target( new FeedbackController().Create );
            set( "ActionLink", t2( new FeedbackController().Create ) );

            if (ctx.viewer.Id == ctx.owner.Id && ctx.owner.obj is User)
                set( "f.ListLink", t2( new FeedbackController().AdminList ) );
            else
                set( "f.ListLink", t2( new FeedbackController().List ) );

            String pwTip = string.Format( lang( "pwTip" ), Feedback.ContentLength );
            set( "pwTip", pwTip );

            IBlock block = getBlock( "list" );
            foreach (Feedback f in serviceData) {

                if (f.Creator == null) continue;

                block.Set( "f.UserName", f.Creator.Name );
                block.Set( "f.UserFace", f.Creator.PicSmall );
                block.Set( "f.UserLink", Link.ToMember( f.Creator ) );

                block.Set( "f.ReplyLink", t2( new FeedbackController().Reply, f.Id ) );

                block.Set( "f.Content", f.GetContent() );
                block.Set( "f.Created", cvt.ToTimeString( f.Created ) );

                block.Bind( "f", f );

                block.Next();
            }
        }
        public virtual void Bind( ContentSection section, IList serviceData ) {

            IBlock block = base.getBlock( "list" );

            foreach (IBinderValue item in serviceData) {

                block.Set( "post.Title", item.Title );
                block.Set( "post.Url", item.Link );

                block.Set( "post.Created", item.Created );
                block.Set( "post.CreatedDay", item.Created.ToShortDateString() );
                block.Set( "post.CreatedTime", item.Created.ToShortTimeString() );

                block.Set( "post.CreatorName", item.CreatorName );
                block.Set( "post.CreatorLink", item.CreatorLink );
                block.Set( "post.CreatorPic", item.CreatorPic );

                block.Set( "post.Content", item.Content );
                block.Set( "post.Summary", strUtil.CutString( item.Content, 200 ) );
                block.Set( "post.PicUrl", item.PicUrl );
                block.Set( "post.Replies", item.Replies );

                block.Bind( "post", item );

                block.Next();

            }

        }
        public virtual void Bind( ContentSection section, IList serviceData ) {

            IBlock block = base.getBlock( "list" );

            foreach (IBinderValue item in serviceData) {

                block.Bind( "d", item );

                IBlock tcBlock = block.GetBlock( "titleAndContent" );
                IBlock onlyBlock = block.GetBlock( "onlyTitle" );


                if (strUtil.HasText( item.Content )) {
                    tcBlock.Set( "d.Title", strUtil.CutString( item.Title, 20 ) );
                    tcBlock.Set( "d.Content", strUtil.ParseHtml( item.Content, 150 ) );
                    tcBlock.Set( "d.Created", item.Created );
                    tcBlock.Bind( "c", item );
                    tcBlock.Next();
                }
                else {
                    onlyBlock.Set( "d.Title", item.Title );
                    onlyBlock.Bind( "c", item );
                    onlyBlock.Set( "d.Created", item.Created );
                    onlyBlock.Next();
                }

                block.Next();
            }

        }
Пример #5
0
        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 ) );
            }
        }
Пример #6
0
        public void Bind( ContentSection section, IList serviceData )
        {
            User user = ctx.owner.obj as User;
            if (user == null) return;

            bind( "user", new UserVo( user ) );
        }
 private String getData( ContentSection articleSection ) {
     IPageSection section = BinderUtils.GetPageSection( articleSection, ctx );
     ControllerBase sectionController = section as ControllerBase;
     section.SectionShow( articleSection.Id );
     String actionContent = sectionController.utils.getActionResult();
     return actionContent;
 }
Пример #8
0
        private void bindList( ContentSection section, DataPage<ContentPost> list, List<ContentPoll> polls )
        {
            User user = (User)ctx.viewer.obj;

            set( "section.Name", section.Title );

            IBlock block = getBlock( "list" );
            for (int i = 0; i < polls.Count; i++) {

                ContentPoll poll = polls[i];
                ContentPost post = list.Results[i];

                block.Set( "post.Created", poll.Created );
                ctx.SetItem( "poll", poll );

                Boolean hasVote = poll.CheckHasVote( user.Id );

                String html = hasVote ? loadHtml( sectionPollResult ) : loadHtml( sectionPoll );

                block.Set( "post.Html", html );
                //block.Set( "post.ShowLink", to( Show, post.Id ) );
                block.Set( "post.ShowLink", alink.ToAppData( post ) );

                String replies = post.Replies > 0 ? lang("comment") + " :" + post.Replies : "";
                block.Set( "post.Replies", replies );

                block.Next();
            }

            set( "page", list.PageBar );
        }
Пример #9
0
        private void bindAddInfo( ContentSection section ) {
            set( "section.Name", section.Title );
            set( "section.Id", section.Id );
            set( "created", DateTime.Now );

            set( "width", ctx.GetLong( "width" ) );
            set( "height", ctx.GetLong( "height" ) );
        }
Пример #10
0
        private String getTitle( ContentSection section, String moreUrl ) {

            if (strUtil.IsNullOrEmpty( moreUrl )) return section.Title;
            if (moreUrl.Equals( "#" )) return section.Title;
            if (isUrl( moreUrl )) return string.Format( "<a href=\"{0}\">{1}</a>", moreUrl, section.Title );

            return section.Title;
        }
 // TODO 封装
 private String getSectionContent( ContentSection section ) {
     String content;
     if (section.ServiceId <= 0) {
         content = getData( section );
     } else {
         content = getAutoData( section );
     }
     return content;
 }
        // wojilu.Web.Controller.Content.Section.TextController => Content/Section/Text/SectionShow
        private static String getTemplatePath( ContentSection s ) {
            String tpath = strUtil.TrimStart( s.SectionType, "wojilu.Web.Controller." );
            tpath = strUtil.TrimEnd( tpath, "Controller" );
            tpath = tpath.Replace( ".", "/" );

            tpath = strUtil.Join( tpath, "SectionShow" );

            return tpath;
        }
Пример #13
0
        public static void loadTemplate( ControllerBase controller, ContentSection s, IContentCustomTemplateService ctService )
        {
            if (s.CustomTemplateId <= 0) return;

            ContentCustomTemplate ct = ctService.GetById( s.CustomTemplateId, controller.ctx.owner.Id );
            if (ct == null) return;

            controller.viewContent( ct.Content );
        }
Пример #14
0
        public void ContentSection_contains_list_of_styles()
        {
            // Arrange
            var contentSection = new ContentSection();

            // Act / Assert
            Assert.That(contentSection.Styles, Is.Not.Null);
            Assert.That(contentSection.Styles, Is.Empty);
        }
Пример #15
0
        public void ContentSection_contains_html_fragment()
        {
            // Arrange
            const string content = "<div id=\"test\">test</div>";
            var contentSection = new ContentSection { Html = content };

            // Act / Assert
            Assert.That(contentSection.Html, Is.EqualTo(content));
        }
Пример #16
0
 public virtual List<ContentSection> GetForCombine( ContentSection section )
 {
     List<ContentSection> sections = GetByApp( section.AppId );
     List<ContentSection> list = new List<ContentSection>();
     foreach (ContentSection s in sections) {
         if (s.Id != section.Id && notCombined( sections, s )) list.Add( s );
     }
     return list;
 }
Пример #17
0
        public void Bind( ContentSection section, IList serviceData )
        {
            IBlock fblock = getBlock( "focus" );
            IBlock block = getBlock( "list" );
            if (serviceData.Count == 0) return;

            bindFocus( fblock, (ContentPost)serviceData[0] ); // 第一篇是焦点要闻
            bindPickedList( serviceData, block );
        }
        public void Bind( ContentSection section, IList serviceData )
        {
            TemplateUtil.loadTemplate( this, section, ctService );

            User user = ctx.owner.obj as User;
            if (user == null) return;

            bind( "user", new UserVo( user ) );
        }
Пример #19
0
        private void bindSectionShow( ContentSection section, List<ContentPost> posts )
        {
            set( "m.Title", section.Title );
            IBlock block = getBlock( "list" );
            foreach (ContentPost post in posts) {
                BinderUtils.bindPostSingle( block, post );

                block.Next();
            }
        }
Пример #20
0
        public void Bind( ContentSection section, IList serviceData )
        {
            User user = ctx.owner.obj as User;

            if (user == null) {
                content( "" );
                return;
            }

            bindFace( user );
        }
Пример #21
0
        public static ContentSection PopulateFeed( int layoutId, MvcContext ctx )
        {
            ContentSection section = new ContentSection();
            section.AppId = ctx.app.Id;

            String layoutStr = layoutId.ToString();
            int rowId = cvt.ToInt( layoutStr.Substring( 0, layoutStr.Length - 1 ) );
            int columnId = cvt.ToInt( layoutStr.Substring( layoutStr.Length - 1, 1 ) );
            section.RowId = rowId;
            section.ColumnId = columnId;
            return section;
        }
Пример #22
0
        private void bindPosts( ContentSection section, DataPage<ContentPost> posts ) {
            set( "section.Name", section.Title );
            IBlock block = getBlock( "list" );
            foreach (ContentPost post in posts.Results) {
                block.Set( "img.Url", alink.ToAppData( post, ctx ) );

                block.Set( "img.Thumb", post.GetImgThumb() );
                block.Set( "img.Title", post.Title );
                block.Set( "img.Description", strUtil.CutString( post.Content, 8 ) );
                block.Next();
            }
        }
        private String getJsonResult( ContentSection section, IList data ) {

            String jsonStr = Json.ToString( data );
            String scriptData = string.Format( "	<script>var sectionData{0} = {1};</script>", section.Id, jsonStr );
            if (section.CustomTemplateId <= 0)
                return scriptData;

            ContentCustomTemplate ct = ctService.GetById( section.CustomTemplateId, ctx.owner.Id );
            if (ct == null) return scriptData;

            return scriptData + ct.Content;
        }
Пример #24
0
        public virtual void Bind( ContentSection section, IList serviceData ) {

            IBlock block = base.getBlock( "list" );

            int i = 1;
            foreach (IBinderValue item in serviceData) {

                BinderUtils.bindMashupData( block, item, i, ctx );
                block.Next();
                i++;
            }
        }
Пример #25
0
        private void bindSectionShow( ContentSection section, IList posts ) {
            set( "m.Title", section.Title );
            IBlock block = getBlock( "list" );
            foreach (ContentPost post in posts) {
                block.Set( "post.Author", post.Author );
                block.Set( "post.Title", post.Title );
                block.Set( "post.Url", alink.ToAppData( post ) );
                block.Set( "post.Content", post.Content );

                block.Bind( "post", post );
                block.Next();
            }
        }
Пример #26
0
 private void bindAdminList( ContentSection section, DataPage<ContentPost> posts ) {
     set( "section.Title", section.Title );
     IBlock block = getBlock( "list" );
     foreach (ContentPost post in posts.Results) {
         block.Set( "post.Content", getContent( post ) );
         block.Set( "post.OrderId", post.OrderId );
         block.Set( "post.PubDate", post.Created );
         block.Set( "post.EditUrl", to( Edit, post.Id ) );
         block.Set( "post.DeleteUrl", to( Delete, post.Id ) );
         block.Next();
     }
     set( "page", posts.PageBar );
 }
Пример #27
0
        private void bindMetaInfo( ContentSection section )
        {
            ctx.Page.SetTitle( section.Title, ctx.app.Name );

            if (strUtil.HasText( section.MetaKeywords )) {
                ctx.Page.Keywords = section.MetaKeywords;
            }
            else {
                ctx.Page.Keywords = section.Title;
            }

            ctx.Page.Description = section.MetaDescription;
        }
        private String getAutoData( ContentSection section ) {

            Dictionary<string, string> presult = getDefaultValue( section );

            IList data = ServiceContext.GetData( section.ServiceId, section.GetServiceParamValues(), presult );

            if (section.TemplateId <= 0) return getJsonResult( section, data );

            ISectionBinder binder = BinderUtils.GetBinder( section, ctx );
            binder.Bind( section, data );
            ControllerBase sectionController = binder as ControllerBase;
            return sectionController.utils.getActionResult();
        }
Пример #29
0
        private void showInfo( ContentSection section ) {

            //1)location
            String location = string.Format( "<a href='{0}'>{1}</a> &gt; {2}",
                alink.ToApp( ctx.app.obj as IApp, ctx ),
                ctx.app.Name,
                "分类查看"
            );

            set( "location", location );

            bindMetaInfo( section );
        }
        public void Bind( ContentSection section, IList serviceData )
        {
            TemplateUtil.loadTemplate( this, section, ctService );

            User user = ctx.owner.obj as User;

            if (user == null) {
                actionContent( "" );
                return;
            }

            bindFace( user );
        }
Пример #31
0
        //---------------------------------------------------------------------------------------------


        public virtual List <ContentPost> GetBySection(long sectionId)
        {
            ContentSection s = ContentSection.findById(sectionId);

            return(this.GetBySection(sectionId, s.ListCount));
        }
Пример #32
0
 private void bindAddInfo(ContentSection section)
 {
     set("module.Name", section.Title);
     set("module.Id", section.Id);
 }
Пример #33
0
        public virtual List <ContentPost> GetTopBySectionAndCategory(long sectionId, long categoryId)
        {
            ContentSection s = ContentSection.findById(sectionId);

            return(GetTopBySectionAndCategory(sectionId, categoryId, s.ListCount));
        }