<% 
	import javax.jcr.Node;
	import org.exoplatform.wcm.webui.paginator.UICustomizeablePaginator;
	import org.exoplatform.wcm.webui.pclv.UIPCLVPortlet;
	import org.exoplatform.wcm.webui.pclv.UIPCLVForm;
	import org.exoplatform.wcm.webui.Utils;
%>
<div class="UIPCLVDefault">
 	<%
	 	uiform.begin();
		def header = uicomponent.getHeader();
		def rssLink = uicomponent.getRssLink();
		def isShowHeader = uicomponent.isShowHeader() && header != null && header.trim().length() != 0;
		def isShowRSSLink = uicomponent.isShowField(UIPCLVPortlet.SHOW_RSS_LINK);
		if (isShowHeader) {
			%>
				<div class="TopBoxParameterized">
					<div class="Title">
						<div class="Header"><%=header%></div>
						<%
						if (isShowRSSLink) {
							%><a class="RssIcon" onclick="javascript:window.open('$rssLink');" style="cursor:pointer">RSS Feed</a><%
						}
						%>
					</div>
					
				</div>
			<%
		}
		%>
			<div class="CaptionItem">
				<% 
					if (uicomponent.getUIPageIterator().getAvailable() == 0) {
						%>
							<div style="height: 20px; text-align: center; font-size: 13px; background: white; padding: 10px; margin: 5px;">
								<%= _ctx.appRes("UIPCLVConfig.label.content-not-found") %>
							</div>
						<%
					} else {
						def count = 0;
						def i = 0;
						def currentPageData = uicomponent.getCurrentPageData();
						for (viewNode in currentPageData) {
							if(!Utils.isViewable(viewNode)) continue;
							i++;
						  	def itemName = viewNode.getName();
						  	def itemLink = uicomponent.generateLink(viewNode);
							def itemSummary = uicomponent.getSummary(viewNode);
							def itemSummaryField = uicomponent.getSummaryField(viewNode);
						    def itemTitle = uicomponent.getTitle(viewNode);
							def itemDateCreated = uicomponent.getCreatedDate(viewNode);
							def imgSrc = uicomponent.getIllustrativeImage(viewNode);
							
							def isShowTitle = uicomponent.isShowField(UIPCLVPortlet.SHOW_TITLE);
							def isShowSumary = uicomponent.isShowField(UIPCLVPortlet.SHOW_SUMMARY);
							def isShowIllustrationImg = uicomponent.isShowField(UIPCLVPortlet.SHOW_THUMBNAILS_VIEW);
							def isShowLink = uicomponent.isShowField(UIPCLVPortlet.SHOW_LINK);
							def isShowCreatedDate = uicomponent.isShowField(UIPCLVPortlet.SHOW_DATE_CREATED) && itemDateCreated != null;
							def isShowReadmore = uicomponent.isShowField(UIPCLVPortlet.SHOW_READMORE);
							if (itemSummary == null) itemSummary = "";
							if (imgSrc == null) 
							  imgSrc = "/eXoWCMResources/skin/DefaultSkin/content-list-viewer-portlet/list-contents/UIContentListPresentationDefault/background/IIlustrationImages.jpg";
							if (itemTitle != null && itemTitle.trim().length() != 0)
								itemName = itemTitle;
							%>
								<div style="padding: 10px 20px;">
									<% 
										if(count == 0) { 
											%>
												<div class="HotNews">
												<div class="ClearFix">
													<%
														if (isShowIllustrationImg) {
															%><a class="ImageHotNews" href="<%=itemLink%>"><img width="248" alt="<%=imgSrc%>" src="<%=imgSrc%>" /></a><%
														} 
													%>
													<div class="ContentHotNews">
														<% 
															if (isShowTitle) {
																if (isShowLink) {
																	%><a class="TitleContentHotNews" href="<%=itemLink%>"><%=itemName%></a><%
																} else {
																	%><%=itemName%><%
																} 
															}
														
															if (isShowSumary) {
																%><div>
																<% 
                                  if (itemSummary != null && itemSummary.trim().length() != 0 && uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_SUMMARY)) {
                                      if (itemSummaryField!=null) {
                                        print uicomponent.getInlineEditingField(viewNode, itemSummaryField, itemSummary, "TEXTAREA", "Text_"+String.valueOf(i), "CLV1ColumnPresent", true);
                                      }
                                  } 
                                %>
                                </div><%
															} 
													
															if (isShowCreatedDate) {
																%><div style="color: red;"><%=itemDateCreated%></div><%
															}
														%>
													</div>
													</div>
													<% if (isShowReadmore) { %>
												  		<div class="ReadLink"><a href="<%=itemLink%>"><%= _ctx.appRes("UIPCLVConfig.label.readmore") %></a></div><%
													}%>
												</div>
											<%
											count = 1;
										} else {
											%>
												<div class="NormalNews ClearFix">
													<% 
														if (isShowIllustrationImg) {
															%><a class="ImageNormalNews" href="<%=itemLink%>"><img width="190" alt="<%=imgSrc%>" src="<%=imgSrc%>" /></a><%
														} 
													%>
													<div class="ContentNormalNews">
														<% 
															if (isShowTitle) {
																%>
																	<div style="font-size: 12px;">
																		<%
																			if (isShowLink) {
																				%><a class="TitleContentNormalNews" href="<%=itemLink%>"><%=itemName%></a><%
																			} else {
  																			print uicomponent.getInlineEditingField(viewNode, "exo:title", itemName, "TEXT", "CLVTitle_"+String.valueOf(i), "GroovyCLVTitle", true, "button_direction=left-to-right");
																			} 
																		%>
																	</div>
																<%
															}
														
															if (isShowSumary) {
																%><div>
																<% 
                                  if (itemSummary != null && itemSummary.trim().length() != 0 && uicomponent.isShowField(UICLVPortlet.PREFERENCE_SHOW_SUMMARY)) {
                                      if (itemSummaryField!=null) {
                                        print uicomponent.getInlineEditingField(viewNode, itemSummaryField, itemSummary, "TEXTAREA", "Text_"+String.valueOf(i), "CLV1ColumnPresent", true);
                                      }
                                  } 
                                %>
                                </div><%
															} 
															
															if (isShowCreatedDate) {
																%><div style="color: red;"><%=itemDateCreated%></div><%
															} 
														%>
													</div>
													
												</div>
												<% if (isShowReadmore) { %>
												  		<div class="ReadLink"><a href="<%=itemLink%>"><%= _ctx.appRes("UIPCLVConfig.label.readmore") %></a></div><%
													}%>
												<div class="LineNormalNews"><span></span></div>
											<%
										} // End is else
									%>
								</div>
							<%
						} // End for loop
					} // End if
				%>
				<div class="CaptionFunc ClearFix">
					<% 
						if (uicomponent.showRefreshButton()) {
							%>				
								<div class="CaptionRefresh">
									<a href="<%=uicomponent.event("Refresh")%>"><%= _ctx.appRes("UIPCLVConfig.action.refresh") %></a>
								</div>
							<% 
						}
						if (uicomponent.showPaginator()) { 
							uicomponent.renderChild(UICustomizeablePaginator.class)
						} 
					%>
					
				</div>
				</div>
			<%
		uiform.end()
	%>
</div>
