<%
  	import org.exoplatform.wcm.webui.scv.UISingleContentViewerPortlet;
  	import org.exoplatform.wcm.webui.Utils;
  	import org.exoplatform.wcm.webui.dialog.UIContentDialogForm;
  	import org.exoplatform.ecm.webui.utils.LockUtil;
  	import org.exoplatform.services.jcr.core.ManageableRepository;

		def rcontext = _ctx.getRequestContext();
    def jsManager = rcontext.getJavascriptManager();
    
    String portletId = Utils.getRealPortletId(rcontext);
		def quickEditingBlockId = portletId + "-QuickEditingBlock";
		def hoverClass = Utils.isShowQuickEdit() ? " ContainerHoverClass" : "";
		def node = uicomponent.getNodeView();
		def currentState = uicomponent.getCurrentState();
		if (node != null) {
			def isShowOptionBar = uicomponent.isShowOptionBar(); 
			def isShowTitle = uicomponent.isShowTitle();
			def isShowDate  = uicomponent.isShowDate();
			boolean isShowInfoBar = uicomponent.isShowInfoBar();
			
			if (isShowTitle && (!uicomponent.isViewMode())) {
        def multiLangMsg = uicomponent.getInlineEditingMsg();
        jsManager.addOnLoadJavascript("InlineEditor.loadLanguage(" + multiLangMsg + ")");
      }
      
			def edittingStyle = "z-index: 1";
			if (isShowInfoBar)
				edittingStyle = "z-index: 1; top:20px";
			%>
			<div class="$uicomponent.id" id="$uicomponent.id" 
				onmouseover="this.className = '$uicomponent.id $hoverClass' " onmouseout="this.className = '$uicomponent.id' ">
			<%     
			  if (Utils.isShowQuickEdit() && !LockUtil.isLocked(node)) {	%>	
				 <div class="EdittingToolBarContainer" style="$edittingStyle">
					 <div class="EdittingToolBar " >
						<div class="EdittingToolBarL">
							<div class="EdittingToolBarR">
								<div class="EdittingToolBarC clearfix">
								<%								
								if((!Utils.isPortalEditMode()) && rcontext.getRemoteUser() && Utils.hasEditPermissionOnPage()) {
									%>
									<div style="float: right">
										<a href="<%= uicomponent.event("Preferences")%>" title="<%= _ctx.appRes("UISCVPreferences.label.Preferences")%>" class="PreferencesIcon" >
										  &nbsp;
										</a>         
									</div>
									<%}%>
									<div style="float: right">
									<a onclick = "eXo.ecm.CLV.addURL(this)" href="<%= uicomponent.getQuickEditLink(node) %>" class="EditContentIcon" title="<%= _ctx.appRes("UIPresentationContainer.title.QuickEdit")%>">
										  &nbsp;
										</a>           
									</div>
									<%
									  if (org.exoplatform.wcm.webui.utils.Utils.isShowFastPublish(node)) {
									%>
									<div style="float: right">
                    <a href="<%= uicomponent.event("FastPublish")%>" title="<%= _ctx.appRes("UIPresentationContainer.title.FastPublish")%>" class="FastPublishIcon" >
                      &nbsp;
                    </a>
									</div>
									<%}%>
									<div class="EdittingCurrentState" style="float: right">
                    ${currentState}
                  </div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<%} else {%>
								
				<div class="EdittingToolBarContainer" style="$edittingStyle">
				 <div class="EdittingToolBar " >
					<div class="EdittingToolBarL">
						<div class="EdittingToolBarR">
							<div class="EdittingToolBarC clearfix">
							<%								
							if((!Utils.isPortalEditMode()) && rcontext.getRemoteUser() && Utils.hasEditPermissionOnPage()) {
								%>
								<div style="float: right">
									<a href="<%= uicomponent.event("Preferences")%>" title="<%= _ctx.appRes("UISCVPreferences.label.Preferences")%>" class="PreferencesIcon" >
									  &nbsp;
									</a>         
								</div>
								<%}%>
								<div style="float: right">
									<div class="IconLocked" title="<%= _ctx.appRes("UISCVPreferences.label.LockStatus")%>">
									  &nbsp;
									</div>           
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			
			<%
				}
			if (isShowTitle||isShowDate) {
				%>
					  <% if (isShowTitle) {
  					  if (uicomponent.isViewMode() ){
                %><div class="Title"><%= uicomponent.getTitle(node) %></div><%
  					  }else {
  					   def orgNode =uicomponent.getOriginalNode();    					  
    					  %>
    					  <%= uicomponent.getInlineEditingField(orgNode, "exo:title") %>    						  
                <%            
              }
            } %>
						<% if (isShowDate) { %>
						<div class="DateAndMail"><%= uicomponent.getCreatedDate(node) %></div>
						<% } %>
				<%
			}
				
			if (!Utils.isPortalEditMode() && isShowOptionBar && !uicomponent.isPrinting()) { 
				%>
					<div class="UIOptionBar">
	         <div class="BackButton" title="<%= _ctx.appRes("UISCVPreferences.label.Back") %>" onclick="history.go(-1)"><span></span></div>
						<a class="ActionIcon PrintIcon" href="javascript: void(0);" onclick="window.open('<%= uicomponent.getPrintUrl(node) %>')" title="<%= _ctx.appRes("UIPresentationContainer.label.print");%>"><%= _ctx.appRes("UIPresentationContainer.label.print") %></a>
					</div>
				<% 
			} 
			uicomponent.renderChildren();
			if(uicomponent.isPrinting()) {
        %>
          <div class="ActionContainer">
            <a class="PrintFrameIcon PrintIcon" href="javascript: void(0)" onclick="window.print();"><%= _ctx.appRes("UISCVPreferences.action.Print") %></a>
            <a class="PrintFrameIcon CloseIcon" id="CloseIcon" href="javascript: void(0)" onclick="window.close();"><%= _ctx.appRes("UISCVPreferences.action.Close") %></a>
          </div>
        <%
      } 
			%></div><%

		} else {
		  
		  if((!Utils.isPortalEditMode()) && rcontext.getRemoteUser() && Utils.hasEditPermissionOnPage() && Utils.isShowQuickEdit()) {
				%>
	      <div class="$uicomponent.id" id="$uicomponent.id" 
	      	onmouseover="this.className = '$uicomponent.id $hoverClass'" onmouseout="this.className = '$uicomponent.id' ">
  				<div class="EdittingToolBarContainer" style=" z-index: 1">
          <div class="EdittingToolBar " >
           <div class="EdittingToolBarL">
             <div class="EdittingToolBarR">
               <div class="EdittingToolBarC clearfix">
                 <div style="float: right">
                   <a href="<%= uicomponent.event("Preferences")%>" title="<%= _ctx.appRes("UISCVPreferences.label.Preferences")%>" class="PreferencesIcon" >
                     &nbsp;
                   </a>         
                 </div>            
               </div>
             </div>
           </div>
         </div>
       </div>
       <div class="SCVNoContent">
            <span><%= _ctx.appRes("UIPresentationContainer.msg.no-content") %></span>
       </div>
     </div>			
		<%
		}
	}
if (uicomponent.isPrinting()) {
  %>
   <script type="text/javascript">
  var allElements = document.getElementsByTagName('*');
  for (i in allElements) {
   if (allElements[i].nodeName == 'HTML') continue;   
   if (allElements[i].style) allElements[i].style.overflow = 'visible';
   allElements[i].overflow = 'visible';
  }
  var pdfViewer = document.getElementById("pdf_viewer_image");
  if (pdfViewer != null) pdfViewer.style.height="";
   </script>
 <style type="text/css">
  @media print{
   a{ display:none; }
   overflow{ display:none;}
  }
 </style>
  <%
}
%>
