General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
Main
▼
:
Document Index
»
Page:
RecentChanges
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to your wiki
»
Dashboard
»
RecentChanges
Wiki source code of
RecentChanges
Last modified by
Administrator
on 2009/01/30 11:18
Content
·
Comments
(0)
·
Attachments
(2)
·
History
·
Information
Hide line numbers
1: ## 2: ## Recent changes. 3: ## 4: ## Optional parameters : 5: ## 6: ## Parameters which can be set in velocity before including this page or can be passed as HTTP parameters. 7: ## Note that HTTP parameters supercede velocity set variables. 8: ## 9: ## - rcShowMinor (String set to "true" or "false"): show minor edits. 10: ## - rcShowDiff (String set to "true" or "false"): show diff in items. 11: ## - rcShowRss (String set to "true" or "false"): show RSS at the bottom of the list. 12: ## - rcChangesNb (String set to a numerical value): number of recent changes to display. 13: ## - rcSpace (List of string[s]): restrict recent changes retrieval to pages within the given space. 14: ## - rcTag (List of string[s]): restrict recent changes retrieval to pages with the given tag. 15: ## - rcAuthor (List of string[s]): restrict recent changes retrieval to pages with the given author. 16: ## 17: ## Parameters which can be set before including this page only. 18: ## 19: ## - rcDocumentNames (Collection): The list of recentlyChanged documents, to reuse a previous search query. 20: ## 21: $xwiki.jsx.use("Main.RecentChanges") 22: $xwiki.ssx.use("Main.RecentChanges") 23: #set($action = "$!request.getParameter('action')") 24: ## 25: ## Start execution timer 26: ## 27: #set($execStart = $util.getDate()) 28: ## 29: ## Go to diff URL service. 30: ## 31: #if($action == "goToDiffURL") 32: #set($page = "$!request.getParameter('page')") 33: #set($author = "$!request.getParameter('author')") 34: #set($date = "$!request.getParameter('date')") 35: #set($period = $xwiki.criteriaService.getPeriodFactory().createDayPeriod($date)) 36: #set($criterion = $xwiki.criteriaService.getRevisionCriteriaFactory().createRevisionCriteria($author, $period)) 37: #if("$!request.getParameter('rcShowMinor')" == "true") 38: #set($discard = $criterion.setIncludeMinorVersions(true)) 39: #end 40: #set($diffDoc = $xwiki.getDocument($page)) 41: #set($revisions = $diffDoc.getRevisions($criterion)) 42: #set($rev1 = $listtool.get($revisions, 0)) 43: #set($revMax = $revisions.size() - 1) 44: #set($rev2 = $listtool.get($revisions, $revMax)) 45: $response.sendRedirect($diffDoc.getURL("view", "viewer=changes&rev1=${rev1}&rev2=${rev2}")) 46: #end 47: ## Manage minor edits. 48: #setVariableFromRequest($rcShowMinor "rcShowMinor" false) 49: ## Manage show diff in items. 50: #setVariableFromRequest($rcShowDiff "rcShowDiff" true) 51: ## Manage show RSS links. 52: #setVariableFromRequest($rcShowRss "rcShowRss" true) 53: ## Manage number of changes to display. 54: #setVariableFromRequest($rcChangesNb "rcChangesNb" 30) 55: ## Manage tag criterion 56: #setVariableFromRequest($rcTag "rcTag" []) 57: ## Manage space criterion 58: #setVariableFromRequest($rcSpace "rcSpace" []) 59: ## Manage author criterion 60: #setVariableFromRequest($rcAuthor "rcAuthor" []) 61: ## 62: ## Create a string containing one or more ? given the number of values in the passed list. 63: ## 64: #macro(createQueryParameters $values $parameters) 65: #foreach($value in $values) 66: #if($parameters == "") 67: #set($parameters = "?") 68: #else 69: #set($parameters = "${parameters}, ?") 70: #end 71: #end 72: #end 73: ## 74: ## Retrieve recently changed documents. 75: ## 76: #set($criteria = $util.getHashMap()) 77: #if("$!rcDocumentNames" == "") 78: #if(!$xwiki.hasMinorEdit() || $rcShowMinor) 79: #set ($hqlQuery = "where 1=1 order by doc.date desc") 80: #else 81: #set ($hqlQuery = ", XWikiRCSNodeInfo as ni where doc.id=ni.id.docId and ni.id.version2=1 group by doc.space, doc.name order by max(ni.date) desc") 82: #end 83: ## Create space criterion. 84: #if($rcSpace.size() > 0) 85: #set($spaceParameters = "") 86: #createQueryParameters($rcSpace $spaceParameters) 87: #set($discard = $criteria.put("doc.space in (${spaceParameters})", $rcSpace)) 88: #end 89: ## Create tag criterion. 90: #if("$!xwiki.getPlugin('tag')" != "" && $rcTag.size() > 0) 91: #set($docsWithTag = $util.getArrayList()) 92: #foreach($item in $rcTag) 93: #set($discard = $docsWithTag.addAll($xwiki.tag.getDocumentsWithTag($item))) 94: #end 95: #set($docsWithTagParameters = "") 96: #createQueryParameters($docsWithTag $docsWithTagParameters) 97: #set($discard = $criteria.put("doc.fullName in (${docsWithTagParameters})", $docsWithTag)) 98: #end 99: #if($rcAuthor.size() > 0) 100: #set($authorParameters = "") 101: #createQueryParameters($rcAuthor $authorParameters) 102: #set($discard = $criteria.put("doc.author in (${authorParameters})", $rcAuthor)) 103: #end 104: #if($criteria.size() > 0) 105: ## If any, loop over criterias to add them to the query, then perform the query. 106: #set($values = $util.getArrayList()) 107: #foreach($criterion in $criteria.keySet()) 108: #if($criteria.get($criterion).size() > 0) 109: #set($hqlQuery = $hqlQuery.replaceAll("where", "where ${criterion} and")) 110: #set($discard = $values.addAll($criteria.get($criterion))) 111: #end 112: #end 113: #set($rcDocumentNames = $xwiki.searchDocuments($hqlQuery, $rcChangesNb, 0, $values)) 114: #else 115: ## No query criterion, perform the query as is. 116: #set($rcDocumentNames = $xwiki.searchDocuments($hqlQuery, $rcChangesNb, 0)) 117: #end 118: #end 119: ## 120: ## Prepare comments handling 121: #set($commentsOrder = false) 122: #if($xwiki.getWebPreferenceAsInt("commentsorder",1) == 0) 123: #set($commentsOrder = true) 124: #end 125: ## 126: ## Comment handling macro. 127: ## Retreive page's last comment if any and 128: ## overwrite variables if this comment is the last modification on the page. 129: ## 130: #macro(handleComment $rcDoc $rcType $rcDt $commentsOrder) 131: ## Retrieve comments from last to first. 132: #set($rcComments = $rcDoc.getComments($commentsOrder)) 133: #if($rcComments.size() > 0) 134: ## Retrieve last comment. 135: #set($lastComment = $listtool.get($rcComments, 0)) 136: #set($lastCommentDate = $lastComment.getProperty("date").getValue()) 137: ## If the last modification on the page is the comment, overwrite values. 138: ## We don't test compareTo() == 0 since the comment date and the save date may vary a little bit. 139: #if($lastCommentDate.compareTo($rcDt.toDate()) > -1 && $lastCommentDate.compareTo($rcDt.toDate()) <= 1) 140: #set($rcType = "comment") 141: #end 142: #end 143: #end 144: ## 145: ## Attachments handling macro. 146: ## Retreive page's attachments and put those which upload matches the modification entry (author and timeframe) 147: ## in the $rcAttachments List. 148: ## 149: #macro(handleAttachments $rcDoc $rcAuthor $rcDt) 150: #set($attachments = $rcDoc.getAttachmentList()) 151: #foreach($attachment in $attachments) 152: #set($attachmentDt = $xwiki.jodatime.getDateTime($attachment.getDate().getTime())) 153: #if($rcAuthor == $attachment.getAuthor() && $rcDt.getYear() == $attachmentDt.getYear() && $rcDt.getDayOfYear() == $attachmentDt.getDayOfYear()) 154: #set($discard = $rcAttachments.add($attachment)) 155: #end 156: #end 157: #end 158: ## 159: ## 160: ## 161: #macro(displayRcAuthor $author) 162: #useravatar($author) 163: <br/><span class="recentChangesAuthor"> 164: #if($author == "XWikiGuest") 165: Guest 166: #else 167: #set($localUserName = $xwiki.getLocalUserName($author)) 168: #if($localUserName == "") 169: ## localUserName can be empty when the page has been saved without specifying the author. 170: ## We're printing a non-breaking space to ensure xhtml validity (ie: avoid empty paragraph). 171: 172: #else 173: $localUserName 174: #end 175: #end 176: </span> 177: #end 178: #macro(displayRcVersion $version) 179: #if($version == "1.1") 180: <span class="rcVersion">(<span style="color:red;">$msg.get("xe.recentchanges.entry.new")</span>)</span> 181: #end 182: #end 183: ## 184: ## Display the recent changes list. 185: ## 186: #set($previousDt = $xwiki.jodatime.getDateTime(0)) 187: #set($discard = $previousDate.setTime(0)) 188: #set($previousAuthor = "") 189: ## Get this very doc, useful when it is included from another one. 190: #set($recentChangesDoc = $xwiki.getDocument("Main.RecentChanges")) 191: <table class="recentChanges"> 192: <tr class="recentChangesHeader"><th>$msg.get("xe.recentchanges.column.authoranddate")</th><th>$msg.get("xe.recentchanges.column.changes")</th></tr> 193: #foreach ($rcDocName in $rcDocumentNames) 194: #set($row = "") 195: #set($rcAttachments = $util.arrayList) 196: ## Verify user access level on the document 197: #if ($xwiki.hasAccessLevel("view", $context.user, "${context.database}:${rcDocName}")) 198: #set($rcDoc = $xwiki.getDocument($rcDocName)) 199: #set($rcType = "page") 200: #set($rcAuthor = $rcDoc.getAuthor()) ## TODO : check comments 201: #set($rcDt = $xwiki.jodatime.getDateTime($rcDoc.getDate().getTime())) 202: ## The handleComment macro overwrites rcType variable if the last modification is a comment. 203: #handleComment($rcDoc $rcType $rcDt $commentsOrder) 204: ## The handleAttachments macro put a list of attachments uploaded during the day by the author in $rcAttachments. 205: #handleAttachments($rcDoc $rcAuthor $rcDt) 206: #if($rcAuthor == $previousAuthor && $rcDt.getYear() == $previousDt.getYear() && $rcDt.getDayOfYear() == $previousDt.getDayOfYear()) 207: ## Same day and author, continue in the same row. 208: #else 209: ## Different day or author, end previous row and start a new one. 210: #if($velocityCount > 1)</ul></td></tr>#end ## close previous row if needed 211: <tr><td class="recentChangesLeft">#displayRcAuthor($rcAuthor)<br/> 212: <span class="recentChangesDate">$xwiki.formatDate($rcDt.toDate(), "MMMM d")</span></td> 213: <td class="recentChangesRight"><ul class="xlist"> ## open next cell 214: #end 215: ## Compute a GUID for this modification with page name, modification date and author. 216: #set($modGUID = "${rcDoc.fullName}_${xwiki.formatDate($rcDt.toDate(), 'yyyyMMdd')}_${rcAuthor}") 217: ## Build the URL used to retreive the diff viewer URL 218: #set($goToDiffURL = $recentChangesDoc.getURL("view", "xpage=plain&action=goToDiffURL&page=${rcDoc.getFullName()}&author=${rcAuthor}&date=${xwiki.formatDate($rcDt.toDate(), 'yyyyMMdd')}&rcShowMinor=${rcShowMinor}")) 219: <li class="xitem xunderline xhighlight ${rcType}"> 220: <div class="xitemcontainer"> 221: #if($rcType == "comment") 222: <div class="modifiedPage"><a href="$rcDoc.getURL()" title="$msg.get("xe.recentchanges.entry.comment.tooltip", [$xwiki.formatDate($rcDt.toDate(), "HH:mm")]) ">$rcDoc.getDisplayTitle()</a></div> 223: #if($rcShowDiff) 224: <div class="xshowonhover modifiedPageActions"><a class="ajax" href="$rcDoc.getURL("vire", "viewer=comments")" onclick="toggleClass(document.getElementById('$modGUID'), 'hidden'); toggleClass(document.getElementById('${modGUID}_comShow'), 'hidden'); toggleClass(document.getElementById('${modGUID}_comHide'), 'hidden'); return false;"><span id="${modGUID}_comShow">[+] $msg.get("xe.recentchanges.entry.comment.show")</span><span id="${modGUID}_comHide" class="hidden">[-] $msg.get("xe.recentchanges.entry.comment.hide")</span> $msg.get("xe.recentchanges.entry.comment")</a></div> 225: <div class="commentContainer hidden" id="$modGUID"> 226: <div class="commentQuote lQuo"> </div> 227: <div class="commentQuote rQuo"> </div> 228: <div class="comment"> 229: $lastComment.get("comment") 230: </div> 231: ## Display discussion link, this link point to the comments anchor. 232: <div class="commentAdd"><img src="$xwiki.getSkinFile("icons/silk/comment.gif")" alt="Reply icon" /> <a href="${rcDoc.getURL("view")}#Comments">$msg.get("xe.recentchanges.entry.comment.seediscussion")</a></div> 233: </div> 234: #end 235: #else 236: <div class="modifiedPage"><a href="$rcDoc.getURL()" title="$msg.get("xe.recentchanges.entry.page.tooltip", [$rcDoc.getVersion(), $xwiki.formatDate($rcDt.toDate())])">$rcDoc.getDisplayTitle()</a> #displayRcVersion($rcDoc.getVersion())</div> 237: #if($rcShowDiff) 238: <div class="xshowonhover modifiedPageActions"><a href="$goToDiffURL">$msg.get("xe.recentchanges.entry.page.seemodifications")</a></div> 239: ## If the author has uploaded attachments during the day in this page, display them. 240: #if($rcAttachments.size() > 0) 241: <div class="attachmentContainer" id="$modGUID"> 242: <ul> 243: #foreach($rcAttachment in $rcAttachments) 244: <li class="attachment"><a href="$rcDoc.getAttachmentURL($rcAttachment.filename)">$rcAttachment.filename</a> #displayRcVersion($rcAttachment.getVersion())</li> 245: #end 246: </ul> 247: </div> 248: #end 249: #end 250: #end 251: <div class="xspacer"> </div> 252: </div> 253: </li> 254: #end 255: #set($previousAuthor = $rcAuthor) 256: #set($previousDt = $rcDt) 257: #end 258: ## Close last row if any. 259: #if($rcDocumentNames.size() > 1)</ul></td></tr>#end 260: </table> 261: ## 262: ## Rebuild URL query string 263: ## Workaround until we fix $request.getQueryString() 264: ## 265: #set($queryString = "") 266: #set($paramMap = $request.getParameterMap()) 267: #foreach($key in $paramMap.keySet()) 268: #foreach($value in $paramMap.get($key)) 269: #set($queryString = "${queryString}&${key}=${value}") 270: #end 271: #end 272: ## 273: ## Provide links to display minor edits and RSS feed. 274: ## 275: #if($xwiki.hasMinorEdit()) 276: <p class="recentChangesMoreActions"> 277: #if($rcShowMinor) 278: <a href="$xwiki.getURL($tdoc.getFullName(), "view", $queryString.replaceAll('rcShowMinor=true', ''))"><img src="$xwiki.getSkinFile("icons/silk/zoom_out.gif")" alt="Hide minor icon"/> $msg.get("xe.recentchanges.hideminor")</a> 279: #else 280: <a href="$xwiki.getURL($tdoc.getFullName(), "view", "${queryString}&rcShowMinor=true")"><img src="$xwiki.getSkinFile("icons/silk/zoom_in.gif")" alt="Show minor icon"/> $msg.get("xe.recentchanges.showminor")</a> 281: #end 282: #if($rcShowRss) 283: #set($rssURL = "") 284: #if($rcTag.size() > 0) 285: ## Temporary harcoded URL until we refactor our RSS feeds. 286: #set($rssURL = $xwiki.getURL("Main.TagsRss", "view", "xpage=rdf&tag=$listtool.get($rcTag, 0)")) 287: #else 288: #set($rssURL = $xwiki.getURL("Main.WebRss", "view", "xpage=rdf")) 289: #end 290: <a href="${rssURL}"><img src="$xwiki.getSkinFile("icons/silk/feed.gif")" alt="RSS icon"/> $msg.get("xe.recentchanges.rssfeed")</a> 291: #end 292: </p> 293: #end 294: ## 295: ## Compute and display execution time. 296: ## 297: #set($execEnd = $util.getDate()) 298: #set($execDuration = $execEnd.getTime() - $execStart.getTime()) 299: <!-- Main.RecentChanges execution time: ${execDuration}ms -->
Search
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox
Recently Modified
XWiki Scheduler Job Class
|
XWiki Preferences
|
XWikiAllGroup