use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class CalendarTag method getMonthNaviLink.
private String getMonthNaviLink(Calendar day, String txt, String queryString) {
String result = "";
queryString = TextUtil.replaceEntities(queryString);
Calendar nextMonth = Calendar.getInstance();
nextMonth.set(Calendar.DATE, 1);
nextMonth.add(Calendar.DATE, -1);
// Now move to 1st day of next month
nextMonth.add(Calendar.MONTH, 1);
if (day.before(nextMonth)) {
WikiPage thePage = m_wikiContext.getPage();
String pageName = thePage.getName();
String calendarDate = m_dateFormat.format(day.getTime());
String url = m_wikiContext.getURL(WikiContext.VIEW, pageName, "calendar.date=" + calendarDate);
if ((queryString != null) && (queryString.length() > 0)) {
//
// Ensure that the 'calendar.date=ddMMyy' has been removed
// from the queryString
//
// FIXME: Might be useful to have an entire library of
// routines for this. Will fail if it's not calendar.date
// but something else.
int pos1 = queryString.indexOf("calendar.date=");
if (pos1 >= 0) {
String tmp = queryString.substring(0, pos1);
// FIXME: Will this fail when we use & instead of &?
// FIXME: should use some parsing routine
int pos2 = queryString.indexOf("&", pos1) + 1;
if ((pos2 > 0) && (pos2 < queryString.length())) {
tmp = tmp + queryString.substring(pos2);
}
queryString = tmp;
}
if (queryString != null && queryString.length() > 0) {
url = url + "&" + queryString;
}
}
result = "<td><a href=\"" + url + "\">" + txt + "</a></td>";
} else {
result = "<td> </td>";
}
return format(result);
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class CheckLockTag method doWikiStartTag.
/**
* {@inheritDoc}
*/
@Override
public final int doWikiStartTag() throws IOException, ProviderException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = m_wikiContext.getPage();
if (page != null) {
PageManager mgr = engine.getPageManager();
PageLock lock = mgr.getCurrentLock(page);
HttpSession session = pageContext.getSession();
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)) {
String tid = getId();
if (tid != null && lock != null) {
pageContext.setAttribute(tid, lock);
}
return EVAL_BODY_INCLUDE;
}
}
return SKIP_BODY;
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class LinkToTag method doWikiStartTag.
public int doWikiStartTag() throws IOException {
String pageName = m_pageName;
boolean isattachment = false;
if (m_pageName == null) {
WikiPage p = m_wikiContext.getPage();
if (p != null) {
pageName = p.getName();
isattachment = p instanceof Attachment;
} else {
return SKIP_BODY;
}
}
JspWriter out = pageContext.getOut();
String url;
String linkclass;
if (isattachment) {
url = m_wikiContext.getURL(WikiContext.ATTACH, pageName, (getVersion() != null) ? "version=" + getVersion() : null);
linkclass = "attachment";
} else {
StringBuilder params = new StringBuilder();
if (getVersion() != null)
params.append("version=" + getVersion());
if (getTemplate() != null)
params.append((params.length() > 0 ? "&" : "") + "skin=" + getTemplate());
url = m_wikiContext.getURL(WikiContext.VIEW, pageName, params.toString());
linkclass = "wikipage";
}
switch(m_format) {
case ANCHOR:
out.print("<a class=\"" + linkclass + "\" href=\"" + url + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(url);
break;
}
return EVAL_BODY_INCLUDE;
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class NextVersionTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiPage page = m_wikiContext.getPage();
int version = page.getVersion();
if (version == -1)
version = -1;
else
version++;
pageContext.getOut().print(version);
return SKIP_BODY;
}
use of org.apache.wiki.WikiPage 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;
}
Aggregations