Wiki source code of Add Extensions

Last modified by superadmin on 2022/05/03 16:48

Hide last authors
superadmin 1.1 1 {{velocity output="false"}}
2 ## NOTE: We don't use #template because it currently registers the Velocity macros in a different namespace which makes
3 ## them unavailable in the current wiki page or the current template. We also tried #parse but it "randomly" fails to
4 ## register the Velocity macros from the parsed template. The only solution we found is to use #evaluate with #include
5 ## but unfortunately this doesn't allow the template to be overridden from the skin.
6 #evaluate("#include('extension.vm')")
7 {{/velocity}}
8
9 {{velocity}}
10 ## HTML cleaner messes up the content of the legend tag.
11 {{html clean="false"}}
12 #if ($isAjaxRequest)
13 #handleExtensionRequest()
14 #else
15 <div class="full column">
16 #displayExtensionSearchBar()
17
18 #if ($request.extensionId && $request.extensionVersion)
19 ## Advanced search.
20 #handleExtensionRequest()
21 #else
22 ## Simple search.
23 #set ($noResultsMessageKey = 'extensions.search.noResults')
24 #set ($paginationParams = {})
25 ## Dump whitespace generated by the pagination macro
26 #set ($discard = "#paginationPrepareParams($paginationParams)")
27 #set ($repository = $extensionManager)
28 #if ($request.repo)
29 #set ($selectedRepositoryId = $request.repo)
30 #end
31 #if ("$!selectedRepositoryId" != '')
32 #set ($repository = $extensionManager.getRepository($selectedRepositoryId))
33 #if ("$!request.search" == '')
34 ## Fetch extensions from known repositories.
35 #if ($selectedRepositoryId == 'core')
36 #set($extensions = $services.extension.core.getCoreExtensions())
37 #elseif ($selectedRepositoryId == 'installed')
38 #if ($xcontext.isMainWiki())
39 #set($extensions = $services.extension.installed.getInstalledExtensions())
40 #else
41 #set($extensions = $services.extension.installed.getInstalledExtensions($extensionNamespace))
42 #end
43 #elseif ($selectedRepositoryId == 'local')
44 #set($extensions = $services.extension.local.getLocalExtensions())
45 #end
46 #if ($extensions)
47 #set ($totalHits = $extensions.size())
48 #if ($totalHits == 0)
49 #set ($noResultsMessageKey = "extensions.search.repository.${selectedRepositoryId}.empty")
50 #end
51 ## All extensions from the specified repository have been fetched. We need to display only the current page.
52 #set ($extensions = $extensions.subList($paginationParams.firstItem, $mathtool.min($extensions.size(), $mathtool.add($paginationParams.firstItem, $paginationParams.itemsPerPage))))
53 #end
54 #end
55 #end
56 #if (!$extensions)
57 #if ($selectedRepositoryId == 'installed' && !$xcontext.isMainWiki())
58 ## When searching for installed extensions we need to take the namespace into account.
59 #set ($extensions = $services.extension.installed.repository.searchInstalledExtensions("$!request.search",
60 $extensionNamespace, $paginationParams.firstItem, $paginationParams.itemsPerPage))
61 #else
62 #set ($extensions = $repository.search("$!request.search", $paginationParams.firstItem, $paginationParams.itemsPerPage))
63 #end
64 #set ($totalHits = $extensions.totalHits)
65 #end
66 #if (!$extensions.iterator().hasNext())
67 <div class="box infomessage">$services.localization.render($noResultsMessageKey, ["<em>$!escapetool.xml($request.search)</em>"])</div>
68 #else
69 #if ($totalHits && $totalHits > $paginationParams.itemsPerPage)
70 #set ($hasPagination = true)
71 #set ($paginationParams.totalItems = $totalHits)
72 #set ($paginationParams.url = $doc.getURL($xcontext.action, $request.getQueryString().replaceAll('(^|&)firstIndex=[^&]++&?', '$1')))
73 #pagination($paginationParams)
74 #end
75 #foreach($extension in $extensions)
76 #displayExtension($extension)
77 #end
78 #if ($hasPagination)
79 #set ($discard = $paginationParams.put('position', 'bottom'))
80 #pagination($paginationParams)
81 #end
82 #end
83 #end
84 </div>
85 #end
86 {{/html}}
87 {{/velocity}}
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 13.10.5 - Documentation