Search in sources :

Example 1 with WikiEngine

use of com.ecyrd.jspwiki.WikiEngine in project jforum2 by rafaelsteil.

the class TrailTag method doWikiStartTag.

/**
	 * @see com.ecyrd.jspwiki.tags.WikiTagBase#doWikiStartTag()
	 */
public final int doWikiStartTag() throws IOException {
    HttpSession session = pageContext.getSession();
    FixedQueue trail = (FixedQueue) session.getAttribute(BREADCRUMBTRAIL_KEY);
    String page = m_wikiContext.getPage().getName();
    if (trail == null) {
        trail = new FixedQueue(maxPages);
    }
    if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW)) {
        if (trail.isEmpty()) {
            trail.push(page);
        } else {
            // Don't add the page to the queue if the page was just refreshed
            if (!((String) trail.getLast()).equals(page)) {
                if (trailType.equalsIgnoreCase("visit")) {
                    if (!trail.contains(page)) {
                        trail.push(page);
                    }
                } else {
                    trail.push(page);
                }
            }
        }
    }
    // our trail
    session.setAttribute(BREADCRUMBTRAIL_KEY, trail);
    JspWriter out = pageContext.getOut();
    int queueSize = trail.size();
    String linkClass = "wikipage";
    WikiEngine engine = m_wikiContext.getEngine();
    int i = 0;
    for (Iterator iter = trail.iterator(); iter.hasNext(); i++) {
        String currentPage = (String) iter.next();
        StringBuffer sb = new StringBuffer(128).append("<a class='").append(linkClass).append("' href='").append(engine.getViewURL(currentPage)).append("'>");
        if (currentPage == page) {
            sb.append("<b>").append(currentPage).append("</b>");
        } else {
            sb.append(currentPage);
        }
        sb.append("</a>");
        out.print(sb.toString());
        if (i + 1 < queueSize) {
            out.print(trailSeparator);
        }
    }
    return SKIP_BODY;
}
Also used : HttpSession(javax.servlet.http.HttpSession) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter) WikiEngine(com.ecyrd.jspwiki.WikiEngine)

Aggregations

WikiEngine (com.ecyrd.jspwiki.WikiEngine)1 Iterator (java.util.Iterator)1 HttpSession (javax.servlet.http.HttpSession)1 JspWriter (javax.servlet.jsp.JspWriter)1