Revision [1772]
This is an old revision of GmBowenCalendar made by JsnX on 2004-10-09 21:14:04.
Calendar action
I thought that some of you might find this calendar a useful little action. I can't claim to have written it, just modified an open source calendar script I found so it works in Wikka. -- MikeExample
The calendar action described on this page was added to Wikka version 1.1.5.4. Here's how it looks:Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | ||||
<< | = | >> |
Code:
The code has been modified some by JsnX, but it still has room for improvement. For example, the table background color is being set to a non-existent variable. This will be fixed before release. If any other bugs are spotted, please post them to this page or add a comment.<?php
$month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];
$year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
?>
<table bgcolor="<?php echo $style['tablebg']; ?>">
<tr>
<td valign="top">
<?php
/*== get what weekday the first is on ==*/
$tmpd = getdate(mktime(0,0,0,$month,1,$year));
$monthname = $tmpd["month"];
$firstwday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($month,$year);
?>
<table cellpadding="2" cellspacing="0" border="1">
<tr>
<td colspan="7" bgcolor="<?php echo $style['tablebg']; ?>">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month-1)<1) ? 12 : $month-1 ; ?>&year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>"><<</a></td>
<td bgcolor="<?php echo $style['tablebg']; ?>" align="center"><font size="2"><?php echo "$monthname $y"; ?></font></td>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">>></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="22">Su</td>
<td width="22">Mo</td>
<td width="22">Tu</td>
<td width="22">We</td>
<td width="22">Th</td>
<td width="22">Fr</td>
<td width="22">Sa</td>
</tr>
<?php
$day = 1;
$wday = $firstwday;
$firstweek = true;
/*== loop through all the days of the month ==*/
while ( $day <= $lastday)
{
/*== set up blank days for first week ==*/
if ($firstweek) {
print " <tr>";
for ($i=1; $i<=$firstwday; $i++)
{ print " <td><font size=\"2\"> </font></td>"; }
$firstweek = false;
}
/*== Sunday start week with <tr> ==*/
if ($wday==0) { print " <tr>\n"; }
/*== check for event ==*/
print " <td>";
if($day<10) {
if($month<10) {
$tag = "$year:0$month:0$day";
} else {
$tag = "$year:$month:0$day";
}
} else {
if($m<10) {
$tag = "$year:0$month:$day";
} else {
$tag = "$year:$month:$day";
}
}
$heute = date("Y:m:d",mktime()); // "01" bis "12"
if($tag==$heute)
{
$font1 = "<font color=\"#FF0000\">";
$font2 = "</font>";
}
else
{
$font1 = "";
$font2 = "";
}
print "$font1$day$font2";
print "</td>\n";
/*== Saturday week with </tr> ==*/
if ($wday==6) { print " </tr>\n"; }
$wday++;
$wday = $wday % 7;
$day++;
}
?>
</tr>
</table>
<br />
</td>
</tr>
</table>
<?php
/*== get the last day of the month ==*/
function mk_getLastDayofMonth($mon,$year)
{
for ($tday=28; $tday <= 31; $tday++)
{
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon) break;
}
$tday--;
return $tday;
}
?>
$month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];
$year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
?>
<table bgcolor="<?php echo $style['tablebg']; ?>">
<tr>
<td valign="top">
<?php
/*== get what weekday the first is on ==*/
$tmpd = getdate(mktime(0,0,0,$month,1,$year));
$monthname = $tmpd["month"];
$firstwday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($month,$year);
?>
<table cellpadding="2" cellspacing="0" border="1">
<tr>
<td colspan="7" bgcolor="<?php echo $style['tablebg']; ?>">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month-1)<1) ? 12 : $month-1 ; ?>&year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>"><<</a></td>
<td bgcolor="<?php echo $style['tablebg']; ?>" align="center"><font size="2"><?php echo "$monthname $y"; ?></font></td>
<td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">>></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="22">Su</td>
<td width="22">Mo</td>
<td width="22">Tu</td>
<td width="22">We</td>
<td width="22">Th</td>
<td width="22">Fr</td>
<td width="22">Sa</td>
</tr>
<?php
$day = 1;
$wday = $firstwday;
$firstweek = true;
/*== loop through all the days of the month ==*/
while ( $day <= $lastday)
{
/*== set up blank days for first week ==*/
if ($firstweek) {
print " <tr>";
for ($i=1; $i<=$firstwday; $i++)
{ print " <td><font size=\"2\"> </font></td>"; }
$firstweek = false;
}
/*== Sunday start week with <tr> ==*/
if ($wday==0) { print " <tr>\n"; }
/*== check for event ==*/
print " <td>";
if($day<10) {
if($month<10) {
$tag = "$year:0$month:0$day";
} else {
$tag = "$year:$month:0$day";
}
} else {
if($m<10) {
$tag = "$year:0$month:$day";
} else {
$tag = "$year:$month:$day";
}
}
$heute = date("Y:m:d",mktime()); // "01" bis "12"
if($tag==$heute)
{
$font1 = "<font color=\"#FF0000\">";
$font2 = "</font>";
}
else
{
$font1 = "";
$font2 = "";
}
print "$font1$day$font2";
print "</td>\n";
/*== Saturday week with </tr> ==*/
if ($wday==6) { print " </tr>\n"; }
$wday++;
$wday = $wday % 7;
$day++;
}
?>
</tr>
</table>
<br />
</td>
</tr>
</table>
<?php
/*== get the last day of the month ==*/
function mk_getLastDayofMonth($mon,$year)
{
for ($tday=28; $tday <= 31; $tday++)
{
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon) break;
}
$tday--;
return $tday;
}
?>