Hier das script:
Code: Alles auswählen
<?PHP
# EXTcalendar 2002 Kristof De Jaeger
# http://realize.be/swentel
# mini cal which you can include somewhere if wanted !
# a td with events in will link to 'day-view' in calendar
include('cal_config.inc.php');
$m = date("n");
$y = date("Y");
$d = date("j");
if (!isset($_GET['month'])) $month = ''; else $month = $_GET['month'];
if (!isset($_GET['year'])) $year = ''; else $year = $_GET['year'];
if (!$month) $month = $m;
if (!$year) $year = $y;
# previous month
$pm = $month;
if ($month == "1") $pm = "12"; else $pm--;
# previous year
$py = $year;
if ($pm == "12") $py--;
# next month
$nm = $month;
if ($month == "12") $nm = "1"; else $nm++;
# next year
$ny = $year;
if ($nm == 1) $ny++;
# get month we want to see + calculate first day
$askedmonth = $maand[$month];
$askedyear = $year;
$firstday = date ("w", mktime(12,0,0,$month,1,$year));
$firstday++;
# nr of days in askedmonth
$nr = date("t",mktime(12,0,0,$month,1,$year));
# header (with links)
echo "<table border=$mini_monthborder cellspacing=$mini_calcells cellpadding=$mini_calcellp width=$mini_tablewidth>\n";
echo "<tr bgcolor=$mini_trtopcolor>";
echo "<td align=center colspan=7 height=$mini_tdtopheight>";
echo "<a href=cal_mini.inc.php?month=".$pm."&year=".$py.">";
echo "<img src=$mini_arrowleft border=0 alt=\"$maand[$pm] $py\" title=\"$maand[$pm] $py\"></a>";
echo " ";
echo "<font size=$mini_calfontasked><b>".$askedmonth." ".$askedyear."</b></font>";
echo " ";
echo "<a href=cal_mini.inc.php?month=".$nm."&year=".$ny.">";
echo "<img src=$mini_arrowright border=0 alt=\"$maand[$nm] $ny\" title=\"$maand[$nm] $ny\"></a>";
echo "</td>";
echo "</tr>\n";
echo "<tr>";
# make the days of week, consisting of seven <td>'s (=days)
# check if first is sunday or monday ? move sunday to end of array if day_start = 1
if ($day_start == 1)
{
$week[8] = $week[1];
array_shift($week);
$sunday_td = 7;
# now let's move all keys one down :)
for ($i=6,$a=7;$i>=0;$i--,$a--)
{
$week[$a] = $week[$i];
}
$firstday--;
} else $sunday_td = 1;
# make the days of week, consisting of seven <td>'s (=days)
for ($i=1;$i<=7;$i++)
{
echo "<td align=center width=$mini_tdwidth height=$mini_tddayheight ";
if ($i == $sunday_td) echo "bgcolor=$mini_sundaytopclr><font size=$mini_weekdayfont><b>".substr($week[$i],0,1)."</b></font></td>"; # sunday
else echo "bgcolor=$mini_weekdaytopclr><font size=$mini_weekdayfont><b>".substr($week[$i],0,1)."</b></font></td>"; # rest of week
}
echo "</tr>\n";
# begin the days
if ($firstday == 0 && $day_start == 1) $firstday = 7;
for ($i=1;$i<$firstday;$i++)
{
echo "<td height=$mini_tdheight ";
if ($i == "1") echo "bgcolor=$mini_sundayemptyclr "; # sunday empty td
else echo "bgcolor=$mini_weekdayemptyclr ";
echo "> </td>";
}
$a=0;
for ($i=1;$i<=$nr;$i++)
{
# get eventual events on $i
$query = "select id,title from events left join calendar_cat on events.cat=calendar_cat.cat_id where day='$i' ";
$query .= "and month='$month' and year='$year' and approved='1' order by day,month,year ASC";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
$sun = $i;
if ($day_start == 1) $sun++;
echo "<td height=$mini_tdheight ";
if ($rows)
echo "bgcolor=$mini_weekday_eventclr ";
elseif (($sun == (2-$firstday))||($sun == (9-$firstday)) or ($sun == (16-$firstday)) or ($sun == (23-$firstday)) or ($sun == (30-$firstday)) or ($sun == (37 - $firstday)))
echo "bgcolor=$mini_sundayclr ";
else echo "bgcolor=$mini_weekdayclr ";
echo " valign=middle align=center><font size=$mini_weekdayfont><b>";
if ($mini_wayoflink == 1)
{
$style = "cal";
$number = "";
}
if ($mini_wayoflink == 2)
{
$style = "flyer";
$number = "#$i";
}
if ($rows) echo "<a href=calendar.php?op=$style&month=$month&year=$year$number>";
echo $i;
if ($rows) echo "</a>";
echo "</b></font>";
echo "</td>\n";
# closing <tr> voor end of week
$a++;
if (($i == (8-$firstday)) or ($i == (15-$firstday)) or ($i == (22-$firstday)) or ($i == (29-$firstday)) or ($i == (36 - $firstday)))
{
echo "</tr>\n<tr>";
$a = 0;
}
}
# ending stuff (making 'white' td's to fill table
if ($a != 0)
{
$last = 7-$a;
for ($i=1;$i<=$last;$i++)
{
echo "<td bgcolor=$weekdayemptyclr> </td>";
}
}
echo "</tr>\n";
echo "</table>\n";
?>
Danke
mahou