use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class EditLinkTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = null;
String versionString = "";
String pageName = null;
//
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.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.
//
JspWriter out = pageContext.getOut();
switch(m_format) {
case ANCHOR:
out.print("<a href=\"" + m_wikiContext.getURL(WikiContext.EDIT, pageName, versionString) + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(m_wikiContext.getURL(WikiContext.EDIT, pageName, versionString));
break;
}
return EVAL_BODY_INCLUDE;
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class FeedDiscoveryTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = m_wikiContext.getPage();
String encodedName = engine.encodeName(page.getName());
String rssURL = engine.getGlobalRSSURL();
String rssFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName + "&mode=wiki", true);
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))) {
String blogFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName, true);
String atomFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName + "&type=atom", true);
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.WikiPage in project jspwiki by apache.
the class HistoryIteratorTag method doStartTag.
public final int doStartTag() {
m_wikiContext = (WikiContext) pageContext.getAttribute(WikiTagBase.ATTR_CONTEXT, PageContext.REQUEST_SCOPE);
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page;
page = m_wikiContext.getPage();
try {
if (page != null && engine.pageExists(page)) {
Collection versions = engine.getVersionHistory(page.getName());
if (versions == null) {
// There is no history
return SKIP_BODY;
}
m_iterator = versions.iterator();
if (m_iterator.hasNext()) {
WikiContext context = (WikiContext) m_wikiContext.clone();
context.setPage((WikiPage) m_iterator.next());
pageContext.setAttribute(WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
pageContext.setAttribute(getId(), context.getPage());
} else {
return SKIP_BODY;
}
}
return EVAL_BODY_BUFFERED;
} catch (ProviderException e) {
log.fatal("Provider failed while trying to iterator through history", e);
// FIXME: THrow something.
}
return SKIP_BODY;
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class InsertPageTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException, ProviderException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage insertedPage;
if (m_pageName == null) {
insertedPage = m_wikiContext.getPage();
if (!engine.pageExists(insertedPage))
return SKIP_BODY;
} else {
insertedPage = engine.getPage(m_pageName);
}
if (insertedPage != null) {
// FIXME: Do version setting later.
// page.setVersion( WikiProvider.LATEST_VERSION );
log.debug("Inserting page " + insertedPage);
JspWriter out = pageContext.getOut();
WikiPage oldPage = m_wikiContext.setRealPage(insertedPage);
switch(m_mode) {
case HTML:
out.print(engine.getHTML(m_wikiContext, insertedPage));
break;
case PLAIN:
out.print(engine.getText(m_wikiContext, insertedPage));
break;
}
m_wikiContext.setRealPage(oldPage);
}
return SKIP_BODY;
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class IteratorTag method buildContext.
/**
* Arg, I hate globals.
*/
private void buildContext() {
//
// Build a clone of the current context
//
WikiContext context = (WikiContext) m_wikiContext.clone();
Object o = m_iterator.next();
if (o instanceof WikiPage)
context.setPage((WikiPage) o);
//
// Push it to the iterator stack, and set the id.
//
pageContext.setAttribute(WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
pageContext.setAttribute(getId(), o);
}
Aggregations