fixes issue #5: remove links to pages in the future, keep those to future days in the current month anyways
parent
4eebfe79ff
commit
5661298dc5
|
|
@ -7,3 +7,5 @@ $database = array(
|
|||
'database' => "temp",
|
||||
);
|
||||
|
||||
$start_year_of_recordings=2012;
|
||||
|
||||
|
|
|
|||
51
function.php
51
function.php
|
|
@ -314,9 +314,13 @@ function drawChart($myData,$target,$date,$type){
|
|||
$myPicture->Render($target);
|
||||
}
|
||||
|
||||
function calendarDay($day,$year,$month,$selection){
|
||||
function calendarDay($day,$year,$month,$selection, $future){
|
||||
$baselink="&year=".$year."&month=".$month."&day=".$day."'";
|
||||
if($future){
|
||||
return $day." (H A B)";
|
||||
}else{
|
||||
return tempLink($baselink,$day,($selection=="temp")).humiLink($baselink,($selection=="humi")).ambiLink($baselink,($selection=="ambi")).baroLink($baselink,($selection=="baro"));
|
||||
}
|
||||
}
|
||||
function tempLink($baselink,$day,$selected=false){
|
||||
$link="<a href='?type=temp".$baselink;
|
||||
|
|
@ -347,6 +351,8 @@ function baroLink($baselink,$selected=false){
|
|||
return $link." >B</a>)";
|
||||
}
|
||||
function calendarNav($month,$year){
|
||||
global $start_year_of_recordings;
|
||||
|
||||
$prevMonth=$prevYear=$nextMonth=$nextYear=0;
|
||||
if($month==12){
|
||||
$prevMonth=$month-1;
|
||||
|
|
@ -364,7 +370,27 @@ function calendarNav($month,$year){
|
|||
$nextMonth=$month+1;
|
||||
$nextYear=$year;
|
||||
}
|
||||
return "<div id='calendarNav'>\n\t<a href='?mode=month&year=".$prevYear."&month=".$prevMonth."'><<</a> <a href='?mode=month&year=".$year."&month=".$month."'>".$month."</a> <a href='?mode=month&year=".$nextYear."&month=".$nextMonth."'>>></a>\n</div>\n";
|
||||
$show['prev']=$prevYear >= $start_year_of_recordings;
|
||||
$show['next']=! isFuture(array(date("j"),date("n"),date("Y")), 0, $nextMonth, $nextYear);
|
||||
$links="<div id='calendarNav'>\n\t";
|
||||
if ($show['prev']){
|
||||
$links.="<a href='?mode=month&year=".$prevYear."&month=".$prevMonth."'><< (".monthToName($prevMonth).")</a>";
|
||||
}else{
|
||||
$links.=monthToName($prevMonth);
|
||||
}
|
||||
$links.=" <a href='?mode=month&year=".$year."&month=".$month."'>".monthToName($month)."</a> ";
|
||||
if ($show['next']){
|
||||
$links.="<a href='?mode=month&year=".$nextYear."&month=".$nextMonth."'>>> (".monthToName($nextMonth).")</a>";
|
||||
}else{
|
||||
$links.=monthToName($nextMonth);
|
||||
}
|
||||
$links.="\n</div>\n";
|
||||
return $links;
|
||||
}
|
||||
function monthToName($month){
|
||||
$dateObj = DateTime::createFromFormat('!m', $month);
|
||||
$monthName = $dateObj->format('F');
|
||||
return $monthName;
|
||||
}
|
||||
function prependZero($number){
|
||||
return ($number<10)? "0".$number : $number;
|
||||
|
|
@ -393,7 +419,8 @@ function drawCalendar($date,$type){
|
|||
}else{
|
||||
$calendar.="\t\t<td>";
|
||||
}
|
||||
$calendar.=calendarDay($day,$year,$month,($day==$selectedDay)? $type : false);
|
||||
$future=isFuture($today, $day, $month, $year, false);
|
||||
$calendar.=calendarDay($day,$year,$month,($day==$selectedDay)? $type : false, $future);
|
||||
$day++;
|
||||
}else{
|
||||
$calendar.="\t\t<td> ";
|
||||
|
|
@ -406,6 +433,24 @@ function drawCalendar($date,$type){
|
|||
Letzte: <a href='?mode=last&num=24&type=temp'>24h</a> <a href='?mode=last&num=48&type=temp'>48h</a> <a href='?mode=last&num=96&type=temp'>96h</a> <a href='?'>Temperatur Heute</a></div>";
|
||||
return $calendar;
|
||||
}
|
||||
function isFuture($today, $day, $month, $year, $overwriteDay=true){
|
||||
# check year
|
||||
if ($today[2] < $year){
|
||||
return true;
|
||||
}
|
||||
if ($today[2] == $year){
|
||||
# check month
|
||||
if ($today[1] < $month){
|
||||
return true;
|
||||
}
|
||||
if($today[1] == $month){
|
||||
# check day
|
||||
return $today[0] < $day && $overwriteDay;
|
||||
}
|
||||
}
|
||||
# base case
|
||||
return false;
|
||||
}
|
||||
|
||||
function typeToSensorCount($type){
|
||||
switch($type){
|
||||
|
|
|
|||
Loading…
Reference in New Issue