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