Index: xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg =================================================================== --- xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg (revision 3312) +++ xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg (working copy) @@ -98,3 +98,7 @@ #p2pxwiki.network.server_port=8685 #p2pxwiki.network.connector_factory=com.xpn.p2pxwiki.communication.jxtarpc.JxtaRpcConnectionFactory #p2pxwiki.network.retry_with_default_connector_factory=false + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12 Index: xwiki/application/src/main/resources/xwiki.cfg =================================================================== --- xwiki/application/src/main/resources/xwiki.cfg (revision 3312) +++ xwiki/application/src/main/resources/xwiki.cfg (working copy) @@ -103,3 +103,7 @@ # Enable to allow superadmin. It is disabled by default as this could be a security breach if # it were set and you forgot about it. #xwiki.superadminpassword=system + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12 Index: xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarModel.java =================================================================== --- xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarModel.java (revision 3312) +++ xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarModel.java (working copy) @@ -23,6 +23,7 @@ import java.util.Calendar; import java.util.Date; +import com.xpn.xwiki.XWikiContext; /** * Model interface for the CalendarTag. The CalendarTag will set a day, then use the computeUrl method to get the URLs it needs. @@ -36,11 +37,18 @@ public Date getNextMonth(); + public String computeTodayMonthUrl(); + + //modified 18.05.07 by Danciu Radu JIRA XWIKI-980 + public String computePrevMonthUrl(XWikiContext context); + + public String computeNextMonthUrl(XWikiContext context); + /** + *@deprecated versions without context + */ public String computePrevMonthUrl(); - - public String computeTodayMonthUrl(); - public String computeNextMonthUrl(); + //*** /** * Create URL for use on edit-weblog page, preserves the request parameters used by the tabbed-menu tag for navigation. Index: xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarParams.java =================================================================== --- xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarParams.java (revision 3312) +++ xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarParams.java (working copy) @@ -19,34 +19,40 @@ */ package com.xpn.xwiki.plugin.calendar; +import com.xpn.xwiki.XWikiContext; import java.util.*; -public class CalendarParams { +public class CalendarParams +{ private Map map = new HashMap(); - public CalendarParams() { - } + public CalendarParams() {} - public CalendarParams(Map map) { + public CalendarParams(Map map) + { this.map = map; } - public Object get(Object key) { + public Object get(Object key) + { return map.get(key); } - public void put(Object key, Object value) { + public void put(Object key, Object value) + { map.put(key, value); } - public Calendar getCalendar(Locale locale) { + public Calendar getCalendar(Locale locale) + { Calendar cal = Calendar.getInstance(locale); cal.setTime(new Date()); String smonth = (String) get("month"); cal.set(Calendar.DAY_OF_MONTH, 1); try { - if (smonth != null && !smonth.trim().equals("")) { + if (smonth != null && !smonth.trim().equals("")) + { if (smonth.indexOf("+") != -1) { cal.add(Calendar.MONTH, Integer.parseInt(smonth.substring(1))); } else if (smonth.indexOf("-") != -1) { @@ -65,24 +71,74 @@ cal.set(Calendar.YEAR, Integer.parseInt(syear)); } } - } catch (NumberFormatException ex) { + } catch (NumberFormatException ex) + { } return cal; } - public String computePrevMonthURL() { - Calendar c = this.getCalendar(Locale.getDefault()); - c.add(Calendar.MONTH, -1); - if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { - return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); - } - return "?month=" + c.get(Calendar.MONTH); - } - public String computeNextMonthURL() { - Calendar c = this.getCalendar(Locale.getDefault()); - c.add(Calendar.MONTH, 1); - if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { - return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); - } - return "?month=" + c.get(Calendar.MONTH); - } -} + + public String computePrevMonthURL(XWikiContext context) + { + Calendar c = this.getCalendar(Locale.getDefault()); + + String prevMonthBound; + int prevBound; + if ((prevMonthBound = context.getWiki().Param("xwiki.calendar.bound.prev")) != null) + prevBound = Integer.parseInt (prevMonthBound); + else + prevBound = 6; + + if (Calendar.getInstance().get(Calendar.MONTH) - c.get(Calendar.MONTH) + 12 * (Calendar.getInstance().get(Calendar.YEAR) - c.get(Calendar.YEAR)) < prevBound) { + c.add(Calendar.MONTH, -1); + if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { + return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); + } + return "?month=" + c.get(Calendar.MONTH); + } + return ""; + } + + public String computeNextMonthURL(XWikiContext context) + { + Calendar c = this.getCalendar(Locale.getDefault()); + + String nextMonthBound; + int nextBound; + if ((nextMonthBound = context.getWiki().Param("xwiki.calendar.bound.next")) != null) + nextBound = Integer.parseInt (nextMonthBound); + else + nextBound = 12; + if (c.get(Calendar.MONTH) - Calendar.getInstance().get(Calendar.MONTH) + 12 * (c.get(Calendar.YEAR) - Calendar.getInstance().get(Calendar.YEAR)) < nextBound) { + c.add(Calendar.MONTH, 1); + if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { + return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); + } + return "?month=" + c.get(Calendar.MONTH); + } + return ""; + } + + /** + *@deprecated versions without passing context + */ + public String computePrevMonthURL() + { + Calendar c = this.getCalendar(Locale.getDefault()); + c.add(Calendar.MONTH, -1); + if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { + return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); + } + return "?month=" + c.get(Calendar.MONTH); + } + + public String computeNextMonthURL() + { + Calendar c = this.getCalendar(Locale.getDefault()); + + c.add(Calendar.MONTH, 1); + if (c.get(Calendar.YEAR) != Calendar.getInstance().get(Calendar.YEAR)) { + return "?year=" + c.get(Calendar.YEAR) + "&month=" + c.get(Calendar.MONTH); + } + return "?month=" + c.get(Calendar.MONTH); + } +} Index: xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarPlugin.java =================================================================== --- xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarPlugin.java (revision 3312) +++ xwiki/core/src/main/java/com/xpn/xwiki/plugin/calendar/CalendarPlugin.java (working copy) @@ -159,16 +159,33 @@ // ------------------------- // --- draw the calendar --- // ------------------------- + + String tempMonthURL; + output.append(""); output.append(""); - output.append(""); + + if ((tempMonthURL = calendarParams.computePrevMonthURL(context)) != "") + { + tempMonthURL = "<"; + }/*else { + tempMonthURL = "<"; + }*/ + output.append(""); output.append(""); - output.append(""); + + if ((tempMonthURL = calendarParams.computeNextMonthURL(context)) != "") + { + tempMonthURL = ">"; + } /*else { + tempMonthURL = ">"; + }*/ + output.append(""); output.append(""); // emit the HTML calendar Index: xwiki/standalone/config/xwiki.cfg =================================================================== --- xwiki/standalone/config/xwiki.cfg (revision 3312) +++ xwiki/standalone/config/xwiki.cfg (working copy) @@ -114,3 +114,7 @@ xwiki.defaultskin=albatross xwiki.defaultbaseskin=albatross + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12 Index: xwiki/tests/resources/xwiki.cfg =================================================================== --- xwiki/tests/resources/xwiki.cfg (revision 3312) +++ xwiki/tests/resources/xwiki.cfg (working copy) @@ -64,4 +64,8 @@ xwiki.defaultskin=albatross xwiki.defaultbaseskin=albatross -xwiki.upload.tempdir=/tmp \ No newline at end of file +xwiki.upload.tempdir=/tmp + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12 \ No newline at end of file Index: xwiki/web/exo/src/main/webapp/WEB-INF/xwiki.cfg =================================================================== --- xwiki/web/exo/src/main/webapp/WEB-INF/xwiki.cfg (revision 3312) +++ xwiki/web/exo/src/main/webapp/WEB-INF/xwiki.cfg (working copy) @@ -104,3 +104,7 @@ xwiki.defaultskin=default xwiki.defaultbaseskin=default + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12 \ No newline at end of file Index: xwiki/web/standard/src/main/webapp/WEB-INF/xwiki.cfg =================================================================== --- xwiki/web/standard/src/main/webapp/WEB-INF/xwiki.cfg (revision 3312) +++ xwiki/web/standard/src/main/webapp/WEB-INF/xwiki.cfg (working copy) @@ -114,3 +114,7 @@ xwiki.defaultskin=albatross xwiki.defaultbaseskin=albatross + +# Calendar Prev/Next Month bounds +xwiki.calendar.bound.prev=6 +xwiki.calendar.bound.next=12
<" + tempMonthURL + ""); output.append(formatTitle.format(dayCal.getTime())); output.append(">" + tempMonthURL + "