public virtual String GetJsonResult() { int total = poll.VoteCount; //{total:6, results:[{ "ImgWidth":1, "Votes":0, "Percent":"0" }, { "ImgWidth":166, "Votes":5, "Percent":"83" }, { "ImgWidth":34, "Votes":1, "Percent":"17" }, { "ImgWidth":1, "Votes":0, "Percent":"0" }, { "ImgWidth":1, "Votes":0, "Percent":"0" }]}; String json = "{total:"; json += poll.VoteCount; json += ", results:["; string[] optionList = poll.OptionList; for (int i = 0; i < optionList.Length; i++) { OptionResult opr = new OptionResult(poll, optionList.Length, i); json += Json.ToString(opr); if (i != optionList.Length - 1) { json += ", "; } } json += "]}"; return(json); }
public void sectionPollResult() { PollData p = ctx.GetItem( "poll" ) as PollData; bindPollItem( p ); set( "poll.ResultLink", to( Voter, p.Id ) ); IBlock opblock = getBlock( "options" ); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult( p, p.OptionList.Length, i ); opblock.Set( "op.Text", p.OptionList[i] ); opblock.Set( "op.Id", (i + 1) ); opblock.Set( "op.ImgWidth", or.ImgWidth * 0.5 ); opblock.Set( "op.Percent", or.VotesAndPercent ); opblock.Next(); } set( "poll.ExpiryInfo", PollUtil.GetRealExpiryDate( p ) ); }
private String GetImgAndCountInfo() { if (poll.VoteCount <= 0) return string.Empty; OptionResult opr = new OptionResult( poll, optionCount, optionIndex ); StringBuilder builder = new StringBuilder(); String imgV = strUtil.Join( sys.Path.Skin, "apps/forum/vote.gif" ); builder.AppendFormat( "<img src='{0}' style='width:{1}px;height:9px;' />", imgV, opr.ImgWidth ); builder.Append( "<span class='pollOptionVotes'>" ); builder.Append( opr.Votes ); builder.Append( "(" ); builder.Append( opr.Percent ); builder.Append( "%)</span>" ); return builder.ToString(); }
public virtual String GetJsonResult() { int total = poll.VoteCount; //{total:6, results:[{ "ImgWidth":1, "Votes":0, "Percent":"0" }, { "ImgWidth":166, "Votes":5, "Percent":"83" }, { "ImgWidth":34, "Votes":1, "Percent":"17" }, { "ImgWidth":1, "Votes":0, "Percent":"0" }, { "ImgWidth":1, "Votes":0, "Percent":"0" }]}; String json = "{total:"; json += poll.VoteCount; json += ", results:["; string[] optionList = poll.OptionList; for (int i = 0; i < optionList.Length; i++) { OptionResult opr = new OptionResult( poll, optionList.Length, i ); json += Json.ToString( opr ); if (i != optionList.Length - 1) json += ", "; } json += "]}"; return json; }
private String GetImgAndCountInfo() { if (poll.VoteCount <= 0) { return(string.Empty); } OptionResult opr = new OptionResult(poll, optionCount, optionIndex); StringBuilder builder = new StringBuilder(); String imgV = strUtil.Join(sys.Path.Skin, "apps/forum/vote.gif"); builder.AppendFormat("<img src='{0}' style='width:{1}px;height:9px;' />", imgV, opr.ImgWidth); builder.Append("<span class='pollOptionVotes'>"); builder.Append(opr.Votes); builder.Append("("); builder.Append(opr.Percent); builder.Append("%)</span>"); return(builder.ToString()); }
public void sectionPollResult() { int sectionId = (int)ctx.GetItem( "sectionId" ); ContentPoll p = ctx.GetItem( "poll" ) as ContentPoll; set( "poll.Title", p.Title ); set( "poll.Question", p.Question ); set( "poll.Voters", p.VoteCount ); set( "poll.ResultLink", to( Voter, p.Id ) + "?sectionId=" + sectionId ); IBlock opblock = getBlock( "options" ); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult( p, p.OptionList.Length, i ); opblock.Set( "op.Text", p.OptionList[i] ); opblock.Set( "op.Id", (i + 1) ); opblock.Set( "op.ImgWidth", or.ImgWidth * 0.5 ); opblock.Set( "op.Percent", or.VotesAndPercent ); opblock.Next(); } set( "poll.ExpiryInfo", PollUtil.GetRealExpiryDate( p ) ); }
private void sectionPoll() { PollData p = ctx.GetItem( "poll" ) as PollData; bindPollItem( p ); set( "poll.VoteLink", to( Vote, p.Id ) ); IBlock opblock = getBlock( "options" ); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult( p, p.OptionList.Length, i ); opblock.Set( "op.SelectControl", getControl( p, i ) ); opblock.Set( "op.Text", p.OptionList[i] ); opblock.Set( "op.Id", (i + 1) ); opblock.Next(); } IBlock cmdBlock = getBlock( "cmdVote" ); IBlock tipBlock = getBlock( "plsVote" ); if (PollUtil.IsClosed( p )) { } else if (ctx.viewer.IsLogin) { cmdBlock.Next(); } else { tipBlock.Next(); } set( "poll.ExpiryInfo", PollUtil.GetRealExpiryDate( p ) ); }
private void sectionPoll() { int sectionId = (int)ctx.GetItem( "sectionId" ); ContentPoll p = ctx.GetItem( "poll" ) as ContentPoll; set( "section.Id", sectionId ); set( "poll.Id", p.Id ); set( "poll.Title", p.Title ); set( "poll.Question", p.Question ); set( "poll.Voters", p.VoteCount ); set( "poll.VoteLink", to( Vote, p.Id ) + "?sectionId=" + sectionId ); IBlock opblock = getBlock( "options" ); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult( p, p.OptionList.Length, i ); opblock.Set( "op.SelectControl", getControl( p, i ) ); opblock.Set( "op.Text", p.OptionList[i] ); opblock.Set( "op.Id", (i + 1) ); opblock.Next(); } IBlock cmdBlock = getBlock( "cmdVote" ); IBlock tipBlock = getBlock( "plsVote" ); if (PollUtil.IsClosed( p )) { } else if (ctx.viewer.IsLogin) { cmdBlock.Next(); } else { tipBlock.Next(); } set( "poll.ExpiryInfo", PollUtil.GetRealExpiryDate( p ) ); }