Tags

  • Picture of Admin
    Administrator
  • Picture of ttest3
    xWiki admin
{{velocity}}
##
## Tag application.
##
## - See a Tag Cloud of all tags within the wiki.
## - See all the pages tagged with the given tag.
## - Rename a tag.
## - Delete a tag.
##
$xwiki.ssx.use('Main.Tags')##
##
## Set application variables (action and tag) from URL parameters.
##
#set ($do = "$!{request.get('do')}")
#set ($tag = "$!{request.get('tag')}")
#set ($urlEscapedTag = $escapetool.url($tag))
#set ($htmlEscapedTag = $escapetool.xml($tag))
##
## Macro displayTagAppTitle. Display level1 title of this app.
##
#macro (displayTagAppTitle $urlEscapedTag $htmlEscapedTag $displayButtons)
(% class="xapp" %)
= (% class="highlight tag" %)${tag}##
#if ($xwiki.hasAdminRights() && $displayButtons) ##
[[$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"]]##
#end
(%%) =
#end
##
## Switch between all possible actions:
## viewTag, prepareRename, rename, prepareDelete, delete, default (Tag cloud)
##
#if ($do == 'viewTag')
##
## View tag
##
#displayTagAppTitle($urlEscapedTag $htmlEscapedTag true)
#if ("$!{request.get('renamedTag')}" != '')
{{info}}$services.localization.render('xe.tag.rename.success', ["//${request.get('renamedTag')}//"]){{/info}}
 
#end
#set ($list = $xwiki.tag.getDocumentsWithTag($tag))
{{container layoutStyle="columns"}}
(((
(% class="xapp" %)
=== $services.localization.render('xe.tag.alldocs', ["//${tag}//"]) ===
 
#if ($list.size()> 0)
{{html}}#displayDocumentList($list true $blacklistedSpaces){{/html}}
#else
(% class='noitems' %)$services.localization.render('xe.tag.notags')
#end
)))
(((
(% class="xapp" %)
=== $services.localization.render('xe.tag.activity', ["//${tag}//"]) ===
 
{{activity tags="$tag" rss='true'/}}
)))
{{/container}}
#elseif ($do == 'prepareRename')
##
## Prepare rename tag
##
#displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
{{html}}
<form id="renameForm" action="$doc.getURL()" method="post">
<div>
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
<input name="do" type="hidden" value="renameTag" />
<input name="tag" type="hidden" value="$htmlEscapedTag" />
$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>
</div>
</form>
{{/html}}
#elseif ($do == 'renameTag')
##
## Rename tag
##
#set ($renameTo = "$!{request.get('renameTo')}")
#set ($success = false)
#if ($renameTo != '')
#set ($success = $xwiki.tag.renameTag($tag, $renameTo))
#end
#if ($success == true || $success == 'OK')
#set ($urlEscapedRenameTo = $escapetool.url($renameTo))
$response.sendRedirect($doc.getURL('view', "do=viewTag&tag=${urlEscapedRenameTo}&renamedTag=${urlEscapedTag}"))
#else
{{error}}$services.localization.render('xe.tag.rename.failure', ["//${tag}//", "//${renameTo}//"]){{/error}}
#end
#elseif ($do == 'prepareDelete')
##
## Prepare delete tag
##
#displayTagAppTitle($urlEscapedTag $htmlEscapedTag false)
{{html}}
<form id="deleteForm" action="$doc.getURL()" method="post">
<div>
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
<input name="do" type="hidden" value="deleteTag" />
<input name="tag" type="hidden" value="$htmlEscapedTag" />
<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>
</div>
</form>
{{/html}}
#elseif ($do == 'deleteTag')
##
## Delete tag
##
#set ($success = $xwiki.tag.deleteTag($tag))
#if ($success == true || $success == 'OK')
$response.sendRedirect($doc.getURL('view', "deletedTag=${urlEscapedTag}"))
#else
{{error}}$services.localization.render('xe.tag.delete.failure', ["//${tag}//"]){{/error}}
#end
#else
##
## View all tags (Tag Cloud)
##
#set ($title = 'All Tags')
#if ("$!{request.get('deletedTag')}" != '')
{{info}}$services.localization.render('xe.tag.delete.success', ["//${request.get('deletedTag')}//"]){{/info}}
 
#end
{{tagcloud/}}
#end
#set ($displayDocExtra = false)
{{/velocity}}
© INRA Copyright - Directeur de publication : Odile Hologne
XWiki Enterprise 6.4.6 - Mentions Légales