Wiki source code of Changes Report

Last modified by Vincent Massol on 2026/09/10 13:54

Show last authors
1 {{velocity output="false"}}
2 ## The report form submits one request parameter per filter. Forward those by name rather than whatever the
3 ## request happens to carry, so that the string built here is always a list of known macro parameters.
4 #set ($reportParameters = ['products', 'versions', 'audience', 'categories', 'importance', 'containsScreenshots',
5 'displayer'])
6 #set ($parameters = "")
7 #set ($filterQueryString = 'action=report')
8 #foreach ($parameterName in $reportParameters)
9 #set ($parameterValue = $stringtool.normalizeSpace("$!request.get($parameterName)"))
10 #if ($parameterValue != '')
11 ## The value is placed into a macro parameter, which is re-parsed as wiki syntax, so it is emitted escaped:
12 ## left raw, a value carrying a quote would close the parameter, and a value ending with the escape character
13 ## would escape the closing quote instead, leaving the whole macro call unparsed and displayed as text.
14 #set ($escapedValue = $services.rendering.escape($parameterValue, 'xwiki/2.1'))
15 #set ($parameters = "$parameters $parameterName='$escapedValue' ")
16 ## The same filters have to reach the other pages of this report, this time as request parameters, so they
17 ## travel unescaped: the escaping above belongs to the wiki syntax the value is written into, not to the value.
18 #set ($filterQueryString = "$filterQueryString&$parameterName=$escapetool.url($parameterValue)")
19 #end
20 #end
21 ## The filters come from the request and default to wildcards, so the report can be asked for every change of a
22 ## product at once. Display one page of changes at a time. The page size is fixed here rather than read from the
23 ## request, otherwise a single URL would bring back the unbounded query this paging exists to avoid.
24 #set ($reportPageSize = 20)
25 #set ($reportOffset = $numbertool.toNumber("$!request.offset"))
26 #if (!$reportOffset || $reportOffset.intValue() < 0)
27 #set ($reportOffset = 0)
28 #else
29 #set ($reportOffset = $reportOffset.intValue())
30 #end
31 #set ($previousOffset = $mathtool.max(0, $mathtool.sub($reportOffset, $reportPageSize)))
32 #set ($nextOffset = $mathtool.add($reportOffset, $reportPageSize))
33 #macro (displayReportPageLink $newOffset $labelKey)
34 #set ($label = $escapetool.xml($services.localization.render($labelKey)))
35 #set ($pageURL = $escapetool.xml($doc.getURL('view', "${filterQueryString}&offset=${newOffset}")))
36 <a href="$pageURL">$label</a>
37 #end
38 {{/velocity}}
39
40 {{velocity}}
41 {{getChanges $parameters limit="$reportPageSize" offset="$reportOffset" contextVariable='reportChanges'/}}
42 {{/velocity}}
43
44 {{velocity}}
45 {{displayChanges $parameters contextVariable='reportChanges'/}}
46 {{/velocity}}
47
48 {{velocity}}
49 ## getChanges publishes whether it had more changes to return, which is what tells a next page apart from the last
50 ## one without counting the whole result set.
51 #if ($reportOffset > 0 || $reportChangesHasMore)
52 {{html clean="false"}}
53 <div class="rn-report-pagination">
54 #if ($reportOffset > 0)
55 #displayReportPageLink($previousOffset, 'releasenotes.report.previous')
56 #end
57 #if ($reportChangesHasMore)
58 #displayReportPageLink($nextOffset, 'releasenotes.report.next')
59 #end
60 </div>
61 {{/html}}
62 #end
63 {{/velocity}}

Get Connected