Afficher les derniers auteurs
1 {{velocity output="false"}}
2 #macro (displaySearchFacetValues_fileSize $facetValues)
3 ##
4 ## Predefined size intervals, specified in bytes.
5 ##
6 #set ($intervals = $solrConfig.facet.fileSize.intervals)
7 #foreach ($interval in $intervals)
8 #set ($start = $interval.start)
9 #set ($end = $interval.end)
10 #if (!$start)
11 #set ($start = '*')
12 #set ($hint = $services.localization.render('solr.facet.size.lessThan', ["#dynamicsize($end)"]))
13 #elseif (!$end)
14 #set ($end = '*')
15 #set ($hint = $services.localization.render('solr.facet.size.moreThan', ["#dynamicsize($start)"]))
16 #else
17 #set ($hint = $services.localization.render('solr.facet.size.between', ["#dynamicsize($start)", "#dynamicsize($end)"]))
18 #end
19 #set ($discard = $interval.putAll({
20 'label': $services.localization.render("solr.facet.size.$interval.id"),
21 'hint': $hint,
22 'name': "[$start TO $end]",
23 'count': 0
24 }))
25 #end
26 ##
27 ## Add custom size intervals specified on the request.
28 ##
29 #foreach ($selectedValue in $facetRequestValues)
30 ## Determine if the value/range is custom.
31 #set ($custom = true)
32 #foreach ($interval in $intervals)
33 #if ($interval.name == $selectedValue)
34 #set ($custom = false)
35 #break
36 #end
37 #end
38 #if ($custom)
39 #set ($rangeMatcher = $rangePattern.matcher($selectedValue))
40 #if ($rangeMatcher.matches())
41 #set ($discard = $intervals.add({
42 'start': $numbertool.toNumber($rangeMatcher.group(1)).intValue(),
43 'end' : $numbertool.toNumber($rangeMatcher.group(2)).intValue(),
44 'name' : $selectedValue,
45 'count': 0
46 }))
47 #end
48 #end
49 #end
50 ##
51 ## Count matches for each date interval.
52 ##
53 #foreach ($facetValue in $facetValues)
54 #set ($size = $numbertool.toNumber($facetValue.name).intValue())
55 #foreach ($interval in $intervals)
56 #if ((!$interval.start || $interval.start <= $size)
57 && (!$interval.end || $size < $interval.end))
58 #set ($discard = $interval.put('count', $mathtool.add($interval.count, $facetValue.count)))
59 #end
60 #end
61 #end
62 ## Filter the size intervals that don't have matches.
63 #set ($intervalsWithMatches = [])
64 #foreach ($interval in $intervals)
65 #if ($interval.count > 0 || $facetRequestValues.contains($interval.name))
66 #set ($discard = $intervalsWithMatches.add($interval))
67 #end
68 #end
69 ## Make sure we sort the intervals based on the number of matches.
70 #set ($intervals = $collectiontool.sort($intervalsWithMatches, 'count:desc'))
71 ##
72 ## Display the size intervals.
73 ##
74 <ul>
75 #foreach ($facetValue in $intervals)
76 <li>#displaySearchFacetValue($facetValue {} 'displaySearchFacetValue_fileSize')</li>
77 #end
78 </ul>
79 #end
80
81 #macro (displaySearchFacetValue_fileSize $sizeInterval)
82 #if ($facetValue.label)
83 <span title="$escapetool.xml($facetValue.hint)">$escapetool.xml($facetValue.label)</span>
84 #elseif ($facetValue.start || $facetValue.end)
85 ## Display the custom interval.
86 #if (!$facetValue.start)
87 $escapetool.xml($services.localization.render('solr.facet.size.lessThan',
88 ["#dynamicsize($facetValue.end)"]))
89 #elseif (!$facetValue.end)
90 $escapetool.xml($services.localization.render('solr.facet.size.moreThan',
91 ["#dynamicsize($facetValue.start)"]))
92 #else
93 $services.localization.render('solr.facet.size.between',
94 ["#dynamicsize($facetValue.start)", "#dynamicsize($facetValue.end)"])
95 #end
96 #else
97 $escapetool.xml($services.localization.render('solr.facet.size.any'))
98 #end
99 #end
100 {{/velocity}}
101
102 {{velocity}}
103 #if ($facetValues)
104 {{html clean="false"}}#displaySearchFacetValues_fileSize($facetValues){{/html}}
105 #end
106 {{/velocity}}
#getBlogDocument($space $blogDoc)
XWiki Enterprise 14.6 - Documentation