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
Hide line numbers
1: <% 2: urating = '' 3: upcount = 0 4: downcount = 0 5: rpage = xwiki.getDocument("XWiki.RatStats") 6: def robj 7: upactive = '' 8: downactive = '' 9: def usersRating 10: currentPage = context.getDoc().toString() 11: currentUser = context.getUser().toString() 12: i = 0 13: 14: allRatings = rpage.getObjects('XWiki.RatingClass') 15: if(currentUser != 'XWiki.XWikiGuest') 16: { 17: //go through all ratings and adjust the counter accordingly 18: for(aRating in allRatings) 19: { 20: pagename = rpage.display('page', aRating) 21: //if there is a rating for the current page... 22: if(pagename == currentPage) 23: { 24: rating = rpage.display("rating", aRating).toInteger() 25: user = rpage.display('user', aRating) 26: //...check whether the rating is positive or negative and change the respective counter 27: if(rating > 3) 28: { 29: upcount++ 30: }else{ 31: downcount++ 32: } 33: //if there is a rating from the current user... 34: if(user == currentUser) 35: { 36: //don't create a new object but select the existing one 37: robj = rpage.getObject('XWiki.RatingClass', i) 38: usersRating = rating 39: } 40: } 41: i++ 42: } 43: if(request.action == 'up') 44: { 45: if(usersRating <= 0) 46: { 47: println "New" 48: robj = rpage.newObject("XWiki.RatingClass") 49: robj.set("page", currentPage) 50: robj.set("user", currentUser) 51: upcount++ 52: %> #info('Thank You For Your Rating!') <% 53: } 54: else if(usersRating == 5) 55: { 56: %> #info('Nothing Changed!') <% 57: } 58: else 59: { 60: robj.set("rating", 5) 61: upcount++ 62: downcount-- 63: %> #info('Rating Updated!') <% 64: } 65: rpage.save("New Rating", true) 66: }else if(request.action == 'down') 67: { 68: if(usersRating <= 0) 69: { 70: println "New" 71: robj = rpage.newObject("XWiki.RatingClass") 72: robj.set("page", currentPage) 73: robj.set("user", currentUser) 74: downcount++ 75: %> #info('Thank You For Your Rating!') <% 76: } 77: else if(usersRating == 1) 78: { 79: %> #info('Nothing Changed!') <% 80: } 81: else 82: { 83: robj.set("rating", 1) 84: downcount++ 85: upcount-- 86: %> #info('Rating Updated!') <% 87: } 88: rpage.save("New Rating", true) 89: } 90: } 91: %> 92: 93: <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