Wiki source code of Lucene search administration
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity output="false"}} | ||
2 | #set ($lucene = $xwiki.lucene) | ||
3 | {{/velocity}} | ||
4 | |||
5 | {{velocity}} | ||
6 | #if ($hasAdmin) | ||
7 | #if ($request.action == 'indexfarm') | ||
8 | #if ($xcontext.isMainWiki()) | ||
9 | #set ($clearIndex = true) | ||
10 | #set ($onlyNew = false) | ||
11 | #set ($startindex = true) | ||
12 | #else## !$xcontext.isMainWiki() | ||
13 | {{error}}$services.localization.render('needadminrights').{{/error}} | ||
14 | #end | ||
15 | #elseif ($request.action == 'indexcurrentwiki') | ||
16 | #set ($wikis = [$xcontext.database]) | ||
17 | #set ($wikisString = "${xcontext.database}") | ||
18 | #set ($clearIndex = true) | ||
19 | #set ($onlyNew = false) | ||
20 | #set ($startindex = true) | ||
21 | #elseif ($request.action == 'indexcustom') | ||
22 | #if ($xcontext.isMainWiki()) | ||
23 | #if ("$!{request.wikis.trim()}" != '') | ||
24 | #set ($wikisArray = $request.wikis.split(',')) | ||
25 | #set ($wikis = $wikisArray.subList(0, $wikisArray.size())) | ||
26 | #set ($wikisString = $request.wikis) | ||
27 | #end | ||
28 | #else## !$xcontext.isMainWiki() | ||
29 | #set ($wikis = [$xcontext.database]) | ||
30 | #set ($wikisString = "${xcontext.database}") | ||
31 | #end | ||
32 | #set ($hqlFilter = $request.hqlFilter) | ||
33 | #set ($clearIndex = $request.clearIndex == 'on') | ||
34 | #set ($onlyNew = $request.onlyNew == 'on') | ||
35 | #set ($startindex = true) | ||
36 | #end | ||
37 | ## | ||
38 | #if ($startindex) | ||
39 | #set ($errorcode = $lucene.startIndex($wikis, $hqlFilter, $clearIndex, $onlyNew)) | ||
40 | #if ($errorcode > 0) | ||
41 | {{info}}$services.localization.render('search.admin.lucene.indexing.message.started'){{/info}} | ||
42 | #elseif ($errorcode == -1) | ||
43 | {{error}}$services.localization.render('needadminrights').{{/error}} | ||
44 | #elseif ($errorcode == -2) | ||
45 | {{warning}}$services.localization.render('search.admin.lucene.indexing.message.alreadystarted'){{/warning}} | ||
46 | #end | ||
47 | #end | ||
48 | #else## !hasAdmin | ||
49 | {{error}}$services.localization.render('needadminrights').{{/error}} | ||
50 | #end## hasAdmin | ||
51 | {{/velocity}} | ||
52 | |||
53 | (% id="Hsearch.admin.lucene.status.title" %) | ||
54 | == {{velocity}}$services.localization.render('search.admin.lucene.status.title'){{/velocity}} == | ||
55 | |||
56 | {{velocity}} | ||
57 | |=$services.localization.render('search.admin.lucene.status.infotitle')|=$services.localization.render('search.admin.lucene.status.valuetitle') | ||
58 | |$services.localization.render('search.admin.lucene.status.indexed')|$lucene.luceneDocCount | ||
59 | |$services.localization.render('search.admin.lucene.status.indexing')|$lucene.queueSize | ||
60 | {{/velocity}} | ||
61 | |||
62 | (% id="Hsearch.admin.lucene.indexing.title" %) | ||
63 | == {{velocity}}$services.localization.render('search.admin.lucene.indexing.title'){{/velocity}} == | ||
64 | |||
65 | {{velocity}}$services.localization.render('search.admin.lucene.indexing.description'){{/velocity}} | ||
66 | |||
67 | {{velocity}} | ||
68 | #if ($hasAdmin) | ||
69 | {{html}} | ||
70 | <form action="$xwiki.requestURL" enctype="multipart/form-data" method="post"> | ||
71 | <fieldset> | ||
72 | <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> | ||
73 | |||
74 | ## Does not really make sense to reindex the whole farm from a subwiki | ||
75 | #if ($xcontext.isMainWiki()) | ||
76 | <p> | ||
77 | <label for="indexfarm"><input id="indexfarm" name="action" type="radio" value="indexfarm" #if (!$request.action || $request.action == 'indexfarm')checked="checked" #end/> $services.localization.render('search.admin.lucene.indexing.action.indexfarm')</label> | ||
78 | </p> | ||
79 | #end | ||
80 | |||
81 | <p> | ||
82 | <label for="indexcurrentwiki"><input id="indexcurrentwiki" name="action" type="radio" value="indexcurrentwiki" #if((!$xcontext.isMainWiki() && !$request.action) || $request.action == 'indexcurrentwiki'))checked="checked" #end/> $services.localization.render('search.admin.lucene.indexing.action.indexcurrentwiki')</label> | ||
83 | </p> | ||
84 | |||
85 | ## Needs programming right because it takes a custom HQL query which could be dangerous | ||
86 | <p> | ||
87 | <label for="indexcustom"><input id="indexcustom" name="action" type="radio" value="indexcustom" #if ($request.action == 'indexcustom')checked="checked" #end/> $services.localization.render('search.admin.lucene.indexing.action.indexcustom')</label> | ||
88 | </p> | ||
89 | |||
90 | <p> | ||
91 | #if ($xcontext.isMainWiki()) | ||
92 | <label for="indexcustom_wikis">$services.localization.render('search.admin.lucene.indexing.action.indexcustom.wikis')</label> <input id="indexcustom_wikis" name="wikis" type="text" title="$escapetool.xml($services.localization.render('search.admin.lucene.indexing.action.indexcustom.wikis.title'))" value="$!wikisString" /> | ||
93 | #else | ||
94 | <input id="indexcustom_wikis" name="wikis" value="${xcontext.database}" type="hidden" value="$!wikisString" /> | ||
95 | #end | ||
96 | </p> | ||
97 | |||
98 | #if ($hasProgramming) | ||
99 | <p> | ||
100 | <label for="indexcustom_hqlFilter">$services.localization.render('search.admin.lucene.indexing.action.indexcustom.hqlfilter')</label> <input id="indexcustom_hqlFilter" name="hqlFilter" type="text" title="$escapetool.xml($services.localization.render('search.admin.lucene.indexing.action.indexcustom.hqlfilter.title'))" #if($request.hqlFilter)value="${escapetool.xml($request.hqlFilter)}"#end /> | ||
101 | </p> | ||
102 | #end | ||
103 | |||
104 | <p> | ||
105 | <label for="indexcustom_clearIndex"><input id="indexcustom_clearIndex" name="clearIndex" type="checkbox" title="$escapetool.xml($services.localization.render('search.admin.lucene.indexing.action.indexcustom.clearindex.title'))" #if($clearIndex)checked="checked" #end/> $services.localization.render('search.admin.lucene.indexing.action.indexcustom.clearindex')</label> | ||
106 | </p> | ||
107 | <p> | ||
108 | <label for="indexcustom_onlyNew"><input id="indexcustom_onlyNew" name="onlyNew" type="checkbox" title="$escapetool.xml($services.localization.render('search.admin.lucene.indexing.action.indexcustom.onlynew.title'))" #if($onlyNew)checked="checked" #end/> $services.localization.render('search.admin.lucene.indexing.action.indexcustom.onlynew')</label> | ||
109 | </p> | ||
110 | |||
111 | <span class="buttonwrapper"><input type="submit" value="$services.localization.render('search.admin.lucene.indexing.button')" class="button"/></span> | ||
112 | |||
113 | </fieldset> | ||
114 | </form> | ||
115 | {{/html}} | ||
116 | #else## !$hasAdmin | ||
117 | {{error}}$services.localization.render('needadminrights').{{/error}} | ||
118 | #end | ||
119 | {{/velocity}} |