Wiki source code of recentCommentsUpdater
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
97.16 | 1 | #if($xwiki.hasAdminRights()) |
| |
1.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) | ||
| |
97.1 | 7 | #set($nb = 150) |
| |
1.1 | 8 | #set($formatDate = "yyyy MMMM dd, HH:mm") |
| 9 | #set($list = $xwiki.searchDocuments($sql , $nb , 0)) | ||
| |
84.1 | 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")) | ||
| |
95.1 | 16 | #set($now2 = $now2y * 365 + $now2m * 30 + $now2d + 30) |
| |
1.1 | 17 | #set($count = 0) |
| |
20.1 | 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")) | ||
| |
21.1 | 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)) | ||
| |
60.1 | 40 | #set($date2 = $date2y * 365 + $date2m * 30 + $date2d) |
| |
21.1 | 41 | #end |
| |
47.1 | 42 | ##"Recent" comments should be comments that have been left in the (roughly) last 10 days |
| |
96.1 | 43 | #if(($now2 - $date2)<14) |
| |
47.1 | 44 | ##We don't want to display more than X recent comments, so for increase the comment counter |
| |
21.1 | 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) | ||
| |
20.1 | 52 | #end |
| |
21.1 | 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") | ||
| |
20.1 | 59 | #end |
| |
21.1 | 60 | #set($thestring = "$thestring" + "</span></td></tr>") |
| 61 | #end | ||
| 62 | #elseif($postsPerPage.size()>0) | ||
| |
31.1 | 63 | #set($newestPost = $postsPerPage.lastElement()) |
| |
32.1 | 64 | #set($date = $newestPost.get("postdate")) |
| |
67.1 | 65 | #set($date2dstring = $date.substring(0,2)) |
| 66 | #set($date2mstring = $date.substring(3,5)) | ||
| 67 | #set($date2ystring = $date.substring(6,10)) | ||
| |
71.1 | 68 | #set($dater2d = $mathtool.toInteger("$date2dstring")) |
| |
72.1 | 69 | #set($dater2m = $mathtool.toInteger("$date2mstring")) |
| |
74.1 | 70 | #set($dater2y = $mathtool.toInteger("$date2ystring")) |
| |
83.1 | 71 | #set($dater2 = $dater2y * 365 + $dater2m * 30 + $dater2d) |
| |
47.1 | 72 | ##"Recent" comments should be comments that have been left in the (roughly) last 10 days// |
| |
96.1 | 73 | #if(($now2 - $dater2)<14) |
| |
48.1 | 74 | ## We don't want to display more than X recent comments, so for increase the comment counter// |
| |
46.1 | 75 | #set($count = $count + 1) |
| |
91.1 | 76 | #set($name = $bentrydoc.name) |
| |
90.1 | 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 | ||
| |
45.1 | 83 | #set($newestAuthor = $newestPost.get("postauthor")) |
| 84 | #set($createur = $xwiki.getUserName("$newestAuthor")) | ||
| |
94.1 | 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>") |
| |
45.1 | 86 | #end |
| |
19.1 | 87 | #end |
| 88 | #end | ||
| |
20.1 | 89 | #end |
| |
1.1 | 90 | #end |
| 91 | #set($thestring = "$thestring" + "</table>") | ||
| 92 | $thepage.setContent("$thestring") | ||
| 93 | $thepage.save() | ||
| |
97.16 | 94 | #end |