<%
	 /**
	 	* Created by The eXo Platform SAS
	 	* Author : eXoPlatform
	 	*          chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com
	 	* Aug 20, 2009
	 	*/

	 	import javax.jcr.Node;
	 	import org.exoplatform.wcm.webui.paginator.UICustomizeablePaginator;
	 	import org.exoplatform.wcm.webui.clv.UICLVPortlet;
	 	import org.exoplatform.wcm.webui.Utils;
	 	import org.exoplatform.services.wcm.core.NodeLocation;
	 	import org.exoplatform.services.jcr.core.ManageableRepository;
	 	import org.exoplatform.webui.application.WebuiRequestContext;


	 	def propertyName = "exo:title";
	 	def repo = "";
	 	def workspace = "";
	 	def uuid = "";

	 	def siteName = org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getPortalOwner();
	 	Locale locale = WebuiRequestContext.getCurrentInstance().getLocale();
	 	def language = locale.getLanguage();

	 	def draftMsg = _ctx.appRes("PublicationStates.draft");
	 	def publishedMsg = _ctx.appRes("PublicationStates.published");
	 	%>

	 	<div id="$uicomponent.id" class="threeColumnsCLVTemplate">
<section class="well-9 bg">
				<div class="container">
					<h3 class="center">Asked questions</h3>
						

	 	<%
	 	def header = uicomponent.getHeader();
	 	def rssLink = uicomponent.getRssLink();
	 	def isShowRssLink = uicomponent.isShowRssLink();
	 	def isShowHeader = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_HEADER) && header != null && header.trim().length() != 0;
	 	%>

	 	<%

	 	if (uicomponent.getUIPageIterator().getAvailable() == 0) {
	 		%>
	 		<div  >
	 		<span><%= _ctx.appRes(uicomponent.getParent().getMessageKey()) %></span>
	 		</div>
	 		<%
	 	} else {
	 		%>
	 		<div class="row">
	 		 
	 		 <ul class="list-2">
	 		<%
	 		def currentPageData = uicomponent.getCurrentPageData();
	 		for (def i = 0; i < currentPageData.size(); i++) {

	 			def viewNode = currentPageData.get(i);
	 			if(!Utils.isViewable(viewNode)) continue;
	 			def isShowTitle = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_TITLE);
	 			def isShowDate = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_DATE_CREATED);
	 			def isShowLink = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_LINK);
	 			def isShowReadmore = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_READMORE);

	 			def itemLink = uicomponent.getURL(viewNode);
	 			def itemDateCreated = uicomponent.getCreatedDate(viewNode);
	 			def itemOwner = uicomponent.getAuthor(viewNode);

	 			def imgSrc = uicomponent.getIllustrativeImage(viewNode);
	 			def isShowImage = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_ILLUSTRATION) && imgSrc != null;

	 			def itemName = viewNode.getName();
	 			def itemTitle = uicomponent.getTitle(viewNode);
	 			if (itemTitle != null && itemTitle.trim().length() != 0)
	 				itemName = itemTitle;

	 			def itemSummary = uicomponent.getSummary(viewNode);
	 			def itemSummaryField = uicomponent.getSummaryField(viewNode);
	 			def isShowSummary = uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_SUMMARY) && itemSummary != null;

	 			repo = ((ManageableRepository)viewNode.getSession().getRepository()).getConfiguration().getName();
	 			workspace = viewNode.getSession().getWorkspace().getName();
	 			uuid = viewNode.getUUID();

	 			%><%=uicomponent.addQuickEditDiv("Column3 grid_6", viewNode)%><%
       
        if (uicomponent.isViewMode()){

        }
        else {
          if (isShowTitle) {
            if (isShowLink) {
              %><div class="heading WCMInlineEditable" contenteditable="true" propertyName="<%=propertyName%>" repo="<%=repo%>" workspace="<%=workspace%>" uuid="<%=uuid%>" siteName="<%=siteName%>" language="<%=language%>" publishedmsg="<%=publishedMsg%>" draftmsg="<%=draftMsg%>" fastpublishlink="<%=uicomponent.getFastPublicLink(viewNode)%>"><a href="$itemLink" rel="tooltip" data-placement="bottom" title="$itemName">$itemName</a></div><%
            } else {
              %>
              <div class="heading WCMInlineEditable" contenteditable="true" propertyName="<%=propertyName%>" repo="<%=repo%>" workspace="<%=workspace%>" uuid="<%=uuid%>" siteName="<%=siteName%>" language="<%=language%>" publishedmsg="<%=publishedMsg%>" draftmsg="<%=draftMsg%>" fastpublishlink="<%=uicomponent.getFastPublicLink(viewNode)%>">
              <% print uicomponent.getInlineEditingField(viewNode, "exo:title", itemName, "TEXT", "CLVTitle_"+String.valueOf(i), "GroovyCLVTitle", true, "button_direction=left-to-right","fast_publish=" + uicomponent.getFastPublicLink(viewNode)); %>
              </div>
              <%
            }
          }
        }
	 			if (isShowSummary) {
	 				
	 				if (itemSummaryField!=null) {
	 					print uicomponent.getInlineEditingField(viewNode, itemSummaryField, itemSummary, "TEXTAREA", "Text_"+String.valueOf(i), "CLV2ColSummary", true, "height=80px","fast_publish=" + uicomponent.getFastPublicLink(viewNode));
	 				}
	 				
	 			}
	 			%></div><%
	 		}
	 		%>
	 		
	 		
	 		
</div>
	 		</ul>
	 		<%if (uicomponent.showPaginator()) { %>
	 			<div class="paginatorDefault" >
	 			<%		uicomponent.renderChild(UICustomizeablePaginator.class) %>
	 			</div>
	 			<%
	 		}
	 		%>

	 		<%
	 	}
	 	%>
	 	
	 	</div>
	 	</section>
	 	</div>