Wiki source code of FAQHomeSheet
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity}} | ||
2 | #set($discard = $xwiki.ssfx.use('uicomponents/pagination/pagination.css', 'true')) | ||
3 | #set($faqHome = $doc.getObject("FAQCode.FAQHomeClass")) | ||
4 | #if($faqHome) | ||
5 | ## Don't display doc extra tabs for FAQ home pages | ||
6 | #set($docextras=[]) | ||
7 | $doc.use("FAQCode.FAQHomeClass") | ||
8 | $xwiki.jsx.use('FAQCode.SkinExtension') | ||
9 | $xwiki.ssx.use('FAQCode.SkinExtension') | ||
10 | ## The space where to add and search for FAQ Entries | ||
11 | #set ($faqSpace = $doc.space) | ||
12 | ## If this page is called with createFAQ=true then create a new page using the FAQTemplate template | ||
13 | #if ($request.createFAQ == 'true') | ||
14 | ## Remove the "?" if it's the last character since the FAQ sheet adds one automatically | ||
15 | #set ($question = $stringtool.stripEnd($stringtool.trim($!{request.question}), '?')) | ||
16 | ## If there's no question then issue a warning below | ||
17 | #if (!$stringtool.isBlank($question)) | ||
18 | #set ($faqPageName = $question) | ||
19 | #if("$!services.modelvalidation" != '' && $services.modelvalidation.configuration.useTransformation()) | ||
20 | #set($faqPageName = $services.modelvalidation.transformName($faqPageName)) | ||
21 | #end | ||
22 | #set ($newFAQReference = $services.model.createDocumentReference('', '', "$faqPageName")) | ||
23 | $response.sendRedirect($xwiki.getURL($newFAQReference, 'inline', "$!{request.queryString}&title=${escapetool.url($question)}")) | ||
24 | #end | ||
25 | #end | ||
26 | #set ($description = $doc.getValue("description")) | ||
27 | #if ("$!description" != "") | ||
28 | {{box cssClass="faqAbout"}} | ||
29 | $doc.display("description") | ||
30 | {{/box}} | ||
31 | #end | ||
32 | |||
33 | (% class="faq-link search-faq box" %)((( | ||
34 | === #if($services.icon)$services.icon.render('find')#end $services.localization.render('platform.faq.search.title') === | ||
35 | ((( | ||
36 | {{html}} | ||
37 | #set($searchDocumentRef = $services.model.createDocumentReference('FAQSearch', $doc.documentReference.parent)) | ||
38 | <form action="$xwiki.getURL($searchDocumentRef)" class="xformInline"> | ||
39 | <div> | ||
40 | ## Lucene search needs the $request.space param | ||
41 | <input type="hidden" name="space" value="${faqSpace}" /> | ||
42 | ## Lucene search needs the $request.wikinames param | ||
43 | <input type="hidden" name="wikinames" value="${xcontext.database}" /> | ||
44 | ## Both Lucene and SOLR searches obey the $request.text param | ||
45 | <input type="text" name="text" value="$services.localization.render('platform.faq.search.questionHint')" size="16" class="withTip" /> | ||
46 | <span class="buttonwrapper"> | ||
47 | <input class="button" type="submit" value="$services.localization.render('platform.faq.search.submit')" /> | ||
48 | </span> | ||
49 | </div> | ||
50 | </form> | ||
51 | {{/html}} | ||
52 | ))) | ||
53 | ))) | ||
54 | |||
55 | #set ($faqSpaceReference = $doc.documentReference.lastSpaceReference) | ||
56 | #if ($isGuest || $services.security.authorization.hasAccess('edit', $faqSpaceReference)) | ||
57 | (% class="faq-link add-faq box" %)((( | ||
58 | === #if($services.icon)$services.icon.render('add')#end $services.localization.render('platform.faq.create.title') === | ||
59 | |||
60 | ((( | ||
61 | #if ($isGuest) | ||
62 | #set($login = ${escapetool.xml($doc.getURL("login", "xredirect=$doc.externalURL"))}) | ||
63 | #set($register = ${escapetool.xml($xwiki.getURL($services.model.resolveDocument('', 'default'), "register", "xredirect=$doc.externalURL"))}) | ||
64 | {{html clean='false'}} | ||
65 | $services.localization.render('platform.faq.need', ["<a href=$login>","</a>","<a href=$register>","</a>"]) | ||
66 | {{/html}} | ||
67 | #elseif ($services.security.authorization.hasAccess('edit', $faqSpaceReference)) | ||
68 | #set ($parent = $services.model.resolveDocument('', 'default', $faqSpaceReference)) | ||
69 | {{html clean='false' wiki='true'}} | ||
70 | <form action="$doc.getURL()" id="newfaq" class="xformInline"> | ||
71 | <div> | ||
72 | <input type="hidden" name="parent" value="$parent" /> | ||
73 | <input type="hidden" name="template" value="FAQCode.FAQTemplate" /> | ||
74 | <input type="hidden" name="createFAQ" value="true" /> | ||
75 | #if ($request.createFAQ == 'true' && $stringtool.isBlank($question)) | ||
76 | {{error}}$services.localization.render('platform.faq.create.empty'){{/error}} | ||
77 | #end | ||
78 | <input class="withTip" type="text" name="question" value="$services.localization.render('platform.faq.create.questionHint')" size="16"/> | ||
79 | <span class="buttonwrapper"> | ||
80 | <input class="btn btn-success button" type="submit" value="$services.localization.render('platform.faq.create.submit')" /> | ||
81 | </span> | ||
82 | </div> | ||
83 | </form> | ||
84 | {{/html}} | ||
85 | #end | ||
86 | ))) | ||
87 | ))) | ||
88 | #end | ||
89 | |||
90 | (% class="clearfloats" %)((()))(%%) | ||
91 | |||
92 | {{faq filter="space=${faqSpace}"/}} | ||
93 | #else | ||
94 | This class sheet must be applied on a document containing an FAQCode.FAQHomeClass object | ||
95 | #end | ||
96 | {{/velocity}} |