Исходный код вики Sheet for displaying polls in view mode
Редактировал(а) Андрей Ганьков 2024/04/25 09:20
Последние авторы
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{include reference="Polls.Macros"/}} | ||
| 2 | |||
| 3 | {{velocity}} | ||
| 4 | $xwiki.jsx.use($pollScript)## | ||
| 5 | $xwiki.ssx.use($pollStyle)## | ||
| 6 | #poll_readPollData($doc) | ||
| 7 | #if("$!{pollObj}" != '') | ||
| 8 | ## | ||
| 9 | ## | ||
| 10 | ## | ||
| 11 | #set($choices = $pollObj.getProperty('optionsPerVoter').value) | ||
| 12 | #if($pollType == 'multiple' || $pollType == 'weighted') | ||
| 13 | #if("$!{choices}" == '' || $choices > $options.size()) | ||
| 14 | #set($choices = $options.size()) | ||
| 15 | #end | ||
| 16 | #end | ||
| 17 | #if($pollType == 'rating' && ($choices > $pollMaxRatingLevel || $choices <= 0)) | ||
| 18 | #set($choices = $pollMaxRatingLevel) | ||
| 19 | #end | ||
| 20 | #if($pollType == 'ranking' || $pollType == 'weighted') | ||
| 21 | $xwiki.jsfx.use('js/scriptaculous/scriptaculous.js')## | ||
| 22 | #end | ||
| 23 | #if("$!{request.xaction}" == 'vote') | ||
| 24 | #if ($pollType == 'single') | ||
| 25 | #poll_voteSingle() | ||
| 26 | #elseif($pollType == 'multiple') | ||
| 27 | #poll_voteMultiple($choices) | ||
| 28 | #elseif ($pollType == 'weighted') | ||
| 29 | #poll_voteWeighted($choices $options) | ||
| 30 | #elseif ($pollType == 'rating') | ||
| 31 | #poll_voteRating($choices $options) | ||
| 32 | #elseif ($pollType == 'ranking') | ||
| 33 | #poll_voteRanking($options) | ||
| 34 | #end | ||
| 35 | #end## done processing the vote | ||
| 36 | ## | ||
| 37 | ## | ||
| 38 | ## | ||
| 39 | {{html clean="false" wiki="true"}} | ||
| 40 | <div class="poll-question">$pollObj.question</div> | ||
| 41 | ## | ||
| 42 | ## Can this user vote? Is the poll open? | ||
| 43 | ## | ||
| 44 | #set($canVote = (!$isGuest && $hasEdit)) | ||
| 45 | #if(!$canVote) | ||
| 46 | |||
| 47 | |||
| 48 | {{warning}}$msg.get('polls.vote.warning.unauthorized'){{/warning}} | ||
| 49 | |||
| 50 | #end | ||
| 51 | #set($from = $pollObj.getProperty('from').value) | ||
| 52 | #set($to = $pollObj.getProperty('to').value) | ||
| 53 | #if ($xwiki.jodatime) | ||
| 54 | ## getDateTimeFormatterForStyle("SS") | ||
| 55 | #set($prettyFrom = $xwiki.jodatime.getDateTimeFormatterForPattern("d MMMM YYYY, H:mm").print($from.getTime())) | ||
| 56 | #set($prettyTo = $xwiki.jodatime.getDateTimeFormatterForPattern("d MMMM YYYY, H:mm").print($to.getTime())) | ||
| 57 | #else | ||
| 58 | #set($prettyFrom = "$!{from}") | ||
| 59 | #set($prettyTo = "$!{to}") | ||
| 60 | #end | ||
| 61 | #if("$!{to}" != '' && $util.date.after(${to})) | ||
| 62 | #set($when = 'after') | ||
| 63 | <div class="box poll-calendar poll-closed">$msg.get('polls.vote.timeline.closed')</div> | ||
| 64 | #elseif("$!{from}" != '' && $util.date.before(${from})) | ||
| 65 | #set($when = 'before') | ||
| 66 | <div class="box poll-calendar poll-not-open">$msg.get('polls.vote.timeline.notOpen', ["//${prettyFrom}//", "//${prettyTo}//"])</div> | ||
| 67 | #else | ||
| 68 | #set($when = 'during') | ||
| 69 | <div class="box poll-calendar poll-open">$msg.get('polls.vote.timeline.ongoing', ["//${prettyFrom}//", "//${prettyTo}//"])</div> | ||
| 70 | #end | ||
| 71 | #set($canVote = $canVote && $when == 'during') | ||
| 72 | ## | ||
| 73 | ## Display the voting form if applicable | ||
| 74 | ## | ||
| 75 | #if ($canVote) | ||
| 76 | <input type="hidden" id="polltype" value="${pollType}"/> | ||
| 77 | <div class="poll-instructions"> | ||
| 78 | #if($pollType == 'ranking') | ||
| 79 | <span id='ranking-instructions-no-script'>$msg.get("polls.vote.instructions.${pollType}.noscript")</span><span id='ranking-instructions-js-tool' class='hidden'>$msg.get("polls.vote.instructions.${pollType}.script")</span> | ||
| 80 | #else | ||
| 81 | $msg.get("polls.vote.instructions.${pollType}", ["$!{choices}"]) | ||
| 82 | #end | ||
| 83 | </div> | ||
| 84 | <form action="" method="post"> | ||
| 85 | <div class="poll-options"> | ||
| 86 | #set($userVotes = $doc.getObjects($pollVoteClass, 'voter', ${context.user})) | ||
| 87 | #if($userVotes.size() > 0) | ||
| 88 | <label class="poll-voted-label">$msg.get('polls.vote.label.voted')</label> | ||
| 89 | #end | ||
| 90 | #poll_displayOptions($pollObj $options $userVotes) | ||
| 91 | </div> | ||
| 92 | <div class="buttons"> | ||
| 93 | <input type="hidden" name="xaction" value="vote"/> | ||
| 94 | <span class="buttonwrapper"><input class="button" type="submit" value="#if($userVotes.size() > 0) $msg.get('polls.vote.actions.updateVote') #else $msg.get('polls.vote.actions.vote') #end"/></span> | ||
| 95 | <a href="$xwiki.getURL(${pollsHome})" class="secondary button">$msg.get('polls.vote.actions.cancel')</a> | ||
| 96 | </div> | ||
| 97 | </form> | ||
| 98 | #end | ||
| 99 | ## | ||
| 100 | ## Display the results | ||
| 101 | ## | ||
| 102 | #set($votes = $doc.getObjects($pollVoteClass)) | ||
| 103 | #if ($votes.size() > 0) | ||
| 104 | == $msg.get("polls.vote.results.title.${when}") == | ||
| 105 | #poll_results($pollObj $pollType $options $votes true true) | ||
| 106 | #end ## votes.size | ||
| 107 | ## | ||
| 108 | ## Results done | ||
| 109 | ## | ||
| 110 | {{/html}}## | ||
| 111 | #end## poll object exists | ||
| 112 | {{/velocity}} |