#set ($canShare = $canView && $xwiki.exists('XWiki.SharePage') && !$isGuest)
<div id="contentmenu" class="pull-right actionmenu">
#if($hasEdit && !$isReadOnly)
  ## Compute the default edit mode
  #set($editaction = $doc.getDefaultEditMode())
  ##
  ## Edit menu
  ##
  #if($isAdvancedUser)
    #xwikisplitbuttonentrystart($doc.getURL($editaction, $!languageparams) $services.localization.render('core.menu.edit') 'tmEdit' 'btn-primary' 'pencil')
      #submenuitem($doc.getURL('edit', "$!{languageparams}#if ($languageparams != '')&amp;#{end}editor=wiki") $services.localization.render('core.menu.edit.wiki') 'tmEditWiki', '', 'wrench')
      ## Check if the WYSIWYG supports the current document's syntax and if so add a menu entry to edit the current
      ## document with the WYSIWYG editor.
      #if ($services.wysiwyg.isSyntaxSupported($tdoc.syntax.toIdString()) || $tdoc.syntax.toIdString() == 'xwiki/1.0')
        #submenuitem($doc.getURL('edit', "$!{languageparams}#if ($languageparams != '')&amp;#{end}editor=wysiwyg") $services.localization.render('core.menu.edit.wysiwyg') 'tmEditWysiwyg', '', 'pencil')
      #end
      #submenuitem($doc.getURL($editaction, "$!{languageparams}#if ($languageparams != '')&amp;#{end}editor=inline") $services.localization.render('core.menu.edit.inline') 'tmEditInline', '', 'list-alt')
      #submenuseparator()
      #submenuitem($doc.getURL('edit', 'editor=rights') $services.localization.render('core.menu.edit.rights') 'tmEditRights', '', 'hdd')
      #submenuitem($doc.getURL('edit', 'editor=object') $services.localization.render('core.menu.edit.object') 'tmEditObject', '', 'hdd')
      #submenuitem($doc.getURL('edit', 'editor=class') $services.localization.render('core.menu.edit.class') 'tmEditClass', '', 'hdd')
    #xwikibuttonentryend()
  #else ## !isAdvanced
    #xwikibutton($doc.getURL($editaction, $!languageparams) $services.localization.render('core.menu.edit') 'tmEdit', 'btn-primary', 'pencil')
  #end
  #if($keyboardShortcutsEnabled)
    <script type="text/javascript">
    //<![CDATA[
      shortcut.add("$services.localization.render('core.shortcuts.view.edit')",function() { location.href=$('tmEdit').down('a').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
      #if($isAdvancedUser)
        shortcut.add("$services.localization.render('core.shortcuts.view.wiki')",function() { location.href=$('tmEditWiki').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        shortcut.add("$services.localization.render('core.shortcuts.view.wysiwyg')",function() { location.href=$('tmEditWysiwyg').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        shortcut.add("$services.localization.render('core.shortcuts.view.inline')",function() { location.href=$('tmEditInline').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        shortcut.add("$services.localization.render('core.shortcuts.view.rights')",function() { location.href=$('tmEditRights').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        shortcut.add("$services.localization.render('core.shortcuts.view.objects')",function() { location.href=$('tmEditObject').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        #if($hasAdmin)
          shortcut.add("$services.localization.render('core.shortcuts.view.class')",function() { location.href=$('tmEditClass').href; }, { 'type':'keypress', 'propagate':false, 'disable_in_input':true });
        #end
      #end
    //]]>
    </script>
  #end
#end
##
## Actions menu
##
#if($displayMoreActionsMenu && !$doc.isNew())
  #xwikibuttonentrystart('' $services.localization.render('core.menu.moreactions') 'tmMoreActions' 'btn-default' 'cog')
    ## Export
    #submenuitem('' $services.localization.render('core.menu.export') 'tmExport', '', 'download-alt', 'data-toggle="modal" data-target="#exportModal"')
    #submenuitem($doc.getURL('view', "xpage=print&amp;$!escapetool.html($request.getQueryString())") $services.localization.render('core.menu.preview') 'tmPrintPreview', '', 'print')
    #submenuitem($doc.getURL('view', "viewer=code") $services.localization.render('core.menu.view.source') 'tmViewSource', '', 'search')
    ## Share by email
    #if ($canShare)
      #submenuitem($xwiki.getURL($doc.documentReference, 'view', 'viewer=share') $services.localization.render('core.menu.share') 'tmActionShare', '', 'envelope')
      #userPicker_import()
      $xwiki.jsx.use('XWiki.SharePage')
      $xwiki.ssx.use('XWiki.SharePage')
    #end
    
    ## ----------------------------
    ## Display the shortcuts
    ## ----------------------------
    #if($displayShortcuts)
      #submenuseparator()
      #template("shortcuts.vm")
    #end
    
  #xwikibuttonentryend()
  ## Export modal
  <div class="modal fade text-left" id="exportModal" tabindex="-1" role="dialog" aria-labelledby="exportModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="exportModalLabel">$services.localization.render('core.menu.export')</h4>
        </div>
        <div class="modal-body">
          <a href="$doc.getURL('view', "xpage=pdfoptions&amp;qs=$!escapetool.url($request.getQueryString())")" class="btn btn-primary">$services.localization.render('core.menu.export.pdf')</a>
          #if("$!{services.officemanager.serverState}" == "Connected")
            <a href="$doc.getURL('export', "format=odt&amp;$!escapetool.html($request.getQueryString())")" class="btn btn-primary">$services.localization.render('core.menu.export.odt')</a>
            <a href="$doc.getURL('export', "format=rtf&amp;$!escapetool.html($request.getQueryString())")" class="btn btn-primary">$services.localization.render('core.menu.export.rtf')</a>
          #end
          <a href="$doc.getURL('export', "format=html&amp;$!escapetool.html($request.getQueryString())")" class="btn btn-primary">$services.localization.render('core.menu.export.html')</a>
          #if($hasAdmin && "$!xwiki.getPlugin('package')" != '')
            <a href="$doc.getURL('export', "format=xar&amp;name=$escapetool.url($doc.fullName)&amp;pages=$escapetool.url($doc.fullName)&amp;$!docvariant")" class="btn btn-primary">$services.localization.render('core.menu.export.xar')</a>
          #end
          <button type="button" class="btn btn-default" data-dismiss="modal">$services.localization.render('cancel')</button>
        </div>
      </div>
    </div>
  </div>
  #if ($keyboardShortcutsEnabled)
    <script type="text/javascript">
    //<![CDATA[
      shortcut.add("$services.localization.render('core.shortcuts.view.code')", function() {
        location.href = $('tmViewSource').href;
      }, {'type': 'keypress', 'propagate': false, 'disable_in_input': true });
    //]]>
    </script>
  #end
#end
</div>
