<%
  import java.util.Locale;
  import java.text.DateFormat;
  import org.exoplatform.portal.webui.util.Util;
  import org.exoplatform.wiki.webui.UIWikiPortlet;
  import org.exoplatform.wiki.commons.Utils;
  import org.exoplatform.container.ExoContainerContext;
  import org.apache.commons.lang.StringEscapeUtils;

  Locale currentLocale = Util.getPortalRequestContext().getLocale();
  DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, currentLocale);
  
  currentWikiPage = uicomponent.getCurrentWikiPage();

  String creator = StringEscapeUtils.escapeHtml(Utils.getFullName(currentWikiPage.getOwner()));
  String author = StringEscapeUtils.escapeHtml(Utils.getFullName(currentWikiPage.getAuthor()));
  def createdDate = df.format(currentWikiPage.getCreatedDate());
  def updatedDate = df.format(currentWikiPage.getUpdatedDate());

  int attachmentsTotal =  uicomponent.getNumberOfAttachments(currentWikiPage);
  int versionsTotal = uicomponent.getNumberOfVersions(currentWikiPage) ;

  String viewChangeSufix = "_changes";
  String viewChangeAnchor = "#" + uicomponent.COMPARE_REVISION +viewChangeSufix;
  
  String viewChangeActionId = UIWikiPortlet.WIKI_PORTLET_ACTION_PREFIX + uicomponent.COMPARE_REVISION + viewChangeSufix;
  String togglelink= uicomponent.event(uicomponent.TOGGLE_ATTACHMENTS_ACTION);
  String showRevision = uicomponent.event(uicomponent.SHOW_REVISION);
  
  String addedByLabel = _ctx.appRes("UIWikiPageInfoArea.label.AddedBy").replace("{0}", "<a>" + creator + "</a>").replace("{1}", createdDate);
  String lastModifiedByLabel = _ctx.appRes("UIWikiPageInfoArea.label.LastModifiedBy").replace("{0}", "<a>" + author + "</a>").replace("{1}", updatedDate);

  String totalAttachmentsLabel = attachmentsTotal;
  String restrictLinkTitle = _ctx.appRes("UIWikiPageInfoArea.label.restrict-link");
  String publicLinkTitle = _ctx.appRes("UIWikiPageInfoArea.label.public-link");

  boolean isCurrentPagePublic = uicomponent.isPagePublic(currentWikiPage);
%>
<div id="$uicomponent.id" class="uiWikiPageInfoArea">
  <div class="txtFeed">
    <span class="label"><a href="javascript:void(0);" onclick="$showRevision"><%=_ctx.appRes("UIWikiPageInfoArea.label.version-short"); %>$versionsTotal</a></span>&nbsp;
	${addedByLabel}&nbsp;-&nbsp;$lastModifiedByLabel
	<!-- View change -->
	<% if (versionsTotal>1) { %>
	  <a href="javascript:eXo.wiki.UIWikiAjaxRequest.makeNewHash('$viewChangeAnchor');"><%= "(" + _ctx.appRes("UIWikiPageInfoArea.label.ViewChange") + ")"; %></a>
	  <a onclick="<%=uicomponent.event(uicomponent.COMPARE_REVISION);%>" id="$viewChangeActionId" style="display:none;">&nbsp;</a>
	<% }%>
	  
    &nbsp;-&nbsp;
    <!-- Restrict or public -->
    <% if (isCurrentPagePublic) { %>
      <a style="white-space:nowrap" rel="tooltip" data-placement="bottom" title="$publicLinkTitle" href="javascript:void(0);" onclick="<%=uicomponent.event(uicomponent.PERMALINK_ACTION);%>"><i class='uiIconUnlockMini uiIconLightGray'></i>&nbsp;<%=_ctx.appRes("UIWikiPageInfoArea.label.Public")%></a>
    <% } else { %>
      <a style="white-space:nowrap" rel="tooltip" data-placement="bottom" title="$restrictLinkTitle" href="javascript:void(0);" onclick="<%=uicomponent.event(uicomponent.PERMALINK_ACTION);%>"><i class='uiIconLockMini uiIconLightGray'></i>&nbsp;<%=_ctx.appRes("UIWikiPageInfoArea.label.Restrict")%></a>
    <% }%>
    &nbsp;-&nbsp;	  
    <a href="javascript:void(0);" onclick="$togglelink"><i class='uiIconAttach'></i>&nbsp;<%= totalAttachmentsLabel %></a>  
	</div>
</div>
