<%
  import java.util.List;
  import org.exoplatform.commons.utils.HTMLSanitizer;
  
  def rcontext = _ctx.getRequestContext() ;
  List breadCumbs = uicomponent.getBreadCumbs();  
  def requireJs = rcontext.getJavascriptManager().getRequireJS();
  requireJs.require("SHARED/UIWikiPortlet", "UIWikiPortlet"); 
  requireJs.addScripts("UIWikiPortlet.renderBreadcrumbs(\"" + uicomponent.id + "\","+ uicomponent.isLink +");");
%>
<div class="uiWikiBreadCrumb" id="$uicomponent.id">
	
   <ul class="breadcrumb">  
   <% if(breadCumbs!=null && breadCumbs.size() > 0) {

      String note = "LeftBlock"; %>
      <% if (uicomponent.isAllowChooseSpace()) {
        uicomponent.renderChild(uicomponent.SPACE_SWITCHER);
      %>
        <span class="uiIconMiniArrowRight">&nbsp;</span>
      <% } else { %>
        <li>
	      <a>
            <% if (uicomponent.isShowWikiName()) { %>
              <% if (uicomponent.isShowWikiType()) { %>
                <%= uicomponent.getWikiType(); %> : 
              <% } %>
              <%= uicomponent.getWikiName(); %>
            <% } %>
	      </a>
	      
	      <% if (uicomponent.isShowWikiName()) { %>
            <span class="uiIconMiniArrowRight">&nbsp;</span>
          <% } %>
	    </li>
      <% } %>
		
     <% for(i in 0 .. breadCumbs.size()-1) {
	   def liClass = (i == breadCumbs.size()-1) && (uicomponent.getActionLabel()==null || "".equals(uicomponent.getActionLabel()))?"active":"";
	   %>
	   <li class="$liClass">
	   <%
          breadcumbData = breadCumbs.get(i);
          String title = HTMLSanitizer.sanitize(breadcumbData.getTitle());
          if (title.isEmpty()) {
              title = _ctx.appRes("UIWikiPageTitleControlArea.label.Untitled");
          }

          String actionLink = uicomponent.createActionLink(breadcumbData);
          if(uicomponent.isLink && i == breadCumbs.size()-1) note = "Selected";
     %>
       <% if (uicomponent.isLink && !"active".equals(liClass)) {%>
         <a href="<%=(breadcumbData.getId() == null) ? "#" : actionLink%>">$title</a>
       <% } else {%>
         <a >$title</a>
       <% } %>
         <%      
          if(i != breadCumbs.size()-1) {
         %>
             <span class="uiIconMiniArrowRight">&nbsp;</span>
         <%
          }
        } %>
		</li>
		<%
      }
      String actionLabel= uicomponent.getActionLabel();
      if(actionLabel!=null && !actionLabel.equals("")) {  
        String label= _ctx.appRes(actionLabel);        
   %>
         <li class="active"><span class="uiIconMiniArrowRight">&nbsp;</span>$label</li>
         
  <% } %>
  </ul>

  <div class="BreadcumPopup">
    <div class="SubBlock"></div>
  </div>

</div>
