General Actions:
Log-in
Wiki:
CreativeIT
▼
:
Document Index
»
Space:
Main
▼
:
Document Index
»
Page:
test3
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
test3
Wiki source code of
test3
Last modified by
Holger Dick
on 2009/07/14 16:56
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
<% urating = '' upcount = 0 downcount = 0 rpage = xwiki.getDocument("XWiki.RatStats") def robj upactive = '' downactive = '' def usersRating currentPage = context.getDoc().toString() currentUser = context.getUser().toString() i = 0 allRatings = rpage.getObjects('XWiki.RatingClass') if(currentUser != 'XWiki.XWikiGuest') { //go through all ratings and adjust the counter accordingly for(aRating in allRatings) { pagename = rpage.display('page', aRating) //if there is a rating for the current page... if(pagename == currentPage) { rating = rpage.display("rating", aRating).toInteger() user = rpage.display('user', aRating) //...check whether the rating is positive or negative and change the respective counter if(rating > 3) { upcount++ }else{ downcount++ } //if there is a rating from the current user... if(user == currentUser) { //don't create a new object but select the existing one robj = rpage.getObject('XWiki.RatingClass', i) usersRating = rating } } i++ } if(request.action == 'up') { if(usersRating <= 0) { println "New" robj = rpage.newObject("XWiki.RatingClass") robj.set("page", currentPage) robj.set("user", currentUser) upcount++ %> #info('Thank You For Your Rating!') <% } else if(usersRating == 5) { %> #info('Nothing Changed!') <% } else { robj.set("rating", 5) upcount++ downcount-- %> #info('Rating Updated!') <% } rpage.save("New Rating", true) }else if(request.action == 'down') { if(usersRating <= 0) { println "New" robj = rpage.newObject("XWiki.RatingClass") robj.set("page", currentPage) robj.set("user", currentUser) downcount++ %> #info('Thank You For Your Rating!') <% } else if(usersRating == 1) { %> #info('Nothing Changed!') <% } else { robj.set("rating", 1) downcount++ upcount-- %> #info('Rating Updated!') <% } rpage.save("New Rating", true) } } %> <span>Rate this Page: so far $upcount <a href="$doc.getURL("view", "action=up")"><img src="/bin/download/XWiki/Rater/Thumb%2Dup.png" alt="Thumb-up.png" title="Give this page a thumbs up"/></a> and $downcount <a href="$doc.getURL("view", "action=down")"><img src="/bin/download/XWiki/Rater/Thumb%2Ddown.png" alt="Thumb-down.png" title="Give this page a thumbs down"/></a></span>
Quick Links
Home
Index
What's New
Blog
Calendar
Photo Albums
Sandbox
Tags
Bulletin Board
My Recent Modifications
PamelaJennings
|
rwakkary
|
HaledenSands
|
ByronLahey