
<%@page import="com.liferay.document.library.kernel.util.PDFProcessorUtil"%>
<%@page import="com.liferay.portal.kernel.dao.search.SearchContainer"%>
<%@ include file="init.jsp" %>

<%
	
	long folderId = assetPublisherDisplayContext.getRootFolder();
	int status = WorkflowConstants.STATUS_APPROVED;
	int max_delta = assetPublisherDisplayContext.getDelta();
	boolean position = assetPublisherDisplayContext.getPosition();
	String css = assetPublisherDisplayContext.getDisplayStyle();
	String styleID = assetPublisherDisplayContext.getStyleID();
	
	OrderByComparator orderByComparator = DLUtil.getRepositoryModelOrderByComparator("modifiedDate", "desc");
	List<FileEntry> fileEntries = DLAppServiceUtil.getGroupFileEntries(scopeGroupId, 0, folderId, currentMimeTypes, status, 0, max_delta, orderByComparator);
	//List<DLFileEntry> dlssss = DLFileEntryLocalServiceUtil.getFileEntries(scopeGroupId, folder.getFolderId(), status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, orderByComparator);
	//System.out.println(fileEntries.size());
%>
<style>
<%= max_delta==1 ? "#"+styleID+" li.lfr-asset-item{width:100%;}" : "" %>
<%= assetPublisherDisplayContext.getCSS() %>

.pdf-column1{
	padding-left: 15px;
	padding-right: 15px;
	padding-bottom: 15px;
}

</style>

<div class="text-justify">
	<ul class="display-style-icon list-unstyled row" id="<%= styleID %>">
	<%
		for(FileEntry fileEntry : fileEntries){
			
			FileVersion fileVersion = DLAppServiceUtil.getFileVersion(fileEntry.getFileVersion().getFileVersionId());
			String thumbnailImage = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, "&videoThumbnail=1");
			if(VideoProcessorUtil.hasVideo(fileVersion)){
				
				String src = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, "&videoPreview=1"+"&type=" + "mp4");
				//String oo = PropsUtil.get(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_CONTAINERS);
	%>
				<li class="lfr-asset-item video" style="<%= fileEntries.size()==1 ? "text-align:center;" : "" %>">
					<video src="<%= src %>" poster="<%= thumbnailImage %>" controls width="<%= assetPublisherDisplayContext.getWidthVideo() %>"></video>
					<div class="cis-text-color" style="white-space: nowrap;"><%= fileEntry.getTitle() %></div>
				</li>
	<%
			}else if(ImageProcessorUtil.hasImages(fileVersion)){
	%>
				<li class="lfr-asset-item">
					<div class="image-link preview" href="<%= DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, "") %>">
						<div class="taglib-vertical-card entry-display-style">
							<div class="clients-item">
								<% if(!assetPublisherDisplayContext.isOneStaticPhoto()){ %>
								<div class="aspect-ratio aspect-ratio-bg-center aspect-ratio-bg-cover" style="background-image: url('<%= DLUtil.getPreviewURL(fileEntry,fileVersion, themeDisplay, "&imageThumbnail=1") %>');cursor: pointer;">
								</div>
								<% }else{ %>
								<img alt="" src="<%= DLUtil.getPreviewURL(fileEntry,fileVersion, themeDisplay, "&imageThumbnail=1") %>">
								<% } %>
							</div>
						</div>
						<div class="cis-text-color"><%= fileEntry.getTitle() %></div>
					</div>
				</li>
				
			
	
	<%
			}else if(PDFProcessorUtil.hasImages(fileVersion)){
				String imageURL = DLUtil.getPreviewURL(fileEntry, fileVersion, themeDisplay, "&previewFileIndex=1");
	%>
				<%-- <div class="image-link preview">
					<%= imageURL %>
				</div> --%>
				<%-- <li class="lfr-asset-item">
					<div class="image-link preview" href="<%= imageURL %>">
						<div class="taglib-vertical-card entry-display-style">
							<div class="clients-item">
								<% if(!assetPublisherDisplayContext.isOneStaticPhoto()){ %>
								<div class="aspect-ratio aspect-ratio-bg-center aspect-ratio-bg-cover" style="background-image: url('<%= imageURL %>');cursor: pointer;"></div>
								<% }else{ %>
								<img alt="" src="<%= imageURL %>">
								<% } %>
							</div>
						</div>
					</div>
				</li> --%>
				<div class="pdf-column1">
					<a href="<%= DLUtil.getDownloadURL(fileEntry, fileVersion, themeDisplay, "") %>">
						<img alt="" src="<%=request.getContextPath()%>/img/pdficon.png"> <span><%= fileEntry.getTitle() %></span>
					</a>
				</div>
	
	<%
			}
		}
	%>
	</ul>
</div>

<%-- <div class="text-justify">
	<%
		DLFolder folder = DLFolderLocalServiceUtil.fetchFolder(scopeGroupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "video");
		if (Validator.isNotNull(folder)){
			List<DLFileEntry> dls = DLFileEntryLocalServiceUtil.getFileEntries(scopeGroupId, folder.getFolderId(), status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, orderByComparator);
			for(DLFileEntry dl : dls){

			}
		}
	%>
<div> --%>





<aui:script use="aui-carousel,aui-image-viewer">

		
		var imageViewer = new A.ImageViewer(
			  {
				caption: '',
				captionFromTitle: true,
				centered: true,
				imageAnim: {
				 duration: 1,
				 easing: 'easeIn'
				},
				intervalTime: 7,
				links: '#<%= styleID %> .image-link.preview',
				playing: true,
				preloadAllImages: true,
				preloadNeighborImages: true,
				showInfo: false,
				showPlayer: true,
				zIndex: 1
			  }
		).render();
	
</aui:script>





