<%
import org.exoplatform.wiki.mow.api.Page;
import org.exoplatform.wiki.utils.Utils;
import org.exoplatform.wiki.service.WikiPageParams;
import org.exoplatform.wiki.commons.DateTimeFomatter;

  def requireJs = _ctx.getRequestContext().getJavascriptManager().getRequireJS();
  requireJs.require("SHARED/UIWikiPageNotFound", "UIWikiPageNotFound");
  requireJs.addScripts("UIWikiPageNotFound.init();");  
%>
<div class="uiWikiPageNotFound">
	<span class="errorBlock"></span>
	
	<h3><%=_ctx.appRes("UIWikiPageNotFound.label.PageNotFound")%></h3>
		<p class="titleWarning"><%=_ctx.appRes("UIWikiPageNotFound.label.NotFound.FirstMsg.part1")%></p>
			<div class="pageContent">
<%
	  WikiPageParams currentParam =  org.exoplatform.wiki.commons.Utils.getCurrentWikiPageParams();	  
	  String currentHomeUrl = uicomponent.getHomeURL(currentParam);	  
		Page relatedPage = uicomponent.getRelatedPage() ;	
		
		if(relatedPage != null) {
			WikiPageParams param = Utils.getWikiPageParams(relatedPage);
			String relatedLocation = relatedPage.getWikiType() +" : " +relatedPage.getWikiOwner();
			String content = relatedPage.getContent();
			String summaryContent =  (content.length() >100) ? content.substring(0,100) + " ..." : content ;
			String url = org.exoplatform.wiki.commons.Utils.getURLFromParams(param);
			String updateDate =  DateTimeFomatter.getLongFormatted(relatedPage.getUpdatedDate());
			String homeUrl = uicomponent.getHomeURL(param);
			String msg1 = _ctx.appRes("UIWikiPageNotFound.label.NotFound.FirstMsg.part3");
			msg1 = msg1.replace("{0}", "<strong>");
			msg1 = msg1.replace("{1}", "</strong>");
		%>
			
				<p><%=_ctx.appRes("UIWikiPageNotFound.label.NotFound.FirstMsg.part2")%></br>
				$msg1
				</p>
				<div class="blockResultFeed">
				  <a href="$url"><i class="uiIconFileMini uiIconLightGray"></i><%=relatedPage.getTitle()%></a>
					<div class="txtDetail"><%=summaryContent%></div>
					<a href="$homeUrl" class="txtMark"><%=relatedLocation %></a><span> <%=_ctx.appRes("UIWikiPageNotFound.label.NotFound.FirstMsg.part4")%> <%= updateDate %></span>
				</div>
			
  	<%
		} else {
			%>
			<ul>
				<li><%=_ctx.appRes("UIWikiPageNotFound.label.NotFound.SecondMsg.part1")%></li>
				<li><%=_ctx.appRes("UIWikiPageNotFound.label.NotFound.SecondMsg.part2")%></li>
			</ul>		
			<%	
		}
	%>
		<%
			String msg2 = _ctx.appRes("UIWikiPageNotFound.label.NotFound.SecondMsg.part3");
			msg2 = msg2.replace("{0}", "<a href=\"$currentHomeUrl\" class=\"backHome\">");
			msg2 = msg2.replace("{1}", "</a>");
		%>
		<p>$msg2</p>
		
	</div>
</div>
