Wiki source code of Tags

Last modified by RB1 on 2019/01/08 16:54

Hide last authors
superadmin 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 ##
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}//"]) ===
RB1 2.1 57 {{notifications useUserPreferences="false" displayOwnEvents="true" tags="$tag" displayRSSLink="true" /}}
superadmin 1.1 58 )))
59 {{/container}}
60 #elseif ($do == 'prepareRename')
61 ##
62 ## Prepare rename tag
63 ##
64 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
65 {{html}}
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" />
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>
72 </div>
73 </form>
74 {{/html}}
75 #elseif ($do == 'renameTag')
76 ##
77 ## Rename tag
78 ##
79 #set ($renameTo = "$!{request.get('renameTo')}")
80 #set ($success = false)
81 #if ($renameTo != '')
82 #set ($success = $xwiki.tag.renameTag($tag, $renameTo))
83 #end
84 #if ($success == true || $success == 'OK')
85 #set ($urlEscapedRenameTo = $escapetool.url($renameTo))
86 $response.sendRedirect($doc.getURL('view', "do=viewTag&tag=${urlEscapedRenameTo}&renamedTag=${urlEscapedTag}"))
87 #else
88 {{error}}$services.localization.render('xe.tag.rename.failure', ["//${tag}//", "//${renameTo}//"]){{/error}}
89 #end
90 #elseif ($do == 'prepareDelete')
91 ##
92 ## Prepare delete tag
93 ##
94 #displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
95 {{html}}
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" />
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>
102 </div>
103 </form>
104 {{/html}}
105 #elseif ($do == 'deleteTag')
106 ##
107 ## Delete tag
108 ##
109 #set ($success = $xwiki.tag.deleteTag($tag))
110 #if ($success == true || $success == 'OK')
111 $response.sendRedirect($doc.getURL('view', "deletedTag=${urlEscapedTag}"))
112 #else
113 {{error}}$services.localization.render('xe.tag.delete.failure', ["//${tag}//"]){{/error}}
114 #end
115 #else
116 ##
117 ## View all tags (Tag Cloud)
118 ##
119 #set ($title = 'All Tags')
120 #if ("$!{request.get('deletedTag')}" != '')
121 {{info}}$services.localization.render('xe.tag.delete.success', ["//${request.get('deletedTag')}//"]){{/info}}
122
123 #end
124 {{tagcloud/}}
125 #end
126 #set ($displayDocExtra = false)
127 {{/velocity}}
Copyright RobotShop 2018