General Actions:
Log-in
Wiki:
CC09
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
recentCommentsUpdater
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
recentCommentsUpdater
Wiki source code of
recentCommentsUpdater
Last modified by
Holger Dick
on 2009/10/11 21:24
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: 2: 3: #set($thepage = $xwiki.getDocument("XWiki.recentComments")) 4: #set($thestring = "<table class='stats' cellspacing='0' cellpadding='0'>") 5: #set($sql = "where doc.space not like 'Scheduler' and doc.space not like 'Panels' and year(doc.date) = year(current_date()) order by doc.date desc") 6: #set($showdata = 1) 7: #set($nb = 150) 8: #set($formatDate = "yyyy MMMM dd, HH:mm") 9: #set($list = $xwiki.searchDocuments($sql , $nb , 0)) 10: #set($now2y = $datetool.getYear()) 11: ##set($now2y = $mathtool.toInteger("$now2ystring")) 12: #set($now2m = $datetool.getMonth()) 13: ##set($now2m = $mathtool.toInteger("$now2mstring")) 14: #set($now2d = $datetool.getDay()) 15: ##set($now2d = $mathtool.toInteger("$now2dstring")) 16: #set($now2 = $now2y * 365 + $now2m * 30 + $now2d + 30) 17: #set($count = 0) 18: #foreach ($item in $list) 19: #if ($count < 5) 20: #set($troubi ="non") 21: #if ($xwiki.hasAccessLevel("view", $context.user, "${context.database}:${item}")) 22: #set($bentrydoc = $xwiki.getDocument($item)) 23: #set($cclass = $xwiki.getDocument("XWiki.XWikiComments").getxWikiClass()) 24: #set($comment = $cclass.newObject()) 25: #if($xwiki.getWebPreferenceAsInt("commentsorder",1)==0) 26: #set($comments = $bentrydoc.getComments()) 27: #else 28: #set($comments = $bentrydoc.getComments(false)) 29: #end 30: #set($postsPerPage = $bentrydoc.getObjects("BBCode.PostClass")) 31: #if($comments.size()>0) 32: #set($i = 0) 33: #set($cobj = $comments.get($i)) 34: #set($comment = $bentrydoc.display("comment", "view", $cobj)) 35: #set($date = $cobj.getXWikiObject().get("date").value) 36: #if($date) 37: #set($date2y = $datetool.getYear($date)) 38: #set($date2m = $datetool.getMonth($date)) 39: #set($date2d = $datetool.getDay($date)) 40: #set($date2 = $date2y * 365 + $date2m * 30 + $date2d) 41: #end 42: ##"Recent" comments should be comments that have been left in the (roughly) last 10 days 43: #if(($now2 - $date2)<14) 44: ##We don't want to display more than X recent comments, so for increase the comment counter 45: #set($count = $count + 1) 46: #set($name = $bentrydoc.name) 47: #if($name.length() >= 22) 48: #set($names= "${name.substring(0, 20)}") 49: #set($names= $names.concat('...')) 50: #else 51: #set($names= $name) 52: #end 53: #set($createur = $xwiki.getUserName($cobj.author)) 54: #set($thestring = "$thestring" + "<tr><td style='border-width: 0px 0px 1px 0px; border-style: dashed; border-color: white;'>[$names>${bentrydoc.fullName}]<br/><span style='font-size: 0.7em; text-indent: 70px;'> $xwiki.formatDate($date,'MMM dd') by ") 55: #if ($createur == 'XWikiGuest') 56: #set($thestring = "$thestring" + "Guest") 57: #else 58: #set($thestring = "$thestring" + "$createur") 59: #end 60: #set($thestring = "$thestring" + "</span></td></tr>") 61: #end 62: #elseif($postsPerPage.size()>0) 63: #set($newestPost = $postsPerPage.lastElement()) 64: #set($date = $newestPost.get("postdate")) 65: #set($date2dstring = $date.substring(0,2)) 66: #set($date2mstring = $date.substring(3,5)) 67: #set($date2ystring = $date.substring(6,10)) 68: #set($dater2d = $mathtool.toInteger("$date2dstring")) 69: #set($dater2m = $mathtool.toInteger("$date2mstring")) 70: #set($dater2y = $mathtool.toInteger("$date2ystring")) 71: #set($dater2 = $dater2y * 365 + $dater2m * 30 + $dater2d) 72: ##"Recent" comments should be comments that have been left in the (roughly) last 10 days// 73: #if(($now2 - $dater2)<14) 74: ## We don't want to display more than X recent comments, so for increase the comment counter// 75: #set($count = $count + 1) 76: #set($name = $bentrydoc.name) 77: #if($name.length() >= 22) 78: #set($names= "${name.substring(0, 20)}") 79: #set($names= $names.concat('...')) 80: #else 81: #set($names= $name) 82: #end 83: #set($newestAuthor = $newestPost.get("postauthor")) 84: #set($createur = $xwiki.getUserName("$newestAuthor")) 85: #set($thestring = "$thestring" + "<tr><td style='border-width: 0px 0px 1px 0px; border-style: dashed; border-color: white;'>[$names>${bentrydoc.fullName}]<br/><span style='font-size: 0.7em; text-indent: 70px;'> " + "$date.substring(0,10)" +" by " + "$createur" + "</span></td></tr>") 86: #end 87: #end 88: #end 89: #end 90: #end 91: #set($thestring = "$thestring" + "</table>") 92: $thepage.setContent("$thestring") 93: $thepage.save()
Quick Links
Wiki Dashboard
Document Index
Blog
Sandbox
My Recent Modifications
recentComments