Wiki source code of Tags

Last modified by Thomas Mortagne on 2020/01/28 17:18

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

Get Connected