Search in sources :

Example 26 with Engine

use of org.apache.wiki.api.core.Engine in project jspwiki by apache.

the class RSSImageLinkTag method doWikiStartTag.

/**
 *  {@inheritDoc}
 */
@Override
public final int doWikiStartTag() throws IOException {
    final Engine engine = m_wikiContext.getEngine();
    final JspWriter out = pageContext.getOut();
    final ResourceBundle rb = Preferences.getBundle(m_wikiContext, InternationalizationManager.CORE_BUNDLE);
    if (engine.getManager(RSSGenerator.class) != null && engine.getManager(RSSGenerator.class).isEnabled()) {
        if (RSSGenerator.MODE_FULL.equals(m_mode)) {
            final String rssURL = engine.getGlobalRSSURL();
            if (rssURL != null) {
                out.print("<a class=\"feed\" href=\"" + rssURL);
                out.print(" title='" + rb.getString("rss.title.full") + "'>");
                out.print("&nbsp;</a> ");
            }
        } else {
            final String page = m_pageName != null ? m_pageName : m_wikiContext.getPage().getName();
            final String params = "page=" + page + "&mode=" + m_mode;
            out.print("<a href='" + m_wikiContext.getURL(ContextEnum.PAGE_NONE.getRequestContext(), "rss.jsp", params));
            out.print("' class='feed'");
            out.print(" title='" + MessageFormat.format(rb.getString("rss.title"), page) + "'>");
            out.print("&nbsp;</a> ");
        }
    }
    return SKIP_BODY;
}
Also used : ResourceBundle(java.util.ResourceBundle) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 27 with Engine

use of org.apache.wiki.api.core.Engine in project jspwiki by apache.

the class ContentEncodingTag method doWikiStartTag.

/**
 *  {@inheritDoc}
 */
@Override
public final int doWikiStartTag() throws IOException {
    final Engine engine = m_wikiContext.getEngine();
    pageContext.getOut().print(engine.getContentEncoding());
    return SKIP_BODY;
}
Also used : Engine(org.apache.wiki.api.core.Engine)

Example 28 with Engine

use of org.apache.wiki.api.core.Engine in project jspwiki by apache.

the class SearchResultIteratorTag method nextResult.

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

Example 29 with Engine

use of org.apache.wiki.api.core.Engine in project jspwiki by apache.

the class PageNameTag method doWikiStartTag.

@Override
public final int doWikiStartTag() throws IOException {
    final Engine engine = m_wikiContext.getEngine();
    final Page page = m_wikiContext.getPage();
    if (page != null) {
        if (page instanceof Attachment) {
            pageContext.getOut().print(TextUtil.replaceEntities(((Attachment) page).getFileName()));
        } else {
            pageContext.getOut().print(engine.getManager(RenderingManager.class).beautifyTitle(m_wikiContext.getName()));
        }
    }
    return SKIP_BODY;
}
Also used : Page(org.apache.wiki.api.core.Page) Attachment(org.apache.wiki.api.core.Attachment) Engine(org.apache.wiki.api.core.Engine)

Example 30 with Engine

use of org.apache.wiki.api.core.Engine in project jspwiki by apache.

the class WikiAjaxDispatcherServlet method validatePermission.

/**
 * Validate the permission of the {@link WikiAjaxServlet} using the {@link AuthorizationManager#checkPermission}
 *
 * @param req the servlet request
 * @param container the container info of the servlet
 * @return true if permission is valid
 */
private boolean validatePermission(final HttpServletRequest req, final AjaxServletContainer container) {
    final Engine e = Wiki.engine().find(req.getSession().getServletContext(), null);
    boolean valid = false;
    if (container != null) {
        valid = e.getManager(AuthorizationManager.class).checkPermission(Wiki.session().find(e, req), container.permission);
    }
    return valid;
}
Also used : Engine(org.apache.wiki.api.core.Engine)

Aggregations

Engine (org.apache.wiki.api.core.Engine)60 Page (org.apache.wiki.api.core.Page)30 PageManager (org.apache.wiki.pages.PageManager)20 ProviderException (org.apache.wiki.api.exceptions.ProviderException)11 Attachment (org.apache.wiki.api.core.Attachment)10 JspWriter (javax.servlet.jsp.JspWriter)9 Context (org.apache.wiki.api.core.Context)9 AttachmentManager (org.apache.wiki.attachment.AttachmentManager)8 Element (org.jdom2.Element)7 IOException (java.io.IOException)6 Calendar (java.util.Calendar)6 ResourceBundle (java.util.ResourceBundle)6 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 PageContext (javax.servlet.jsp.PageContext)5 Principal (java.security.Principal)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 PluginException (org.apache.wiki.api.exceptions.PluginException)4 RenderingManager (org.apache.wiki.render.RenderingManager)4 ArrayList (java.util.ArrayList)3