public void Edit(int postId) { ContentPost post = topicService.GetById(postId, ctx.owner.Id); if (post == null) { throw new NullReferenceException("Edit Poll, ContentPost"); } ContentPoll poll = pollService.GetByTopicId(postId); if (poll == null) { throw new NullReferenceException("Edit Poll, ContentPoll"); } target(Update, post.Id); bindEditInfo(post); List <ContentSection> sectionList = sectionService.GetInputSectionsByApp(ctx.app.Id); String sectionIds = sectionService.GetSectionIdsByPost(post.Id); checkboxList("postSection", sectionList, "Title=Id", 0); set("sectionIds", sectionIds); }
//--------------------------------------------------------------------------------- public void Show(int id) { ContentPoll p = pollService.GetByTopicId(id); ctx.SetItem("poll", p); actionContent(loadHtml(Detail)); }
public void Show(int id) { ContentPost post = postService.GetById(id, ctx.owner.Id); ContentPoll poll = pollService.GetByTopicId(id); set("lnkPoll", to(new wojilu.Web.Controller.Content.Common.PollController().Show, post.Id)); }
public void Detail() { ContentPoll p = ctx.GetItem("poll") as ContentPoll; if (p == null) { set("pollForm", ""); set("pollResult", ""); return; } set("topicId", p.TopicId); set("poll.Id", p.Id); set("poll.VoteLink", to(Vote, p.Id)); set("resultLink", to(GetPollResultHtml, p.Id)); String hideCss = "display:none;"; if (p.CheckHasVote(ctx.viewer.Id) || (p.IsClosed() && p.IsVisible == 0)) { set("formStyle", hideCss); set("resultStype", ""); } else { set("formStyle", ""); set("resultStype", hideCss); } load("pollForm", pollForm); load("pollResult", pollResult); }
public void Update(int postId) { ContentPost post = topicService.GetById(postId, ctx.owner.Id); if (post == null) { echo(lang("exDataNotFound")); return; } post = ContentValidator.SetPostValue(post, ctx); String sectionIds = sectionService.GetSectionIdsByPost(post.Id); topicService.Update(post, sectionIds, ctx.Post("TagList")); // update Poll ContentPoll poll = pollService.GetByTopicId(postId); poll.Title = post.Title; poll.Created = post.Created; poll.Hits = post.Hits; pollService.Update(poll); echoToParentPart(lang("opok")); HtmlHelper.SetPostToContext(ctx, post); }
public void AdminSectionShow(int sectionId) { set("section.Id", sectionId); set("addLink", to(new Admin.Common.PollController().Add, sectionId)); set("listLink", to(new Admin.Common.PollController().AdminList, sectionId)); ContentSection section = sectionService.GetById(sectionId, ctx.app.Id); List <ContentPost> posts = postService.GetBySection(sectionId, section.ListCount); List <ContentPoll> polls = pollService.GetByTopicList(posts); IBlock block = getBlock("list"); foreach (ContentPost x in posts) { ContentPoll p = pollService.GetByTopicId(polls, x.Id); String editLink = string.Format("<a href=\"{0}\" class=\"frmBox\"><img src=\"{1}edit.gif\" />{2}</a>", to(new Admin.Common.PollController().Edit, x.Id), sys.Path.Img, lang("edit")); block.Set("editLink", editLink); ctx.SetItem("poll", p); block.Set("pollHtml", loadHtml(new wojilu.Web.Controller.Content.Common.PollController().Detail)); block.Next(); } }
public virtual void GetPollResultHtml(long pollId) { ContentPoll p = pollService.GetById(pollId); ctx.SetItem("poll", p); echo(loadHtml(pollResult)); }
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>"); }
public void Show(int id) { ContentPost post = postService.GetById(id, ctx.owner.Id); ContentPoll poll = pollService.GetByTopicId(id, typeof(ContentPost).FullName); postService.AddHits(post); Page.Title = post.Title; bindDetail(post, poll); }
public void SectionDetail(int sectionId) { ContentPoll c = pollService.GetRecentPoll(ctx.app.Id, sectionId); if (c == null) { actionContent(""); return; } bindPollDetail(sectionId, c); }
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); }
public virtual void Voter(long id) { ContentPoll poll = pollService.GetById(id); if (poll == null) { echoText(lang("exPollItemNotFound")); return; } DataPage <ContentPollResult> voterList = pollService.GetVoterList(id); bindVoter(poll, voterList); }
private String getControl(ContentPoll poll, int optionIndex) { Html html = new Html(); if (poll.Type == 1) { html.CheckBox("pollOption", Convert.ToString((optionIndex + 1)), ""); } else { html.Radio("pollOption", Convert.ToString((optionIndex + 1)), ""); } return(html.ToString()); }
public virtual void pollResult() { ContentPoll p = ctx.GetItem("poll") as ContentPoll; set("topicId", p.TopicId); set("poll.Title", p.Title); set("poll.Question", p.Question); set("poll.Voters", p.VoteCount); set("lnkVoter", getVoterLink(p)); int colorCount = 6; int iColor = 1; IBlock opblock = getBlock("options"); for (int i = 0; i < p.OptionList.Length; i++) { PollHelper or = new PollHelper(p, p.OptionList.Length, i); opblock.Set("op.Text", p.OptionList[i]); opblock.Set("op.Id", (i + 1)); opblock.Set("op.ImgWidth", or.ImgWidth * 1); opblock.Set("op.Percent", or.VotesAndPercent); opblock.Set("op.ColorIndex", iColor); opblock.Next(); iColor++; if (iColor > colorCount) { iColor = 1; } } set("poll.ExpiryInfo", p.GetRealExpiryDate()); IBlock btnVote = getBlock("btnVote"); IBlock lblVoted = getBlock("lblVoted"); if (p.CheckHasVote(ctx.viewer.Id)) { lblVoted.Next(); } else if (p.IsClosed() == false) { btnVote.Next(); } }
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(); } }
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)); } }
public void VoteResult(int pollId) { int sectionId = ctx.GetInt("sectionId"); ContentPoll poll = pollService.GetById(pollId); if (poll == null) { actionContent(lang("exPollNotFound")); return; } ctx.SetItem("poll", poll); ctx.SetItem("sectionId", sectionId); load("voteResult", sectionPollResult); }
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); }
private void populatePoll(List <ContentPost> list, List <ContentPoll> polls) { foreach (ContentPost x in list) { ContentPoll poll = getPollByPost(polls, x); if (poll == null) { x.data["VoteCount"] = "0"; x.data["Option1"] = ""; x.data["Option2"] = ""; } else { x.data["VoteCount"] = poll.VoteCount.ToString(); x.data["Option1"] = getOption(poll.OptionList[0], poll.Type); x.data["Option2"] = getOption(poll.OptionList[1], poll.Type); } } }
public void Vote(int pollId) { int sectionId = ctx.GetInt("sectionId"); ContentPoll poll = pollService.GetById(pollId); if (poll == null) { actionContent(lang("exPollNotFound")); return; } ContentPost post = postService.GetById(poll.TopicId, ctx.owner.Id); if (post == null || post.PageSection.Id != sectionId) { actionContent(lang("exPollNotFound")); return; } if (poll.CheckHasVote(ctx.viewer.Id)) { actionContent(alang("exVoted")); return; } String choice = ctx.Get("pollOption"); ContentPollResult pr = new ContentPollResult(); pr.User = (User)ctx.viewer.obj; pr.PollId = poll.Id; pr.Answer = choice; pr.Ip = ctx.Ip; //String lnkPoll = to( Show, poll.TopicId ); String lnkPoll = alink.ToAppData(post); pollService.CreateResult(pr, lnkPoll); String url = to(VoteResult, poll.Id) + "?sectionId=" + sectionId; echoRedirect(alang("pollDone"), url); }
public virtual void pollForm() { ContentPoll p = ctx.GetItem("poll") as ContentPoll; set("topicId", p.TopicId); set("resultLink", to(GetPollResultHtml, p.Id)); 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)); IBlock opblock = getBlock("options"); for (int i = 0; i < p.OptionList.Length; i++) { opblock.Set("op.SelectControl", getControl(p, i, p.OptionList[i])); opblock.Set("op.Id", (i + 1)); opblock.Next(); } IBlock cmdBlock = getBlock("cmdVote"); // 投票命令 IBlock tipBlock = getBlock("plsVote"); // 请先登录 if (p.IsClosed()) { } else if (ctx.viewer.IsLogin) { cmdBlock.Next(); } else { tipBlock.Next(); } bindViewLink(p); set("poll.ExpiryInfo", p.GetRealExpiryDate()); }
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 ) ); }
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)); }
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); }
public void Voter(int pollId) { int sectionId = ctx.GetInt("sectionId"); ContentPoll poll = pollService.GetById(pollId); if (poll == null) { actionContent(lang("exPollNotFound")); return; } ContentPost post = postService.GetById(poll.TopicId, ctx.owner.Id); if (post == null) { //if (post == null || post.PageSection.Id != sectionId) { actionContent(lang("exPollNotFound")); return; } bindVoterList(poll, sectionId); }
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", "" ); } }
public virtual void Vote(long id) { ContentPoll poll = pollService.GetById(id); if (poll == null) { echoError(lang("exPollItemNotFound")); return; } if (poll.CheckHasVote(ctx.viewer.Id)) { echoError(lang("exVoted")); return; } String choice = ctx.Post("pollOption"); if (strUtil.IsNullOrEmpty(choice)) { echoError(lang("pollSelectRequire")); return; } ContentPollResult pollResult = new ContentPollResult(); pollResult.User = (User)ctx.viewer.obj; pollResult.PollId = poll.Id; pollResult.Answer = choice; pollResult.Ip = ctx.Ip; String lnkPost = to(new Content.PostController().Show, poll.TopicId); pollService.CreateResult(pollResult, lnkPost); echoAjaxOk(); }
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 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)); } }
private bool isAuthor(ContentPoll p) { return(ctx.viewer.Id == p.Creator.Id); }
public void AdminSectionShow(int sectionId) { ContentPoll c = pollService.GetRecentPoll(ctx.app.Id, sectionId); bindPollSection(sectionId, c); }
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 ) ); }
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 ); }
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 ); }
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(); }
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>"; }
private bool isAuthor( ContentPoll p ) { return ctx.viewer.Id == p.Creator.Id; }
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(); } }
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 ); }