Wiki source code of $services.localization.render('extension.extensions')
Version 3.1 by Thomas Coelho on 2022/07/13 16:03
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{template name="extension.vm" output="false"/}} | ||
2 | |||
3 | {{velocity}} | ||
4 | ## HTML cleaner messes up the content of the legend tag. | ||
5 | {{html clean="false"}} | ||
6 | #if ($isAjaxRequest) | ||
7 | #handleExtensionRequest() | ||
8 | #else | ||
9 | <div class="full column"> | ||
10 | #displayExtensionSearchBar() | ||
11 | |||
12 | #if ($request.extensionId && $request.extensionVersion) | ||
13 | ## Advanced search. | ||
14 | #handleExtensionRequest() | ||
15 | #else | ||
16 | #if ($request.index_start) | ||
17 | #set ($void = $extensionManager.getRepository('index').index("wiki:${xcontext.database}")) | ||
18 | #end | ||
19 | ## Simple search. | ||
20 | #set ($noResultsMessageKey = 'extensions.search.noResults') | ||
21 | #set ($paginationParams = {}) | ||
22 | ## Dump whitespace generated by the pagination macro | ||
23 | #set ($discard = "#paginationPrepareParams($paginationParams)") | ||
24 | #if ("$!selectedRepositoryId" != '') | ||
25 | #set ($repository = $extensionManager.getRepository($selectedRepositoryId)) | ||
26 | #if ("$!request.search" == '') | ||
27 | ## Fetch extensions from known repositories. | ||
28 | #if ($selectedRepositoryId == 'core') | ||
29 | #set($extensions = $services.extension.core.getCoreExtensions()) | ||
30 | #elseif ($selectedRepositoryId == 'installed') | ||
31 | #if ($xcontext.isMainWiki()) | ||
32 | #set($extensions = $services.extension.installed.getInstalledExtensions()) | ||
33 | #else | ||
34 | #set($extensions = $services.extension.installed.getInstalledExtensions($extensionNamespace)) | ||
35 | #end | ||
36 | #elseif ($selectedRepositoryId == 'local') | ||
37 | #set($extensions = $services.extension.local.getLocalExtensions()) | ||
38 | #end | ||
39 | #if ($extensions) | ||
40 | #set ($totalHits = $extensions.size()) | ||
41 | #if ($totalHits == 0) | ||
42 | #set ($noResultsMessageKey = "extensions.search.repository.${selectedRepositoryId}.empty") | ||
43 | #end | ||
44 | ## All extensions from the specified repository have been fetched. We need to display only the current page. | ||
45 | #set ($extensions = $extensions.subList($paginationParams.firstItem, $mathtool.min($extensions.size(), $mathtool.add($paginationParams.firstItem, $paginationParams.itemsPerPage)))) | ||
46 | #end | ||
47 | #end | ||
48 | #end | ||
49 | #if (!$extensions) | ||
50 | #set($extensionQuery = $services.extension.index.newQuery("$!request.search")) | ||
51 | #set($void = $extensionQuery.setOffset($paginationParams.firstItem)) | ||
52 | #set($void = $extensionQuery.setLimit($paginationParams.itemsPerPage)) | ||
53 | #if ($selectedRepositoryId == 'installed') | ||
54 | #if ($xcontext.isMainWiki()) | ||
55 | #set ($extensions = $services.extension.installed.repository.searchInstalledExtensions($extensionQuery)) | ||
56 | #else | ||
57 | ## When searching for installed extensions in a subwiki we need to take the namespace into account. | ||
58 | #set ($extensions = $services.extension.installed.repository.searchInstalledExtensions($extensionNamespace, $extensionQuery)) | ||
59 | #end | ||
60 | #elseif ($repository) | ||
61 | #set ($extensions = $repository.search($extensionQuery)) | ||
62 | #else | ||
63 | #if ($recommended) | ||
64 | #set($void = $extensionQuery.addFilter('recommended', true, 'EQUAL')) | ||
65 | #end | ||
66 | #if ($indexed) | ||
67 | #set ($repository = $extensionManager.index.repository) | ||
68 | #if ($compatible) | ||
69 | #set ($void = $extensionQuery.setCompatible(true, '', "wiki:$xcontext.database")) | ||
70 | #end | ||
71 | #else | ||
72 | #set ($repository = $extensionManager) | ||
73 | #end | ||
74 | #set ($extensions = $repository.search($extensionQuery)) | ||
75 | #end | ||
76 | #set ($totalHits = $extensions.totalHits) | ||
77 | #end | ||
78 | |||
79 | #if ($recommended) | ||
80 | #if (!$extensions.iterator().hasNext()) | ||
81 | <div class="box warningmessage">$services.localization.render('extensions.search.recommended.fallback', ["<em>$!escapetool.xml($request.search)</em>"])</div> | ||
82 | ## Search again with the recommended filter | ||
83 | #set ($extensions = $repository.search("$!request.search", $paginationParams.firstItem, $paginationParams.itemsPerPage)) | ||
84 | #set ($totalHits = $extensions.totalHits) | ||
85 | #set ($recommended = false) | ||
86 | #elseif (!$customExtensionFilter) | ||
87 | <div class="box infomessage"> | ||
88 | #if ($compatible) | ||
89 | $services.localization.render('extensions.search.compatiblerecommended.disclaimer') | ||
90 | #else | ||
91 | $services.localization.render('extensions.search.recommended.disclaimer') | ||
92 | #end | ||
93 | <form action="${xwiki.relativeRequestURL}"> | ||
94 | #if ($request.section) | ||
95 | <input type="hidden" name="section" value="${escapetool.xml($request.section)}" /> | ||
96 | #end | ||
97 | <input type="hidden" name="search" value="$!{escapetool.xml($request.search)}" /> | ||
98 | <input type="hidden" name="recommended" value="false" /> | ||
99 | <input type="hidden" name="indexed" value="$indexed" /> | ||
100 | <input type="hidden" name="compatible" value="$compatible" /> | ||
101 | #if ($compatible) | ||
102 | <input type="submit" value="${escapetool.xml($services.localization.render('extensions.search.compatible.all.label'))}" class="btn btn-default"/> | ||
103 | #else | ||
104 | <input type="submit" value="${escapetool.xml($services.localization.render('extensions.search.all.label'))}" class="btn btn-default"/> | ||
105 | #end | ||
106 | </form> | ||
107 | </div> | ||
108 | #end | ||
109 | #end | ||
110 | |||
111 | #if (!$extensions.iterator().hasNext()) | ||
112 | <div class="box infomessage">$services.localization.render($noResultsMessageKey, ["<em>$!escapetool.xml($request.search)</em>"])</div> | ||
113 | #else | ||
114 | #if ($totalHits && $totalHits > $paginationParams.itemsPerPage) | ||
115 | #set ($hasPagination = true) | ||
116 | #set ($paginationParams.totalItems = $totalHits) | ||
117 | #set ($paginationParams.url = $doc.getURL($xcontext.action, $request.getQueryString().replaceAll('(^|&)firstIndex=[^&]++&?', '$1'))) | ||
118 | #pagination($paginationParams) | ||
119 | #end | ||
120 | #foreach($extension in $extensions) | ||
121 | #displayExtension($extension) | ||
122 | #end | ||
123 | #if ($hasPagination) | ||
124 | #set ($discard = $paginationParams.put('position', 'bottom')) | ||
125 | #pagination($paginationParams) | ||
126 | #end | ||
127 | #end | ||
128 | |||
129 | #if ($indexed) | ||
130 | #set ($indexJobStatus = $repository.getStatus("wiki:${xcontext.database}")) | ||
131 | #if ($indexJobStatus) | ||
132 | <div class="box infomessage"> | ||
133 | #if ($indexJobStatus.state != 'FINISHED') | ||
134 | $escapetool.xml($services.localization.render('extensions.search.indexed.started', [$xwiki.formatDate($indexJobStatus.startDate)])) | ||
135 | #set ($discard = $xwiki.jsfx.use('uicomponents/job/job.js')) | ||
136 | #set ($jobStatusURL = $doc.getURL('get', $escapetool.url({ | ||
137 | 'xpage': 'job_status_json', | ||
138 | 'outputSyntax': 'plain', | ||
139 | 'jobId': $indexJobStatus.request.id | ||
140 | }))) | ||
141 | <div class="xcontent job-status" data-url="$escapetool.xml($jobStatusURL)"> | ||
142 | #displayJobProgressBar($indexJobStatus, true) | ||
143 | </div> | ||
144 | #else | ||
145 | $escapetool.xml($services.localization.render('extensions.search.indexed.on', [$xwiki.formatDate($indexJobStatus.startDate)])) | ||
146 | #end | ||
147 | #else | ||
148 | <div class="box warningmessage">$escapetool.xml($services.localization.render('extensions.search.indexed.nojob')) | ||
149 | #end | ||
150 | <form action="${xwiki.relativeRequestURL}"> | ||
151 | #if ($request.section) | ||
152 | <input type="hidden" name="section" value="${escapetool.xml($request.section)}" /> | ||
153 | #end | ||
154 | <input type="hidden" name="search" value="$!{escapetool.xml($request.search)}" /> | ||
155 | <input type="hidden" name="recommended" value="$recommended" /> | ||
156 | <input type="hidden" name="indexed" value="$indexed" /> | ||
157 | <input type="hidden" name="compatible" value="$compatible" /> | ||
158 | #if ($indexJobStatus.state != 'RUNNING') | ||
159 | <input type="submit" value="${escapetool.xml($services.localization.render('extensions.search.indexed.reindex'))}" name="index_start" class="btn btn-default"/> | ||
160 | #end | ||
161 | </form> | ||
162 | </div> | ||
163 | #end | ||
164 | #end | ||
165 | </div> | ||
166 | #end | ||
167 | {{/html}} | ||
168 | {{/velocity}} |