## Insert JS and CSS needed for the fullscreen edit feature
$xwiki.jsfx.use('uicomponents/widgets/fullScreen.js', {'forceSkinAction': true, 'language': ${xcontext.language}})##
$xwiki.ssfx.use('uicomponents/widgets/fullScreen.css', true)##
#set($formname = "inline")
#set($saveaction = "save")
#set($previewenabled = true)
## Determine if editing should be allowed
#set($force = $!request.get("force"))
#set($allowDocEdit = !(($doc.getLocked()==true)&&(!$force)) )
##
<div class="main">
<div id="mainContentArea">
## ----------------------------------------------------------------------------
## Start FORM at start of content area IF editing is allowed.
## ----------------------------------------------------------------------------
#if ($allowDocEdit)
 <form id="inline" method="post" action="$doc.getURL("preview")" class="withLock">
#end
#template("hierarchy.vm")
<div class="row">
  <div id="editMeta" class="col-xs-12 col-md-7">
    #template('editmeta.vm')
    ## ----------------------------------------------------------------------------
    ## Compute title to display and modify rendered content accordingly.
    ## ----------------------------------------------------------------------------
    #set ($renderedContent = $cdoc.getRenderedContent())
    #template("titlevars.vm")
    ## ----------------------------
    ## Display the title
    ## ----------------------------
    <div id="document-title"><h1>$titleToDisplay</h1></div>
  </div>
  #if($displayContentMenu)
    <div class="col-xs-12 col-md-5">
      #template("menus_content.vm")
    </div>
  #end
</div>
##
## If the document cannot be edited, display an information and a forcing link:
##
#if (!$allowDocEdit)
  <div>
  $response.setStatus(423)
  #set($newquerystring = "$!{request.getQueryString().replaceAll('&', '&amp;').replaceAll('&amp;amp;', '&amp;')}&amp;force=1")
  #set($forceEditURL = $doc.getURL($xcontext.action, ${newquerystring}))
  #xwikimessageboxstart($services.localization.render('notice') "$services.localization.render('doclockedby') $xwiki.getUserName($doc.getLockingUser())")
    <a href="$forceEditURL">$services.localization.render('forcelock')</a>
  #xwikimessageboxend()
  </div>
#else
##
## Otherwise, can edit - continue the form.
##
<div>
<input type="hidden" name="xcontinue" value="$doc.getURL($doc.getDefaultEditMode(), 'editor=inline')"/>
## CSRF prevention
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
## This input is used by the full screen widget: it stores the selector of the maximized element, so that the full screen can be restored when coming back from preview.
<input type="hidden" name="x-maximized" value="$!{escapetool.xml(${request.get('x-maximized')})}" />
<input type="hidden" name="xredirect" value="$!{escapetool.xml($request.get('xredirect'))}" />
<input type="hidden" name="xnotification" value="$!{escapetool.xml($request.get('xnotification'))}" />
<input type="hidden" name="template" value="$!{escapetool.xml($request.template)}" />
## We need to submit the language of the translated document because the inline edit mode is not limited to editing only
## the objects, which are shared by all translations. We can also edit the content or the title of the document which are
## specific to each translation and so we need to specify which translation is being edited.
<input type="hidden" name="language" value="$!{escapetool.xml($tdoc.realLanguage)}" />
#if("$!request.parent" != '')
  <input type="hidden" name="parent" value="$escapetool.xml($!request.parent)" />
#end
#if("$!request.title" != '')
  <input type="hidden" name="title" value="$escapetool.xml($!request.title)" />
#end
## ----------------------------
## Display the rendered content
## ----------------------------
$renderedContent
#set($editactions = "bottom")
<div class="bottombuttons">#template("editactions.vm")</div>
</div> ## form
</form>
#template("textarea_wysiwyg.vm")
#end ## can edit
</div> ## mainContentArea
</div> ## main
