Show last authors
1 {{velocity}}
2 ##
3 ## Tag application.
4 ##
5 ## - See a Tag Cloud of all tags within the wiki.
6 ## - See all the pages tagged with the given tag.
7 ## - Rename a tag.
8 ## - Delete a tag.
9 ##
10 $xwiki.ssx.use('Main.Tags')##
11 ##
12 ## Set application variables (action and tag) from URL parameters.
13 ##
14 #set ($do = "$!{request.get('do')}")
15 #set ($tag = "$!{request.get('tag')}")
16 #set ($wikiEscapedTag = $services.rendering.escape($tag, 'xwiki/2.1'))
17 #set ($urlEscapedTag = $escapetool.url($tag))
18 #set ($htmlEscapedTag = $escapetool.xml($tag))
19 ##
20 ## Macro displayTagAppTitle. Display level1 title of this app.
21 ##
22 #macro (displayTagAppTitle $urlEscapedTag $htmlEscapedTag $displayButtons)
23 (% class="xapp" %)
24 = (% class="highlight tag" %)${wikiEscapedTag}##
25 #if ($xwiki.hasAdminRights() && $displayButtons) ##
26 [[$services.localization.render('xe.tag.rename.link')>>||queryString="do=prepareRename&tag=${urlEscapedTag}" class="button rename" rel="nofollow"]] [[$services.localization.render('xe.tag.delete.link')>>||queryString="do=prepareDelete&tag=${urlEscapedTag}" class="button delete" rel="nofollow"]]##
27 #end
28 (%%) =
29 #end
30 ##
31 ## Switch between all possible actions:
32 ## viewTag, prepareRename, rename, prepareDelete, delete, default (Tag cloud)
33 ##
34 #if ($do == 'viewTag')
35 ##
36 ## View tag
37 ##
38 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag true)
39 #if ("$!{request.get('renamedTag')}" != '')
40 {{info}}$services.localization.render('xe.tag.rename.success', ["//${services.rendering.escape(${request.get('renamedTag')}, 'xwiki/2.1')}//"]){{/info}}
41
42 #end
43 #set ($list = $xwiki.tag.getDocumentsWithTag($tag))
44 {{container layoutStyle="columns"}}
45 (((
46 (% class="xapp" %)
47 === $services.localization.render('xe.tag.alldocs', ["//${wikiEscapedTag}//"]) ===
48
49 #if ($list.size()> 0)
50 {{html}}#displayDocumentList($list false $blacklistedSpaces){{/html}}
51 #else
52 (% class='noitems' %)$services.localization.render('xe.tag.notags')
53 #end
54 )))
55 (((
56 (% class="xapp" %)
57 === $services.localization.render('xe.tag.activity', ["//${wikiEscapedTag}//"]) ===
58 {{notifications useUserPreferences="false" displayOwnEvents="true" tags="$wikiEscapedTag" displayRSSLink="true" /}}
59 )))
60 {{/container}}
61 #elseif ($do == 'prepareRename')
62 ##
63 ## Prepare rename tag
64 ##
65 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
66 {{html}}
67 <form id="renameForm" action="$doc.getURL()" method="post">
68 <div>
69 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
70 <input name="do" type="hidden" value="renameTag" />
71 <input name="tag" type="hidden" value="$htmlEscapedTag" />
72 $services.localization.render('xe.tag.rename.renameto', [$htmlEscapedTag]) <input type="text" name="renameTo" /> <span class="buttonwrapper"><input type="submit" value="$services.localization.render('xe.tag.rename')" class="button"/></span><span class="buttonwrapper"><a href="$doc.getURL('view', "do=viewTag&tag=${urlEscapedTag}")" class="secondary button">$services.localization.render('cancel')</a></span>
73 </div>
74 </form>
75 {{/html}}
76 #elseif ($do == 'renameTag')
77 #if (!$services.csrf.isTokenValid($request.get('form_token')))
78 #set ($discard = $response.sendError(401, "Wrong CSRF token"))
79 #else
80 ##
81 ## Rename tag
82 ##
83 #set ($renameTo = "$!{request.get('renameTo')}")
84 #set ($success = false)
85 #if ($renameTo != '')
86 #set ($success = $xwiki.tag.renameTag($tag, $renameTo))
87 #end
88 #if ($success == true || $success == 'OK')
89 #set ($urlEscapedRenameTo = $escapetool.url($renameTo))
90 $response.sendRedirect($doc.getURL('view', "do=viewTag&tag=${urlEscapedRenameTo}&renamedTag=${urlEscapedTag}"))
91 #else
92 {{error}}$services.localization.render('xe.tag.rename.failure', ["//${wikiEscapedTag}//", "//${services.rendering.escape($renameTo, 'xwiki/2.1')}//"]){{/error}}
93 #end
94 #end
95 #elseif ($do == 'prepareDelete')
96 ##
97 ## Prepare delete tag
98 ##
99 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
100 {{html}}
101 <form id="deleteForm" action="$doc.getURL()" method="post">
102 <div>
103 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
104 <input name="do" type="hidden" value="deleteTag" />
105 <input name="tag" type="hidden" value="$htmlEscapedTag" />
106 <span class="buttonwrapper"><input type="submit" value="$services.localization.render('xe.tag.delete', [$htmlEscapedTag])" class="button"/></span><span class="buttonwrapper"><a href="$doc.getURL('view', "do=viewTag&tag=${urlEscapedTag}")" class="secondary button">$services.localization.render('cancel')</a></span>
107 </div>
108 </form>
109 {{/html}}
110 #elseif ($do == 'deleteTag')
111 #if (!$services.csrf.isTokenValid($request.get('form_token')))
112 #set ($discard = $response.sendError(401, "Wrong CSRF token"))
113 #else
114 ##
115 ## Delete tag
116 ##
117 #set ($success = $xwiki.tag.deleteTag($tag))
118 #if ($success == true || $success == 'OK')
119 $response.sendRedirect($doc.getURL('view', "deletedTag=${urlEscapedTag}"))
120 #else
121 {{error}}$services.localization.render('xe.tag.delete.failure', ["//${wikiEscapedTag}//"]){{/error}}
122 #end
123 #end
124 #else
125 ##
126 ## View all tags (Tag Cloud)
127 ##
128 #set ($title = 'All Tags')
129 #if ("$!{request.get('deletedTag')}" != '')
130 {{info}}$services.localization.render('xe.tag.delete.success', ["//${services.rendering.escape($request.get('deletedTag'), 'xwiki/2.1')}//"]){{/info}}
131
132 #end
133 {{tagcloud/}}
134 #end
135 #set ($displayDocExtra = false)
136 {{/velocity}}
Rangee GmbH ©2022