Calendar widgit is broken when wrapping years
---------------------------------------------
Key: OLIO-18
URL: https://issues.apache.org/jira/browse/OLIO-18
Project: Olio
Issue Type: Bug
Components: php-app
Reporter: Nick Lanham
Assignee: Shanti Subramanyam
If a user clicks the next_month or prev_month arrows and the year is wrapping
(i.e. going from December to January or vice versa) then the links for the
particular days in that month will be wrong. For example, if it's December
2008 and a user clicks the next month and then clicks the link for the 4th the
url will be "http://[host]/index.php?month=13&day=04&year=2008", which is wrong
in both the month and year fields. The same holds for prev_month except the
month will go to 0 (or lower) and the year will not change.
Here are patches that will fix the problem:
--- webapp/php/trunk/public_html/calendar.php
+++ webapp/php/trunk/public_html/calendar.php
@@ -57,8 +57,8 @@ $prevMonthDay++;
}
$prev_year= $year-1;
$next_year= $year+1;
-$prev_month = $month-1;
-$next_month = $month+1;
+$prev_month = $month==1?12:$month-1;
+$next_month = $month==12?1:$month+1;
ob_start();
require("../views/calendar.php");
--- webapp/php/trunk/views/calendar.php
+++ webapp/php/trunk/views/calendar.php
@@ -46,9 +46,9 @@ var updateMYLink = "calendar.php?mon=";
<caption class="monthName"></caption><thead>
<tr><th id="calheader" colspan="7">
<a href="#prev_year" class="prev_year" onclick="updateCalendar(<?echo
$month;?>,<? echo $prev_year;?>)"><</a>
- <a href="#prev_month" class="prev_month" onclick="updateCalendar(<? echo
$prev_month;?>,<? echo $year;?>)"><</a>
+ <a href="#prev_month" class="prev_month" onclick="updateCalendar(<? echo
$prev_month;?>,<? echo ($prev_month==12?($year-1):$year);?>)"><</a>
<?=$monthName." ".$year?>
- <a href="#next_month" class="next_month" onclick="updateCalendar(<?echo
$next_month;?>,<? echo $year;?>)">></a>
+ <a href="#next_month" class="next_month" onclick="updateCalendar(<?echo
$next_month;?>,<? echo ($next_month==1?($year+1):$year);?>)">></a>
<a href="#next_year" class="next_year" onclick="updateCalendar(<?echo
$month;?>,<? echo $next_year;?>)">></a>
</th></tr>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.