<% 
  import org.exoplatform.ecm.webui.utils.Utils;
  
  String[] hiddenField1 = ["jcrPath=/node/jcr:content", "nodetype=nt:resource", "mixintype=dc:elementSet", "visible=false"] ; 
  String[] hiddenField2 = ["jcrPath=/node/jcr:content/jcr:encoding", "visible=false", "UTF-8"] ;
  String[] hiddenField4 = ["jcrPath=/node/jcr:content/jcr:lastModified", "visible=false"] ;
  String[] hiddenField5 = ["jcrPath=/node/jcr:content/dc:date", "visible=false"] ;
  uicomponent.addHiddenField("hiddenInput1", hiddenField1) ;
  uicomponent.addHiddenField("hiddenInput2", hiddenField2) ;
  uicomponent.addCalendarField("hiddenInput4", hiddenField4) ;
  uicomponent.addCalendarField("hiddenInput5", hiddenField5) ;
%>
<style>
  .uiDocumentFormController .form-horizontal .controls .uiUploadInput {
    margin-right: 13px;
    min-width: 270px;
    width: auto;
  }
</style>
<div class="UIForm FormLayout FormScrollLayout">
  <% uiform.begin() %>

  <div class="uiBox">
  <%/* start render action*/%>
  <% if (uiform.isShowActionsOnTop()) {
            uiform.processRenderAction();
         }
  %>
  <%/* end render action*/%>
    <div class="form-horizontal uiContentBox">
        <div class="control-group">
          <label class="control-label" for="name"><%=_ctx.appRes("File.dialog.label.name")%>:</label>
          <div class="controls">
            <%
              String[] fieldName = ["jcrPath=/node", "mixintype=mix:votable,mix:commentable,mix:i18n,dc:elementSet", "editable=if-null", "validate=empty"];
              uicomponent.addTextField("name", fieldName) ; 
            %>
          </div>
        </div>
        <%if(!uicomponent.getId().equals("UILanguageDialogForm")){%>
          <div class="control-group">
            <label class="control-label" for="categories"><%=_ctx.appRes("File.dialog.label.categories")%>:</label>
            <div class="controls">
              <% 
                String[] fieldCategories = ["jcrPath=/node/exo:category", "multiValues=true", "reference=true", "editable=false"];
                uicomponent.addTextField("categories", fieldCategories);
              %>
            </div>
          </div>
        <%}%>
        <div class="control-group">
          <label class="control-label" for="content-lang"><%=_ctx.appRes("ElementSet.dialog.label.language")%></label>
          <div class="controls">
            <%
              String lang = org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getLocale().toString();
              String[] fieldLang = ["jcrPath=/node/exo:language", "script=ecm-explorer/widget/FillSelectBoxWithLanguage.groovy", lang] ;
              uicomponent.addSelectBoxField("content-lang", fieldLang) ;
            %>
          </div>
        </div>
        
        
        
        
        <!--content-->
        <div class="control-group">
          <label class="control-label" for="content"><%=_ctx.appRes("File.dialog.label.content")%>:</label>
          <div class="controls">
              <%
                if(uicomponent.isEditing()) { 
                  def curNode = uicomponent.getNode() ;
                  if(curNode.hasNode("jcr:content")) {
                    def content = curNode.getNode("jcr:content") ;
                    String mimeType = content.getProperty("jcr:mimeType").getString() ;
                      if (content.getProperty("jcr:data").getStream().available() > 0 && !uicomponent.isDataRemoved("/jcr:content")) {
                        def actionLink = uicomponent.event("RemoveData", "/jcr:content");
                        def fileName = Utils.getTitle(curNode);
                          %> 
                        <a class="nameInfo" rel="tooltip" data-placement="bottom" title="$fileName">
                           $fileName
                        </a>
                        <a class="actionIcon" href="$actionLink">
                          <i class="uiIconDelete uiIconLightGray" rel="tooltip" data-placement="bottom" title="<%=_ctx.appRes("Ecm.dialog.label.remove")%>" alt="<%=_ctx.appRes("Ecm.dialog.label.remove")%>"></i>
                        </a>
                      
                         <%
                      }else{
                        String[] fieldData = ["jcrPath=/node/jcr:content/jcr:data"] ;
                        uicomponent.addUploadField("data", fieldData) ;
                      }
                  } else {
                    String[] fieldData = ["jcrPath=/node/jcr:content/jcr:data"] ;
                    uicomponent.addUploadField("data", fieldData) ;
                  }
                  
                } else {//create new banner slide image  
                  String[] fieldData = ["jcrPath=/node/jcr:content/jcr:data"] ;
                  uicomponent.addUploadField("data", fieldData) ;
                }
              %>
              <div style="display:inline-block;" onmouseover="(function(elm) {eXo.ecm.WCMUtils.showPopover(elm);})(this)" onmouseout="(function(elm) {eXo.ecm.WCMUtils.hidePopover(elm);})(this)" data-toggle="popover" data-placement="left" data-content="For best results we recommend an image with a minimum size of 320x107" data-original-title="" title="">
              <i class="uiIconQuestion uiIconLightGray"> </i>              
            </div>
          </div>
        </div>     
        <!--end of content-->
        
          <div class="control-group">
            <label class="control-label" for="title"><%=_ctx.appRes("ElementSet.dialog.label.title")%></label>
            <div class="controls">
              <%
                String[] fieldTitle = ["jcrPath=/node/jcr:content/dc:title", "multiValues=true"] ;
                uicomponent.addTextField("title", fieldTitle) ;
              %>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="description"><%=_ctx.appRes("ElementSet.dialog.label.description")%></label>
            <div class="controls">
              <%
                String[] fieldDescription = ["jcrPath=/node/jcr:content/dc:description", "multiValues=true"] ;
                uicomponent.addTextField("description", fieldDescription) ; ;
              %>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="creator"><%=_ctx.appRes("ElementSet.dialog.label.creator")%></label>
            <div class="controls">
              <%
                String[] fieldCreator = ["jcrPath=/node/jcr:content/dc:creator", "multiValues=true"] ;
                uicomponent.addTextField("creator", fieldCreator) ;
              %>
            </div>
          </div>
          <div class="control-group">
           <label class="control-label" for="source"><%=_ctx.appRes("ElementSet.dialog.label.source")%></label>
            <div class="controls">
              <%
                String[] fieldSource = ["jcrPath=/node/jcr:content/dc:source", "multiValues=true"] ;
                uicomponent.addTextField("source", fieldSource) ;
              %>
            </div>
          </div>
          
    </div>

  <% if (!uiform.isShowActionsOnTop()) {
            uiform.processRenderAction()
         }
  %>
  </div>
  <%uiform.end()%>
</div>