Search in sources :

Example 21 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class SearchResultIteratorTag method nextResult.

private int nextResult() {
    if (m_iterator != null && m_iterator.hasNext() && m_count++ < m_maxItems) {
        SearchResult r = (SearchResult) m_iterator.next();
        // Create a wiki context for the result
        WikiEngine engine = m_wikiContext.getEngine();
        HttpServletRequest request = m_wikiContext.getHttpRequest();
        Command command = PageCommand.VIEW.targetedCommand(r.getPage());
        WikiContext context = new WikiContext(engine, request, command);
        // Stash it in the page context
        pageContext.setAttribute(WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
        pageContext.setAttribute(getId(), r);
        return EVAL_BODY_BUFFERED;
    }
    return SKIP_BODY;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WikiContext(org.apache.wiki.WikiContext) Command(org.apache.wiki.ui.Command) PageCommand(org.apache.wiki.ui.PageCommand) SearchResult(org.apache.wiki.search.SearchResult) WikiEngine(org.apache.wiki.WikiEngine)

Example 22 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class NoSuchPageTag method doWikiStartTag.

public int doWikiStartTag() throws IOException, ProviderException {
    WikiEngine engine = m_wikiContext.getEngine();
    WikiPage page;
    if (m_pageName == null) {
        page = m_wikiContext.getPage();
    } else {
        page = engine.getPage(m_pageName);
    }
    if (page != null && engine.pageExists(page.getName(), page.getVersion())) {
        return SKIP_BODY;
    }
    return EVAL_BODY_INCLUDE;
}
Also used : WikiPage(org.apache.wiki.WikiPage) WikiEngine(org.apache.wiki.WikiEngine)

Example 23 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class PageInfoLinkTag method doWikiStartTag.

public final int doWikiStartTag() throws IOException {
    WikiEngine engine = m_wikiContext.getEngine();
    String pageName = m_pageName;
    if (m_pageName == null) {
        WikiPage p = m_wikiContext.getPage();
        if (p != null) {
            pageName = p.getName();
        } else {
            return SKIP_BODY;
        }
    }
    if (engine.pageExists(pageName)) {
        JspWriter out = pageContext.getOut();
        String url = m_wikiContext.getURL(WikiContext.INFO, pageName);
        switch(m_format) {
            case ANCHOR:
                out.print("<a class=\"pageinfo\" href=\"" + url + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
                break;
            case URL:
                out.print(url);
                break;
        }
        return EVAL_BODY_INCLUDE;
    }
    return SKIP_BODY;
}
Also used : WikiPage(org.apache.wiki.WikiPage) JspWriter(javax.servlet.jsp.JspWriter) WikiEngine(org.apache.wiki.WikiEngine)

Example 24 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class PageNameTag method doWikiStartTag.

public final int doWikiStartTag() throws IOException {
    WikiEngine engine = m_wikiContext.getEngine();
    WikiPage page = m_wikiContext.getPage();
    if (page != null) {
        if (page instanceof Attachment) {
            pageContext.getOut().print(((Attachment) page).getFileName());
        } else {
            pageContext.getOut().print(engine.beautifyTitle(m_wikiContext.getName()));
        }
    }
    return SKIP_BODY;
}
Also used : WikiPage(org.apache.wiki.WikiPage) Attachment(org.apache.wiki.attachment.Attachment) WikiEngine(org.apache.wiki.WikiEngine)

Example 25 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class PageSizeTag method doWikiStartTag.

public final int doWikiStartTag() throws IOException {
    WikiEngine engine = m_wikiContext.getEngine();
    WikiPage page = m_wikiContext.getPage();
    try {
        if (page != null) {
            long size = page.getSize();
            if (// should never happen with attachments
            size == -1 && engine.pageExists(page)) {
                size = engine.getPureText(page.getName(), page.getVersion()).length();
                page.setSize(size);
            }
            pageContext.getOut().write(Long.toString(size));
        }
    } catch (ProviderException e) {
        log.warn("Providers did not work: ", e);
        pageContext.getOut().write("Error determining page size: " + e.getMessage());
    }
    return SKIP_BODY;
}
Also used : ProviderException(org.apache.wiki.api.exceptions.ProviderException) WikiPage(org.apache.wiki.WikiPage) WikiEngine(org.apache.wiki.WikiEngine)

Aggregations

WikiEngine (org.apache.wiki.WikiEngine)67 WikiPage (org.apache.wiki.WikiPage)29 ProviderException (org.apache.wiki.api.exceptions.ProviderException)15 Attachment (org.apache.wiki.attachment.Attachment)10 WikiContext (org.apache.wiki.WikiContext)9 Properties (java.util.Properties)8 JspWriter (javax.servlet.jsp.JspWriter)8 TestEngine (org.apache.wiki.TestEngine)8 Element (org.jdom2.Element)7 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Calendar (java.util.Calendar)5 Date (java.util.Date)5 ResourceBundle (java.util.ResourceBundle)5 PluginException (org.apache.wiki.api.exceptions.PluginException)5 Before (org.junit.Before)5 Principal (java.security.Principal)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 InternalWikiException (org.apache.wiki.InternalWikiException)4 ArrayList (java.util.ArrayList)3