use of org.apache.wiki.api.core.Engine in project jspwiki by apache.
the class EditLinkTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
Page page = null;
String versionString = "";
final String pageName;
// Determine the page and the link.
if (m_pageName == null) {
page = m_wikiContext.getPage();
if (page == null) {
// You can't call this on the page itself anyways.
return SKIP_BODY;
}
pageName = page.getName();
} else {
pageName = m_pageName;
}
//
if (m_version != null) {
if ("this".equalsIgnoreCase(m_version)) {
if (page == null) {
// No page, so go fetch according to page name.
page = engine.getManager(PageManager.class).getPage(m_pageName);
}
if (page != null) {
versionString = "version=" + page.getVersion();
}
} else {
versionString = "version=" + m_version;
}
}
//
// Finally, print out the correct link, according to what user commanded.
//
final JspWriter out = pageContext.getOut();
switch(m_format) {
case ANCHOR:
out.print("<a href=\"" + m_wikiContext.getURL(ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString) + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(m_wikiContext.getURL(ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString));
break;
}
return EVAL_BODY_INCLUDE;
}
use of org.apache.wiki.api.core.Engine in project jspwiki by apache.
the class FeedDiscoveryTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
final Page page = m_wikiContext.getPage();
final String encodedName = engine.encodeName(page.getName());
final String rssURL = engine.getGlobalRSSURL();
final String rssFeedURL = engine.getURL(ContextEnum.PAGE_NONE.getRequestContext(), "rss.jsp", "page=" + encodedName + "&mode=wiki");
if (rssURL != null) {
String siteName = Feed.getSiteName(m_wikiContext);
siteName = TextUtil.replaceEntities(siteName);
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS wiki feed for the entire site.\" href=\"" + rssURL + "\" />\n");
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS wiki feed for page " + siteName + ".\" href=\"" + rssFeedURL + "\" />\n");
// FIXME: This does not work always, as plugins are not initialized until the first fetch
if ("true".equals(page.getAttribute(WeblogPlugin.ATTR_ISWEBLOG))) {
final String blogFeedURL = engine.getURL(ContextEnum.PAGE_NONE.getRequestContext(), "rss.jsp", "page=" + encodedName);
final String atomFeedURL = engine.getURL(ContextEnum.PAGE_NONE.getRequestContext(), "rss.jsp", "page=" + encodedName + "&type=atom");
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed for weblog " + siteName + ".\" href=\"" + blogFeedURL + "\" />\n");
pageContext.getOut().print("<link rel=\"service.feed\" type=\"application/atom+xml\" title=\"Atom 1.0 weblog feed for " + siteName + "\" href=\"" + atomFeedURL + "\" />\n");
}
}
return SKIP_BODY;
}
use of org.apache.wiki.api.core.Engine in project jspwiki by apache.
the class InsertPageTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException, ProviderException {
final Engine engine = m_wikiContext.getEngine();
final Page insertedPage;
if (m_pageName == null) {
insertedPage = m_wikiContext.getPage();
if (!engine.getManager(PageManager.class).wikiPageExists(insertedPage))
return SKIP_BODY;
} else {
insertedPage = engine.getManager(PageManager.class).getPage(m_pageName);
}
if (insertedPage != null) {
// FIXME: Do version setting later.
// page.setVersion( WikiProvider.LATEST_VERSION );
log.debug("Inserting page " + insertedPage);
final JspWriter out = pageContext.getOut();
final Page oldPage = m_wikiContext.setRealPage(insertedPage);
switch(m_mode) {
case HTML:
out.print(engine.getManager(RenderingManager.class).getHTML(m_wikiContext, insertedPage));
break;
case PLAIN:
out.print(engine.getManager(PageManager.class).getText(insertedPage));
break;
}
m_wikiContext.setRealPage(oldPage);
}
return SKIP_BODY;
}
use of org.apache.wiki.api.core.Engine in project jspwiki by apache.
the class LinkTag method doEndTag.
@Override
public int doEndTag() {
try {
final Engine engine = m_wikiContext.getEngine();
final JspWriter out = pageContext.getOut();
final String url = figureOutURL();
final StringBuilder sb = new StringBuilder(20);
sb.append((m_cssClass != null) ? "class=\"" + m_cssClass + "\" " : "");
sb.append((m_style != null) ? "style=\"" + m_style + "\" " : "");
sb.append((m_target != null) ? "target=\"" + m_target + "\" " : "");
sb.append((m_title != null) ? "title=\"" + m_title + "\" " : "");
sb.append((m_rel != null) ? "rel=\"" + m_rel + "\" " : "");
sb.append((m_accesskey != null) ? "accesskey=\"" + m_accesskey + "\" " : "");
sb.append((m_tabindex != null) ? "tabindex=\"" + m_tabindex + "\" " : "");
if (engine.getManager(PageManager.class).getPage(m_pageName) instanceof Attachment) {
sb.append(engine.getManager(AttachmentManager.class).forceDownload(m_pageName) ? "download " : "");
}
switch(m_format) {
case URL:
out.print(url);
break;
default:
case ANCHOR:
out.print("<a " + sb + " href=\"" + url + "\">");
break;
}
// Add any explicit body content. This is not the intended use of LinkTag, but happens to be the way it has worked previously.
if (m_bodyContent != null) {
final String linktext = m_bodyContent.getString().trim();
out.write(linktext);
}
// Finish off by closing opened anchor
if (m_format == ANCHOR)
out.print("</a>");
} catch (final Exception e) {
// Yes, we want to catch all exceptions here, including RuntimeExceptions
log.error("Tag failed", e);
}
return EVAL_PAGE;
}
use of org.apache.wiki.api.core.Engine in project jspwiki by apache.
the class CheckLockTag method doWikiStartTag.
/**
* {@inheritDoc}
*/
@Override
public final int doWikiStartTag() throws IOException, ProviderException {
final Engine engine = m_wikiContext.getEngine();
final Page page = m_wikiContext.getPage();
if (page != null) {
final PageManager mgr = engine.getManager(PageManager.class);
final PageLock lock = mgr.getCurrentLock(page);
final HttpSession session = pageContext.getSession();
final PageLock userLock = (PageLock) session.getAttribute("lock-" + page.getName());
if ((lock != null && m_mode == LockState.LOCKED && lock != userLock) || (lock != null && m_mode == LockState.OWNED && lock == userLock) || (lock == null && m_mode == LockState.NOTLOCKED)) {
final String tid = getId();
if (tid != null && lock != null) {
pageContext.setAttribute(tid, lock);
}
return EVAL_BODY_INCLUDE;
}
}
return SKIP_BODY;
}
Aggregations