##
## Document footer: tags, creation date, modification date
##
##
<div id="xdocFooter">
  #template("documentTags.vm")
  <div id="xdocAuthors">
    <div class="xdocCreation"> ## Creation
      $services.localization.render('core.footer.creation', [$xwiki.getUserName($doc.creator), $xwiki.formatDate($doc.creationDate)])<br/>
      #if($tdoc.realLanguage != $doc.realLanguage)
        $services.localization.render('core.footer.translationCreation', [$tdoc.realLanguage, $xwiki.getUserName($tdoc.creator), $xwiki.formatDate($tdoc.creationDate)])<br/>
      #end
    </div>
  </div>
</div>
##
##
## More document related data: comments, attachments ...
##
<div id="xwikidata">
##
## Build the list of documents extras to display, if it does not exist (default).
## List format : ['ExtraAnchor', 'ExtraName', 'ExtraTabText', ExtraNumberOfItems, 'extratemplate.vm', 'keyboardShortcut']
##
#if (!$docextras)
  #set ($docextras = [])
  #if ($showcomments)
    $xwiki.jsfx.use('uicomponents/viewers/comments.js', {'forceSkinAction': true, 'language': ${xcontext.language}})
    $xwiki.ssfx.use('uicomponents/viewers/comments.css', true)
    #set ($discard = $docextras.add(['Comments', 'comments', $services.localization.render('docextra.comments'), $doc.getObjects('XWiki.XWikiComments').size(), 'commentsinline.vm', $services.localization.render('core.shortcuts.view.comments')]))
  #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 = $docextras.add(['Annotations', 'annotations', $services.localization.render('docextra.annotations'), $annotationCount, 'annotationsinline.vm', $services.localization.render('core.shortcuts.view.annotations')]))
  #end
  #if ($showattachments)
    $xwiki.jsfx.use('uicomponents/widgets/upload.js', {'forceSkinAction': true, 'language': ${xcontext.language}})
    $xwiki.ssfx.use('uicomponents/widgets/upload.css', true)
    $xwiki.jsfx.use('js/xwiki/viewers/attachments.js', {'forceSkinAction': true, 'language': ${xcontext.language}})
    $xwiki.ssfx.use('js/xwiki/viewers/attachments.css', true)
    ### Support attachment sorting
    #set ($sortAttachmentsBy = "$!{request.sortAttachmentsBy}")
    #if ($sortAttachmentsBy != '')
      ## Prepend request parameter
      #set ($sortAttachmentsBy = "&sortAttachmentsBy=$escapetool.url(${sortAttachmentsBy})")
    #end
    #set ($discard = $docextras.add(['Attachments', 'attachments', $services.localization.render('docextra.attachments'), $doc.getAttachmentList().size(), "attachmentsinline.vm$!{sortAttachmentsBy}", $services.localization.render('core.shortcuts.view.attachments')]))
  #end
  #if ($showhistory)
    ## Pagination style
    $xwiki.ssfx.use('uicomponents/pagination/pagination.css', true)##
    #set ($discard = $docextras.add(['History', 'history', $services.localization.render('docextra.history'), -1, 'historyinline.vm', $services.localization.render('core.shortcuts.view.history')]))
  #end
  #if ($showinformation)
    #set ($discard = $docextras.add(['Information', 'information', $services.localization.render('docextra.information'), -1, 'informationinline.vm', $services.localization.render('core.shortcuts.view.information')]))
  #end
#end
##
## Put anchors before the footer, otherwise the top of each section would be hidden by the floating topmenu
##
#if ($docextras.size() > 0)
<div id="docextraanchors">
#foreach ($docextra in $docextras)<span id="${docextra.get(0)}anchor">&nbsp;</span>#end
</div>
#end
##
## Display tabs
##
#if($docextras.size() > 0)
  <div id="xwikidatacontents">
    <div class="floatcontainer" id="docExtraTabs">
      <ul class="xwikitabbar" id="docExtrasTabsUl">
        #foreach($docextra in $docextras)
          <li id="${docextra.get(0)}tab">
            <a id="${docextra.get(0)}link" href="$doc.getURL('view', "viewer=${docextra.get(1)}")">
              $docextra.get(2) #if($docextra.get(3) >= 0) <span class="itemCount">$services.localization.render('docextra.extranb', [$docextra.get(3)])</span> #end
            </a>
          </li>
        #end
      </ul>
    </div>
    ##
    ## Display panes (AJAX placeholders)
    ##
    <div id="docextrapanes">
      #foreach($docextra in $docextras)
        <div id="${docextra.get(0)}pane" class="hidden empty"></div>
      #end
    </div>
    ##
    ## JavaScript code generation
    ##
    <script type="text/javascript">
      var hashviewer = self.document.location.hash.substring(1);
      #foreach($docextra in $docextras)
        #set ($extraAnchor = $docextra[0])
        #set ($extraName = $docextra[1])
        #set ($extraTemplate = $docextra[4])
        #set ($extraShortcut = $docextra[5])
        ##
        ## Set the extra to load
        ##
        #if ($velocityCount == 1)
          var extraInit = function(){ XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", false) };
        #end
        if (hashviewer == "${extraAnchor}") {
          var extraInit = function(){ XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", true) };
        }
        ##
        ## Replace tab link
        ##
        if ($("${extraAnchor}link") != null) {
          $("${extraAnchor}link").href="#${extraAnchor}";
          Event.observe($("${extraAnchor}link"), "click", function(){ XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", false); }, false);
        }
        ##
        ## Replace top menu link (if any)
        ##
        if ($("tmShow${extraAnchor}") != null) {
          $("tmShow${extraAnchor}").href="#${extraAnchor}";
          Event.observe($("tmShow${extraAnchor}"), "click", function(){ XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", true); }, false);
        }
        ##
        ## Replace shortcut link (if any)
        ##
        if ($("${extraName}shortcut") != null) {
          $("${extraName}shortcut").down('a').href="#${extraName}";
          Event.observe($("${extraName}shortcut"), "click", function(){ XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", true); }, false);
        }
        ##
        ## Override keyboard shortcut (if any)
        ##
        #if ($keyboardShortcutsEnabled && "$!extraShortcut" != "")
          shortcut.remove("$extraShortcut");
          shortcut.add("$extraShortcut", function() { XWiki.displayDocExtra("${extraAnchor}", "${extraTemplate}", true); }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        #end
      #end
      document.observe("dom:loaded", extraInit, false);
    </script>
  </div> ## xwikidatacontents
#end
</div>  ## xwikidata
