Example #1
0
        private void bindDetail( ContentPost post, ContentPoll poll )
        {
            set( "post.Title", post.Title );
            set( "post.CreateTime", post.Created );
            set( "post.ReplyCount", post.Replies );
            set( "post.Hits", post.Hits );
            set( "post.Source", post.SourceLink );

            ctx.SetItem( "ContentPost", post );
            ctx.SetItem( "poll", poll );
            ctx.SetItem( "sectionId", post.PageSection.Id );

            User user = (User)ctx.viewer.obj;
            Boolean hasVote = poll.CheckHasVote( user.Id );

            if (hasVote)
                set( "post.Content", loadHtml( sectionPollResult ) );
            else
                set( "post.Content", loadHtml( sectionPoll ) );
        }
Example #2
0
        private void bindPollSection( int sectionId, ContentPoll c )
        {
            set( "addLink", to( Add, sectionId ) );
            set( "listLink", to( List, sectionId ) );
            set( "section.Id", sectionId );

            if (c != null) {
                set( "poll.Title", c.Title );

                set( "poll.Question", c.Question );

                // 显示投票选项
                ctx.SetItem( "sectionId", sectionId );
                String html = ExtData.GetExtView( c.Id, typeof( ContentPost ).FullName, typeof( ContentPoll ).FullName, ctx );

                set( "poll.Html", html );
            }
            else {
                set( "poll.Title", alang( "exPollNotAdd" ) );
                set( "poll.Question", "" );
                set( "poll.Html", "" );
            }
        }
Example #3
0
        protected void createPoll( ContentSection s, String title, List<String> options )
        {
            ContentPoll p = new ContentPoll();
            p.Title = title;
            p.Question = "";
            p.Answer = getAnswerString( options );

            IMember o = this.owner;
            User u = this.user;

            p.OwnerId = o.Id;
            p.OwnerType = o.GetType().FullName;
            p.OwnerUrl = o.Url;

            p.Creator = u;
            p.CreatorUrl = u.Url;

            p.AppId = s.AppId;

            new ContentPollService().CreatePoll( s.Id, p );
        }
Example #4
0
        private void bindVoter( ContentPoll poll, DataPage<ContentPollResult> voterList ) {

            IBlock block = getBlock( "list" );
            foreach (ContentPollResult result in voterList.Results) {
                block.Set( "user.Name", result.User.Name );
                block.Set( "user.Choice", result.Answer );
                block.Set( "user.Created", result.Created );
                block.Next();
            }

            set( "page", voterList.PageBar );
        }
Example #5
0
 private String getControl( ContentPoll poll, int optionIndex, String optionText ) {
     Html html = new Html();
     if (poll.Type == 1) {
         html.CheckBox( "pollOption", Convert.ToString( (optionIndex + 1) ), optionText );
     }
     else {
         html.Radio( "pollOption", Convert.ToString( (optionIndex + 1) ), optionText );
     }
     return html.ToString();
 }
Example #6
0
        private String getVoterLink( ContentPoll p ) {

            if (p.IsOpenVoter == 0) {
                String url = to( Voter, p.Id );
                return string.Format( "<a href=\"{0}\" class=\"frmBox left10 right10\" target=\"_blank\">投票人数: {1}</a>", url, p.VoteCount );
            }

            return "<span class=\"poll-voter-count\">投票人数: " + p.VoteCount + "</span>";
        }
Example #7
0
 private bool isAuthor( ContentPoll p ) {
     return ctx.viewer.Id == p.Creator.Id;
 }
Example #8
0
 private void bindViewLink( ContentPoll p ) {
     IBlock lnkView = getBlock( "lnkView" );
     IBlock lblView = getBlock( "lblView" );
     if (p.IsVisible == 0 || isAuthor( p ) || ctx.viewer.IsAdministrator() || ctx.viewer.IsOwnerAdministrator( ctx.owner.obj )) {
         lnkView.Set( "topicId", p.TopicId );
         lnkView.Next();
     }
     else {
         lblView.Next();
     }
 }
Example #9
0
        private void bindVoterList( ContentPoll poll, int sectionId )
        {
            ctx.SetItem( "poll", poll );
            ctx.SetItem( "sectionId", sectionId );

            load( "voteResult", sectionPollResult );

            DataPage<ContentPollResult> voterList = pollService.GetVoterList( poll.Id, 10 );
            IBlock block = getBlock( "list" );
            foreach (ContentPollResult result in voterList.Results) {
                block.Set( "user.Name", result.User.Name );
                block.Set( "user.Choice", result.Answer );
                block.Set( "user.Created", result.Created );
                block.Next();
            }
            set( "page", voterList.PageBar );
        }
Example #10
0
        private void bindPollDetail( int sectionId, ContentPoll poll )
        {
            ctx.SetItem( "poll", poll );
            ctx.SetItem( "sectionId", sectionId );

            User user = (User)ctx.viewer.obj;
            Boolean hasVote = poll.CheckHasVote( user.Id );

            if (hasVote)
                actionContent( loadHtml( sectionPollResult ) );
            else
                actionContent( loadHtml( sectionPoll ) );
        }