<% /** * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ %> <% NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); NumberFormat percentFormat = NumberFormat.getPercentInstance(locale); %> <% int totalVotes = question.getVotesCount(); for (int i = 0; i < choices.size(); i++) { PollsChoice choice = (PollsChoice)choices.get(i); int choiceVotes = choice.getVotesCount(); String className = "portlet-section-body results-row"; String classHoverName = "portlet-section-body-hover results-row hover"; if (MathUtil.isEven(i)) { className = "portlet-section-alternate results-row alt"; classHoverName = "portlet-section-alternate-hover results-row alt hover"; } double votesPercent = 0.0; if (totalVotes > 0) { votesPercent = (double)choiceVotes / totalVotes; } int votesPixelWidth = 35; if (windowState.equals(WindowState.MAXIMIZED)) { votesPixelWidth = 100; } int votesPercentWidth = (int)Math.floor(votesPercent * votesPixelWidth); %> <% } %>
%
<%= percentFormat.format(votesPercent) %> "> <%= numberFormat.format(choiceVotes) %>
<%= choice.getName() %>. <%= choice.getDescription() %>

: <%= numberFormat.format(totalVotes) %>

: , , , ,

<% PortletURL portletURL = renderResponse.createRenderURL(); portletURL.setWindowState(WindowState.MAXIMIZED); portletURL.setParameter("struts_action", "/polls/view_question"); portletURL.setParameter("redirect", redirect); portletURL.setParameter("questionId", String.valueOf(question.getQuestionId())); List headerNames = new ArrayList(); headerNames.add("user"); headerNames.add("choice"); headerNames.add("vote-date"); SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, null); int total = PollsVoteLocalServiceUtil.getQuestionVotesCount(question.getQuestionId()); searchContainer.setTotal(total); List results = PollsVoteLocalServiceUtil.getQuestionVotes(question.getQuestionId(), searchContainer.getStart(), searchContainer.getEnd()); searchContainer.setResults(results); List resultRows = searchContainer.getResultRows(); for (int i = 0; i < results.size(); i++) { PollsVote vote = (PollsVote)results.get(i); ResultRow row = new ResultRow(vote, vote.getVoteId(), i); // User row.addText(PortalUtil.getUserName(vote.getUserId(), String.valueOf(vote.getUserId()), request)); // Choice PollsChoice choice = vote.getChoice(); row.addText(choice.getName() + ". " + choice.getDescription()); // Vote date row.addText(dateFormatDateTime.format(vote.getVoteDate())); // Add result row resultRows.add(row); } %>

<%= LanguageUtil.format(pageContext, "voting-is-disabled-because-this-poll-expired-on-x", dateFormatDateTime.format(question.getExpirationDate())) %>.