Afficher les derniers auteurs
1 {{velocity output="false"}}
2 #macro (databaseSearchForm)
3 {{html clean="false"}}
4 <form action="$doc.getURL()" id="searchBar" role="search">
5 <div>
6 <label for="text" class="hidden">$services.localization.render('search.page.query.label')</label>
7 <input type="text" id="text" name="text" class="searchQuery" value="$!escapetool.xml($request.text)"
8 title="$services.localization.render('search.page.bar.query.title')"
9 placeholder="$services.localization.render('search.page.bar.query.tip')" />
10 <input type="text" name="space" class="suggestSpaces" value="$!escapetool.xml($request.space)"
11 placeholder="$services.localization.render('search.page.bar.spaces.title')" />
12 <span class='buttonwrapper'>
13 <input type="submit" class="searchButton button"
14 value="$services.localization.render('search.page.bar.submit')"
15 title="$services.localization.render('search.page.bar.submit.title')" />
16 </span>
17 </div>
18 </form>
19 {{/html}}
20 #end
21
22 #macro (databaseAddResults $statement $params $map)
23 #set ($query = $services.query.hql("$statement order by doc.date desc").addFilter('hidden').setLimit(50))
24 #foreach ($entry in $params.entrySet())
25 #set ($query = $query.bindValue($entry.key, $entry.value))
26 #end
27 #foreach ($localDocRef in $query.execute())
28 #set ($documentReference = $services.model.resolveDocument($localDocRef))
29 #if ($services.security.authorization.hasAccess('view', $documentReference))
30 #set ($discard = $map.put($documentReference, $xwiki.getDocument($documentReference)))
31 #end
32 #end
33 #end
34
35 #macro (databaseSearch $text $list)
36 #set ($results = {})
37 #set ($matchLocation = '')
38 #set ($params = {
39 'text': "%$text.replaceAll('([%_!])', '!$1')%"
40 })
41 ## Search in the specified location, if $request.space is defined
42 #set ($space = $request.space)
43 #if ("$!space" != '')
44 #set ($matchLocation = "(doc.space = :space or doc.space like :spacePrefix escape '!') and")
45 #set ($params.space = $space)
46 #set ($spaceReference = $services.model.resolveSpace($space))
47 #set ($documentReference = $services.model.createDocumentReference('x', $spaceReference))
48 #set ($params.spacePrefix = $stringtool.removeEnd($services.model.serialize($documentReference), 'x'))
49 #set ($params.spacePrefix = "$params.spacePrefix.replaceAll('([%_!])', '!$1')%")
50 #end
51 ## Search in the page names
52 #databaseAddResults(", XWikiSpace as space where $matchLocation space.reference = doc.space and ((doc.name <> 'WebHome' and upper(doc.name) like upper(:text) escape '!') or (doc.name = 'WebHome' and upper(space.name) like upper(:text) escape '!'))" $params $results)
53 ## Search in page content
54 #databaseAddResults("where $matchLocation upper(doc.content) like upper(:text) escape '!'" $params $results)
55 ## Search in text fields (simple String properties)
56 #databaseAddResults(", BaseObject as obj, StringProperty as prop where $matchLocation obj.name = doc.fullName and prop.id.id = obj.id and upper(prop.value) like upper(:text) escape '!'" $params $results)
57 ## Search in big text fields (textarea properties)
58 #databaseAddResults(", BaseObject as obj, LargeStringProperty as prop where $matchLocation obj.name = doc.fullName and prop.id.id = obj.id and upper(prop.value) like upper(:text) escape '!'" $params $results)
59 #set ($discard = $list.addAll($collectiontool.sort($results, ['date'])))
60 #end
61 {{/velocity}}
62
63 {{velocity}}
64 #set ($rssMode = $xcontext.action == 'get' || "$!request.xpage" == 'plain')
65 #if (!$rssMode)
66 #set ($discard = $xwiki.ssfx.use('uicomponents/search/search.css', true))
67 ## Disable the document extra data: comments, attachments, history...
68 #set ($displayDocExtra = false)
69 #databaseSearchForm
70 #end
71 #set ($text = "$!request.text")
72 #if ($text != '')
73 #set ($list = [])
74 #databaseSearch($text $list)
75 #if ($rssMode)
76 #set ($feed = $xwiki.feed.getDocumentFeed($list, {}))
77 #set ($feedURI = $doc.getExternalURL("view"))
78 #set ($discard = $feed.setLink($feedURI))
79 #set ($discard = $feed.setUri($feedURI))
80 #set ($discard = $feed.setAuthor('XWiki'))
81 #set ($discard = $feed.setTitle($services.localization.render('search.rss', [$text])))
82 #set ($discard = $feed.setDescription($services.localization.render('search.rss', [$text])))
83 #set ($discard = $feed.setLanguage("$xcontext.locale"))
84 #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))
85 #set ($discard = $response.setContentType('application/rss+xml'))
86 {{{$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))}}}
87 #else
88 {{include reference="XWiki.Results"/}}
89
90 {{html clean="false"}}
91 #set ($rssURL = $doc.getURL('get', $escapetool.url({
92 'outputSyntax': 'plain',
93 'space': $space,
94 'text': $text
95 })))
96 <a href="$rssURL" class="hasIcon iconRSS">
97 $services.localization.render('search.rss', ["[$escapetool.xml($text)]"])
98 </a>
99 {{/html}}
100 #end
101 #end
102 {{/velocity}}
#getBlogDocument($space $blogDoc)
XWiki Enterprise 14.6 - Documentation