Wiki source code of Tags

Last modified by superadmin on 2017/11/28 14:52
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 ($urlEscapedTag = $escapetool.url($tag))
17 #set ($htmlEscapedTag = $escapetool.xml($tag))
18 ##
19 ## Macro displayTagAppTitle. Display level1 title of this app.
20 ##
21 #macro (displayTagAppTitle $urlEscapedTag $htmlEscapedTag $displayButtons)
22 (% class="xapp" %)
23 = (% class="highlight tag" %)${tag}##
24 #if ($xwiki.hasAdminRights() && $displayButtons) ##
25 [[$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"]]##
26 #end
27 (%%) =
28 #end
29 ##
30 ## Switch between all possible actions:
31 ## viewTag, prepareRename, rename, prepareDelete, delete, default (Tag cloud)
32 ##
33 #if ($do == 'viewTag')
34 ##
35 ## View tag
36 ##
37 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag true)
38 #if ("$!{request.get('renamedTag')}" != '')
39 {{info}}$services.localization.render('xe.tag.rename.success', ["//${request.get('renamedTag')}//"]){{/info}}
40
41 #end
42 #set ($list = $xwiki.tag.getDocumentsWithTag($tag))
43 {{container layoutStyle="columns"}}
44 (((
45 (% class="xapp" %)
46 === $services.localization.render('xe.tag.alldocs', ["//${tag}//"]) ===
47
48 #if ($list.size()> 0)
49 {{html}}#displayDocumentList($list false $blacklistedSpaces){{/html}}
50 #else
51 (% class='noitems' %)$services.localization.render('xe.tag.notags')
52 #end
53 )))
54 (((
55 (% class="xapp" %)
56 === $services.localization.render('xe.tag.activity', ["//${tag}//"]) ===
57
58 {{activity tags="$tag" rss='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 ##
78 ## Rename tag
79 ##
80 #set ($renameTo = "$!{request.get('renameTo')}")
81 #set ($success = false)
82 #if ($renameTo != '')
83 #set ($success = $xwiki.tag.renameTag($tag, $renameTo))
84 #end
85 #if ($success == true || $success == 'OK')
86 #set ($urlEscapedRenameTo = $escapetool.url($renameTo))
87 $response.sendRedirect($doc.getURL('view', "do=viewTag&tag=${urlEscapedRenameTo}&renamedTag=${urlEscapedTag}"))
88 #else
89 {{error}}$services.localization.render('xe.tag.rename.failure', ["//${tag}//", "//${renameTo}//"]){{/error}}
90 #end
91 #elseif ($do == 'prepareDelete')
92 ##
93 ## Prepare delete tag
94 ##
95 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
96 {{html}}
97 <form id="deleteForm" action="$doc.getURL()" method="post">
98 <div>
99 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
100 <input name="do" type="hidden" value="deleteTag" />
101 <input name="tag" type="hidden" value="$htmlEscapedTag" />
102 <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>
103 </div>
104 </form>
105 {{/html}}
106 #elseif ($do == 'deleteTag')
107 ##
108 ## Delete tag
109 ##
110 #set ($success = $xwiki.tag.deleteTag($tag))
111 #if ($success == true || $success == 'OK')
112 $response.sendRedirect($doc.getURL('view', "deletedTag=${urlEscapedTag}"))
113 #else
114 {{error}}$services.localization.render('xe.tag.delete.failure', ["//${tag}//"]){{/error}}
115 #end
116 #else
117 ##
118 ## View all tags (Tag Cloud)
119 ##
120 #set ($title = 'All Tags')
121 #if ("$!{request.get('deletedTag')}" != '')
122 {{info}}$services.localization.render('xe.tag.delete.success', ["//${request.get('deletedTag')}//"]){{/info}}
123
124 #end
125 {{tagcloud/}}
126 #end
127 #set ($displayDocExtra = false)
128 {{/velocity}}