##
##
## Build the list of documents extras to display, if it does not exist (default).
## List format : ["ExtraAnchor",  "ExtraTabText", numberOfItems]
##
#if (!$docextralinks && !$docextras)
  #set($docextralinks = [])
  #if($xcontext.action == 'view' && $viewer != 'content')
    #set ($discard = $docextralinks.add(['content', $services.localization.render('core.links.content'), -1, 'file']))
  #end
  #if($viewer != 'comments' && $showcomments)
    #set ($discard = $docextralinks.add(['comments', $services.localization.render('docextra.comments'), $doc.getObjects('XWiki.XWikiComments').size(), 'comment']))
  #end
  #if($showannotations)
    #if(!$annotationCount)
      ## Annotation count is supposed to be defined in xwikivars.vm. If for a reason or another it is not
      ## defined at this point, we tap into the standard annotation class, and do not load again the 
      ## config document. This however should not happen.
      #set($annotationCount = $doc.getObjects('AnnotationCode.AnnotationClass').size())
    #end
    #set ($discard = $docextralinks.add(['annotations', $services.localization.render('docextra.annotations'), $annotationCount, 'pushpin']))
  #end
  #if($viewer != 'attachments' && $showattachments)
    #set ($discard = $docextralinks.add(['attachments', $services.localization.render('docextra.attachments'), $doc.getAttachmentList().size(), 'paperclip']))
  #end
  #if($viewer != 'history' && $showhistory)
    #set ($discard = $docextralinks.add(['history', $services.localization.render('docextra.history'), -1, 'time']))
  #end
  #if($viewer != 'information' && $showinformation)
    #set ($discard = $docextralinks.add(['information', $services.localization.render('docextra.information'), -1, 'info-sign']))
  #end
#end

#if($xcontext.action == 'view' && $viewer != 'content')
  <div class="text-right">
  #xwikibuttonentrystart('' $services.localization.render('core.menu.moreactions') 'tmMoreActions' 'btn-default' 'cog')
#end
#foreach($docextralink in $docextralinks)
  #set ($extraAnchor = $docextralink.get(0))
  #set ($extraText = $docextralink.get(1))
  #set ($extraCount = $docextralink.get(2))
  #set ($glyphIcon = '')
  #if ($docextralink.size()>3)
    #set ($glyphIcon = $docextralink.get(3))
  #end
  #submenuitem($doc.getURL('view', "viewer=$!{escapetool.url(${extraAnchor})}"), ${escapetool.xml(${extraText})}, '', '', $glyphIcon)
#end
#if($xcontext.action == 'view' && $viewer != 'content')
  #xwikibuttonentryend()
  </div>
#end
