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. -- Mike

NEW: Users of this page should now note that the code shown on this page is NOT the code generating the calendar visible here. The action which generates the calendar visible on this page is almost a complete code re-write (with substantially different structure, etc.) by JavaWoman and is available at JwCalendar. The code shown on this page will work as a calendar, but it's copyright is considerably more hazy (see the discussion in the comments below which probably accurately identifies the original designer as Marcus Kazmierczak and the site the code originated from, probably several authors back now, is probably Blazonry whose copyright statement does allow for modification).... but I'm leaving the code here as it might be useful for other purposes....such as comparative ones. -- Mike

Example

The calendar action described on this page was added to Wikka version 1.1.5.4 (GMB note: never released, superceded by 1.1.6.0....see WikkaReleaseNotes). Here's how it looks:
December 2017
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
31            
<< = >>


You can control the appearance of the calendar by modifying the stylesheet and adding a calendar style. For example:
.calendar
{
	background-color: teal;
	color: white;
}
.calendar .currentday {color: yellow;}


Code:

The code has been modified some by JsnX, but it still has room for improvement.

<?php
$month = (!isset($_GET['month'])) ? date("n",mktime()) : $_GET['month'];    
$year = (!isset($_GET['year'])) ? date("Y",mktime()) : $_GET['year'];
?>

<table class="calendar">
    <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">
            <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 ; ?>&amp;year=<?php echo (($month-1)<1) ? $year-1 : $year ; ?>">&lt;&lt;</a></td>
                    <td align="center"><font size="2"><?php echo "$monthname $year"; ?></font></td>
                    <td width="20"><a href="<?php echo $this->href("", "", "month="); echo (($month+1)>12) ? 1 : $month+1 ; ?>&amp;year=<?php echo (($month+1)>12) ? $year+1 : $year ; ?>">&gt;&gt;</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\">&nbsp;</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($month<10) {
                $tag = "$year:0$month:$day";
            } else {
                $tag = "$year:$month:$day";
            }
        }
       
        $heute = date("Y:m:d",mktime());    // "01" bis "12"
        if($tag==$heute)
        {
            print "<span class='currentday'>$day</span>";
        }
        else
        {
           print "$day";
        }
        print "</td>\n";

        /*== Saturday week with </tr> ==*/
        if ($wday==6) { print "    </tr>\n"; }

        $wday++;
        $wday = $wday % 7;
        $day++;
    }
?>
    </tr>
</table>
        </td>
    </tr>
</table>
<br />

<?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;
}

?>


"The <a> tags should be replaced with the appropriate function (JsnX, I think it's time to write some Coding Tips in the WikkaCore page ;))" .... I'm all for that. I don't have a clue why what I coded was inappropriate and would happily work at complying with what the overall wakka community is doing. -- Mike
My variant of this Calendar action is now ready - explanations (lots) and code on JwCalendar. Not just "cleaned up" but with extended functionality and internationalization-ready (in fact, mostly done!), while it still does all yours does. :) --JavaWoman.
Wow....what an incredible amount of work....nice job JW. I'm going to have to start this Scheduler Project all over aren't I?? (to keep the code base coherent) Sigh (grin). -- Mike
Thanks, Mike! Actually, I think you'll see that with the code organization as I'm explaining in "A pattern for an action" it's easier to extend and maintain. And if you make another action, try following that coding pattern, too. --JavaWoman

[Show Code]

Year Calendar

Prompted by chattering with JavaWoman (in the comment section for her calendar), I snooped around to see if there was a way to have a Year calendar as an action. I came across activecalendar (which is essentially the readme.html file referred to in the comments in the program) which I spent an evening fooling around with to make work in wikka. I "hardcoded" a bit "in" the distributed class because I needed to replace a "?" with a "&" (take a look at line 477 and you'll see what I mean) and added a few lines of code at the top so it would read in variables (figuring out how to add the code in the 4th line in the brackets so that the url reference to change years correctly was a pure fluke...I'd struggled with trying to get that code to work in the function at line 477 for hours without success). Overall it works pretty well (you can see it working here)....I hope some of you find it useful. Feel free to tidy the code up anyone that wants to remove the functions oriented for doing "month" panels only.

I had to add the following code to the css file....
.year {border-style: outset; border-width: 1px; background-color: #cbeaca; text-align: center;}
.month {border-style: none; background-color: #cbeaca; text-align: center;}
.yearname {text-align: center; font-size: 20px; font-weight: bold;}
.monthname {text-align: center; font-size: 13px; height: 30px; background-color: #e9e9e9;}
.yearnavigation {background-color: #dddddd;}
.monthnavigation {background-color: #dddddd;}
.datepicker {background-color: #ffffff;}
.datepickerform {margin: 0px;}
.monthpicker {background-color: #eeeeee;}
.yearpicker {background-color: #eeeeee;}
.pickerbutton {background-color: #eeeeee; border-style: none;}
.dayname td {text-align: center; font-size: 13px; background-color: #dddddd;}
.nomonthday {background-color: #cbeaca; height:25px; width:25px;}
.monthday {text-align: center; background-color: #e9e9e9; height:25px; width:25px;}
.today {text-align: center; background-color: #ffff99; height:25px; width:25px;}
.selectedday {text-align: center; background-color: #66ff66; height:25px; width:25px;}
.sunday {text-align: center; font-weight: bold; color: red; height:20px; width:20px;}
.sunday a {color: red;}
.saturday {text-align: center; font-weight: bold; color: red; height:20px; width:20px;}
.saturday a {color: red;}
.event {text-align: center; color: red; background-color: #ffff99; height:20px; width:20px;}
.event a {background-color: #ffff99; color: red;}
.selectedevent {text-align: center; color: red; background-color: #ffff99; height:20px; width:20px;}
.selectedevent a {background-color: #ffff99; color: red;}
.todayevent {text-align: center; color: red; background-color: #ffff99; height:20px; width:20px;}
.todayevent a {background-color: #ffff99; color: red;}  

and then I used the following code as the action year.php
<?php
$yearID = (!isset($_GET['yearID'])) ? date("Y",mktime()) : $_GET['yearID'];
$cal = new activeCalendar($yearID);
$cal->enableYearNav("wakka.php?wakka=".$this->GetPageTag());
echo $cal->showYear();
/*
* @class: activeCalendar
* @project: Active Calendar Class
* @version: 0.9 (stable);
* @author: Giorgos Tsiledakis;
* @date: 2004-11-20;
* @copyright: Giorgos Tsiledakis;
* @license: GNU LESSER GENERAL PUBLIC LICENSE;
*
* Special thanks to Corissia S.A (http://www.corissia.com) for the permission to publish the source code
* Thanks to Maik Lindner (http://nifox.com) for his help developing this class
*
* This class generates calendars as a html table
* Supported views: month and year view
* Supported dates:
* 1. Using PHP native date functions (default): 1902-2037 (UNIX) or 1971-2037 (Windows)
* 2. Using ADOdb Date Library : 100-3000 and later [limited by the computation time of adodb_mktime()].
* You can find the ADOdb Date Library at http://phplens.com/phpeverywhere/adodb_date_library
* To use the ADOdb Date Library just include it in your main script. The Active Calendar class will use the library functions automatically.
* Supported features:
* 1. Static calendar without any links
* 2. Calendar with month's or year's view navigation controls
* 3. Calendar with linkable days (url or javascript)
* 4. Calendar with a date picker (year ot month mode)
* 5. Calendar with event days (css configutation) and event links
* The layout of can be configured using css, as the class generates various html classes (check the css file included)
* Please read the readme.html first and check the examples included in this package
*/

class activeCalendar{
/*
********************************************************************************
You can change below the month and day names, according to your language
********************************************************************************
*/

var $jan="January";
var $feb="February";
var $mar="March";
var $apr="April";
var $may="May";
var $jun="June";
var $jul="July";
var $aug="August";
var $sep="September";
var $oct="October";
var $nov="November";
var $dec="December";
var $sun="Sun";
var $mon="Mon";
var $tue="Tue";
var $wed="Wed";
var $thu="Thu";
var $fri="Fri";
var $sat="Sat";
/*
********************************************************************************
You can change below the year's and month's view navigation controls
********************************************************************************
*/

var $yearNavBack=" &lt;&lt; "; // Previous year
var $yearNavForw=" &gt;&gt; "; // Next year
var $monthNavBack=" &lt;&lt; "; // Previous month
var $monthNavForw=" &gt;&gt; "; // Next month
var $selBtn="Go"; // value of the date picker button (if enabled)
var $monthYearDivider=" "; // the divider between month and year in the month`s title
/*
********************************************************************************
$startOnSun = false: first day of week is Monday
$startOnSun = true: first day of week is Sunday
********************************************************************************
*/

var $startOnSun=true;
/*
********************************************************************************
$rowCount : defines the number of months in a row in yearview
********************************************************************************
*/

var $rowCount=4;
/*
********************************************************************************
$crSunClass = true: creates a td class="sunday" on every Sunday (css layout)
$$crSatClass = true: creates a td class="saturday" on every Saturday (css layout)
********************************************************************************
*/

var $crSunClass=true;
var $crSatClass=true;
/*
********************************************************************************
You can change below the GET VARS NAMES (navigation + day links)
You should modify mkUrl(), if you want to change the structure of the generated links
********************************************************************************
*/

var $yearID="yearID";
var $monthID="monthID";
var $dayID="dayID";

/*
********************************************************************************
You can change below only if you know what you are doing :)
********************************************************************************
*/

var $yearNav=false; // true enables the year's view navigation controls (set by enableYearNav())
var $monthNav=false; // true enables the months's view navigation controls (set by enableMonthNav())
var $dayLinks=false; // true enables links on each day (set by enableDayLinks())
var $datePicker=false; // true enables date picker control (set by enableDatePicker())
var $startYear=1971; // default start year for the date picker (can be changed, if using the ADOdb Date Library)
var $endYear=2037; // default end year for the date picker (can be changed, if using the ADOdb Date Library)
var $url=false;
var $calEvents=false;
var $calEventsUrl=false;
var $eventUrl=false;
var $javaScriptDay=false;
/*
********************************************************************************
activeCalendar() -> class constructor, does the initial date calculation by calling the internal methods mkActiveTime(), mkActiveDate()
********************************************************************************
*/

function activeCalendar($year=false,$month=false,$day=false){
$this->selectedday=-2;
$this->selectedyear=$year;
$this->selectedmonth=$month;
    if (!$month) $month=1;
    if (!$day) $day=1;
    else $this->selectedday=$day;
$this->unixtime=$this->mkActiveTime(0,0,1,$month,$day,$year);
    if ($this->unixtime==-1 || !$year) $this->unixtime=time();
$this->daytoday=$this->mkActiveDate("j");
$this->monthtoday=$this->mkActiveDate("n");
$this->yeartoday=$this->mkActiveDate("Y");
$this->actday=$this->mkActiveDate("j",$this->unixtime);
$this->actmonth=$this->mkActiveDate("n",$this->unixtime);
$this->actyear=$this->mkActiveDate("Y",$this->unixtime);
$this->has31days=checkdate($this->actmonth,31,$this->actyear);
$this->isSchalt=checkdate(2,29,$this->actyear);
    if ($this->isSchalt==1 && $this->actmonth==2) $this->maxdays=29;
    elseif ($this->isSchalt!=1 && $this->actmonth==2) $this->maxdays=28;
    elseif ($this->has31days==1) $this->maxdays=31;
    else $this->maxdays=30;
$this->firstday=$this->mkActiveDate("w", $this->mkActiveTime(0,0,1,$this->actmonth,1,$this->actyear));
}
/*
********************************************************************************
enableYearNav() -> enables the year's navigation controls
********************************************************************************
*/

function enableYearNav($link=false){
    if ($link) $this->url=$link;
    else $this->url=$_SERVER['PHP_SELF'];
$this->yearNav=true;
}
/*
********************************************************************************
enableMonthNav() -> enables the month's navigation controls
********************************************************************************
*/

function enableMonthNav($link=false){
    if ($link) $this->url=$link;
    else $this->url=$_SERVER['PHP_SELF'];
$this->monthNav=true;
}
/*
********************************************************************************
enableDayLinks() -> enables the day links
param javaScript: sets a Javascript function on each day link
********************************************************************************
*/

function enableDayLinks($link=false,$javaScript=false){
    if ($link) $this->url=$link;
    else $this->url=$_SERVER['PHP_SELF'];
    if ($javaScript) $this->javaScriptDay=$javaScript;
$this->dayLinks=true;
}
/*
********************************************************************************
enableDatePicker() -> enables the day picker control
********************************************************************************
*/

function enableDatePicker($startYear=false,$endYear=false,$link=false){
    if ($link) $this->url=$link;
    else $this->url=$_SERVER['PHP_SELF'];
    if ($startYear && $endYear){
        if ($startYear>=$this->startYear && $startYear<$this->endYear) $this->startYear=$startYear;
        if ($endYear>$this->startYear && $endYear<=$this->endYear) $this->endYear=$endYear;
    }
$this->datePicker=true;
}
/*
********************************************************************************
setEvent() -> sets a calendar event, $id: the HTML class (css layout)
********************************************************************************
*/

function setEvent($year,$month,$day,$id=false,$url=false){
$eventTime=$this->mkActiveTime(0,0,1,$month,$day,$year);
    if (!$id) $id="event";
    if (!$url) $this->calEvents[$eventTime]=$id;
    else{
        $this->calEvents[$eventTime]=$id;
        $this->calEventsUrl[$eventTime]=$url;
    }
}
/*
********************************************************************************
showYear() -> returns the year's view as html table string
Each internal method returns a tr tag of the table as a string.
You can change the calendar structure by simply calling these internal methods in another order
********************************************************************************
*/

function showYear(){
$this->monthNav=false;
$out=$this->mkYearHead(); // this should remain first: opens table tag
$out.=$this->mkYearTitle(); // tr tag: year title and navigation
$out.=$this->mkDatePicker("yearonly"); // tr tag: year date picker (only year selection)
$this->datePicker=false;
$out.=$this->mkYearBody(); // tr tag(s): year month (html tables)
$out.=$this->mkYearFoot(); // this should remain last: closes table tag
return $out;
}
/*
********************************************************************************
showMonth() -> returns the month's view as html table string
Each internal method returns a tr tag of the table as a string.
You can change the calendar structure by simply calling these internal methods in another order
********************************************************************************
*/

function showMonth(){
$out=$this->mkMonthHead(); // this should remain first: opens table tag
$out.=$this->mkMonthTitle(); // tr tag: month title and navigation
$out.=$this->mkDatePicker(); // tr tag: month date picker (month and year selection)
$out.=$this->mkWeekDays(); // tr tag: the weekday names
$out.=$this->mkMonthBody(); // tr tags: the days of the month
$out.=$this->mkMonthFoot(); // this should remain last: closes table tag
return $out;
}
/*
********************************************************************************
INTERN mkYearHead() -> creates the year table tag
********************************************************************************
*/

function mkYearHead(){
return "<table class=\"year\">\n";
}
/*
********************************************************************************
INTERN mkYearTitle() -> creates the tile and navigation tr tag of the year table
********************************************************************************
*/

function mkYearTitle(){
    if ($this->rowCount<1 || $this->rowCount>12) $this->rowCount=4;
    if (!$this->yearNav){
        $out="<tr><td colspan=\"".$this->rowCount."\" class=\"yearname\">";
        $out.=$this->actyear;
        $out.="</td></tr>\n";
    }
    else{
        $out="<tr><td colspan=\"".$this->rowCount."\" align=\"center\">";
        $out.="<table><tr><td class=\"yearnavigation\">";
        $out.=$this->mkUrl($this->actyear-1);
        $out.=$this->yearNavBack."</a></td>";
        $out.="<td class=\"yearname\">".$this->actyear."</td>";
        $out.="<td class=\"yearnavigation\">";
        $out.=$this->mkUrl($this->actyear+1);
        $out.=$this->yearNavForw."</a></td></tr></table></td></tr>\n";
    }
return $out;
}
/*
********************************************************************************
INTERN mkYearBody() -> creates the tr tags of the year table
********************************************************************************
*/

function mkYearBody(){
$TrMaker = $this->rowCount;
$out="<tr>\n";
    for ($x=1; $x<=12; $x++) {
        $this->activeCalendar($this->actyear,$x);
        $out.="<td valign=\"top\">\n".$this->showMonth()."</td>\n";
        if ($x == $TrMaker && $x < 12) {
            $out.="</tr><tr>";
            $TrMaker = ($TrMaker+$this->rowCount);
        }
    }
$out.="</tr>\n";
return $out;
}
/*
********************************************************************************
INTERN mkYearFoot() -> closes the year table tag
********************************************************************************
*/

function mkYearFoot(){
return "</table>\n";
}
/*
********************************************************************************
INTERN mkMonthHead() -> creates the month table tag
********************************************************************************
*/

function mkMonthHead(){
return "<table class=\"month\">\n";
}
/*
********************************************************************************
INTERN mkMonthTitle() -> creates the tile and navigation tr tag of the month table
********************************************************************************
*/

function mkMonthTitle(){
    if (!$this->monthNav){
        $out="<tr><td class=\"monthname\" colspan=\"7\">";
        $out.=$this->getMonthName().$this->monthYearDivider.$this->actyear;
        $out.="</td></tr>\n";
    }
    else{
        $out="<tr><td class=\"monthnavigation\" colspan=\"2\">";
        if ($this->actmonth==1) $out.=$this->mkUrl($this->actyear-1,"12");
        else $out.=$this->mkUrl($this->actyear,$this->actmonth-1);
        $out.=$this->monthNavBack."</a></td>";
        $out.="<td class=\"monthname\" colspan=\"3\">";
        $out.=$this->getMonthName().$this->monthYearDivider.$this->actyear."</td>";
        $out.="<td class=\"monthnavigation\" colspan=\"2\">";
        if ($this->actmonth==12) $out.=$this->mkUrl($this->actyear+1,"1");
        else $out.=$this->mkUrl($this->actyear,$this->actmonth+1);
        $out.=$this->monthNavForw."</a></td></tr>\n";
    }
return $out;
}
/*
********************************************************************************
INTERN mkDatePicker() -> creates the tr tag for the date picker
********************************************************************************
*/

function mkDatePicker($yearpicker=false){
    if ($yearpicker) $pickerSpan=$this->rowCount;
    else $pickerSpan=7;
    if ($this->datePicker){
        $out="<tr><td class=\"datepicker\" colspan=\"".$pickerSpan."\">\n";
        $out.="<form name=\"datepickerform\" class=\"datepickerform\" action=\"".$this->url."\" method=\"get\">\n";
        if (!$yearpicker){
            $out.="<select name=\"".$this->monthID."\" class=\"monthpicker\">\n";
            for ($z=1;$z<=12;$z++){
                if ($z==$this->actmonth) $out.="<option value=\"".$z."\" selected=\"selected\">".$this->getMonthName($z)."</option>\n";
                else $out.="<option value=\"".$z."\">".$this->getMonthName($z)."</option>\n";
            }
            $out.="</select>\n";
        }
        $out.="<select name=\"".$this->yearID."\" class=\"yearpicker\">\n";
        for ($z=$this->startYear;$z<=$this->endYear;$z++){
            if ($z==$this->actyear) $out.="<option value=\"".$z."\" selected=\"selected\">".$z."</option>\n";
            else $out.="<option value=\"".$z."\">".$z."</option>\n";
        }
        $out.="</select>\n";
        $out.="<input type=\"submit\" value=\"".$this->selBtn."\" class=\"pickerbutton\">\n";
        $out.="</form>\n";
        $out.="</td></tr>\n";
    }
    else $out="";
return $out;
}
/*
********************************************************************************
INTERN mkWeekDays() -> creates the tr tag of the month table for the weekdays
********************************************************************************
*/

function mkWeekDays(){
    if ($this->startOnSun){
        $out="<tr class=\"dayname\"><td>".$this->getDayName(0)."</td>";
        $out.="<td>".$this->getDayName(1)."</td>";
        $out.="<td>".$this->getDayName(2)."</td>";
        $out.="<td>".$this->getDayName(3)."</td>";
        $out.="<td>".$this->getDayName(4)."</td>";
        $out.="<td>".$this->getDayName(5)."</td>";
        $out.="<td>".$this->getDayName(6)."</td></tr>\n";
    }
    else{
        $out="<tr class=\"dayname\"><td>".$this->getDayName(1)."</td>";
        $out.="<td>".$this->getDayName(2)."</td>";
        $out.="<td>".$this->getDayName(3)."</td>";
        $out.="<td>".$this->getDayName(4)."</td>";
        $out.="<td>".$this->getDayName(5)."</td>";
        $out.="<td>".$this->getDayName(6)."</td>";
        $out.="<td>".$this->getDayName(0)."</td></tr>\n";
        $this->firstday=$this->firstday-1;
        if ($this->firstday<0) $this->firstday=6;
    }
return $out;
}
/*
********************************************************************************
INTERN mkMonthBody() -> creates the tr tags of the month table
********************************************************************************
*/

function mkMonthBody(){
$out="<tr>";
$monthday=0;
    for ($x=0; $x<=6; $x++){
        if ($x>=$this->firstday){
        $monthday++;
        $out.=$this->mkDay($monthday);
        }
        else $out.="<td class=\"nomonthday\"></td>";
    }
$out.="</tr>\n";
$goon=$monthday+1;
$stop=0;
    for ($x=0; $x<=6; $x++){
        if ($goon>$this->maxdays) break;
        if ($stop==1) break;
        $out.="<tr>";
            for ($i=$goon; $i<=$goon+6; $i++){
                if ($i>$this->maxdays){
                    $out.="<td class=\"nomonthday\"></td>";
                    $stop=1;
                }
                else $out.=$this->mkDay($i);
            }
        $goon=$goon+7;
        $out.="</tr>\n";
    }
$this->selectedday="-2";
return $out;
}
/*
********************************************************************************
INTERN mkDay() -> creates each td tag of the month body
********************************************************************************
*/

function mkDay($var){
$linkstr=$this->mkUrl($this->actyear,$this->actmonth,$var);
    if ($this->javaScriptDay) $linkstr="<a href=\"javascript:".$this->javaScriptDay."(".$this->actyear.",".$this->actmonth.",".$var.")\">".$var."</a>";
    if ($this->isEvent($var)){
        if ($this->eventUrl){
            $out="<td class=\"".$this->eventID."\"><a href=\"".$this->eventUrl."\">".$var."</a></td>";
            $this->eventUrl=false;
        }
        elseif (!$this->dayLinks) $out="<td class=\"".$this->eventID."\">".$var."</td>";
        else $out="<td class=\"".$this->eventID."\">".$linkstr."</td>";
    }
    elseif ($var==$this->selectedday && $this->actmonth==$this->selectedmonth && $this->actyear==$this->selectedyear){
        if (!$this->dayLinks) $out="<td class=\"selectedday\">".$var."</td>";
        else $out="<td class=\"selectedday\">".$linkstr."</td>";
    }
    elseif ($var==$this->daytoday && $this->actmonth==$this->monthtoday && $this->actyear==$this->yeartoday){
        if (!$this->dayLinks) $out="<td class=\"today\">".$var."</td>";
        else $out="<td class=\"today\">".$linkstr."</td>";
    }
    elseif ($this->getWeekday($var)==0 && $this->crSunClass){
        if (!$this->dayLinks) $out="<td class=\"sunday\">".$var."</td>";
        else $out="<td class=\"sunday\">".$linkstr."</td>";
    }
    elseif ($this->getWeekday($var)==6 && $this->crSatClass){
        if (!$this->dayLinks) $out="<td class=\"saturday\">".$var."</td>";
        else $out="<td class=\"saturday\">".$linkstr."</td>";
    }
    else{
        if (!$this->dayLinks) $out="<td class=\"monthday\">".$var."</td>";
        else $out="<td class=\"monthday\">".$linkstr."</td>";
    }
return $out;
}
/*
********************************************************************************
INTERN mkMonthFoot() -> closes the month table
********************************************************************************
*/

function mkMonthFoot(){
return "</table>\n";
}
/*
********************************************************************************
INTERN mkUrl() -> creates the day and navigation link structure
********************************************************************************
*/

function mkUrl($year,$month=false,$day=false){
if (strpos($this->url,"?")) $glue="&";
else $glue="?";
// LINE BELOW EDITED BY GMB adding "&" to replace $glue
$yearNavLink="<a href=\"".$this->url."&amp;".$this->yearID."=".$year."\">";
$monthNavLink="<a href=\"".$this->url.$glue.$this->yearID."=".$year."&amp;".$this->monthID."=".$month."\">";
$dayLink="<a href=\"".$this->url.$glue.$this->yearID."=".$year."&amp;".$this->monthID."=".$month."&amp;".$this->dayID."=".$day."\">".$day."</a>";
if ($year && $month && $day) return $dayLink;
if ($year && !$month && !$day) return $yearNavLink;
if ($year && $month && !$day) return $monthNavLink;
}
/*
********************************************************************************
INTERN getMonthName() -> returns the month's name, according to the configuration
********************************************************************************
*/

function getMonthName($var=false){
    if (!$var) $var=@$this->actmonth;
    switch($var){
        case 1: return $this->jan;
        case 2: return $this->feb;
        case 3: return $this->mar;
        case 4: return $this->apr;
        case 5: return $this->may;
        case 6: return $this->jun;
        case 7: return $this->jul;
        case 8: return $this->aug;
        case 9: return $this->sep;
        case 10: return $this->oct;
        case 11: return $this->nov;
        case 12: return $this->dec;
    }
}
/*
********************************************************************************
INTERN getDayName() -> returns the day's name, according to the configuration
********************************************************************************
*/

function getDayName($var=false){
    switch($var){
        case 0: return $this->sun;
        case 1: return $this->mon;
        case 2: return $this->tue;
        case 3: return $this->wed;
        case 4: return $this->thu;
        case 5: return $this->fri;
        case 6: return $this->sat;
    }
}
/*
********************************************************************************
INTERN getWeekday() -> returns the weekday's number, 0 = Sunday ... 6 = Saturday
********************************************************************************
*/

function getWeekday($var){
return $this->mkActiveDate("w", $this->mkActiveTime(0,0,1,$this->actmonth,$var,$this->actyear));
}
/*
********************************************************************************
INTERN isEvent() -> checks if a date was set as an event and creates the eventID (css layout) and eventUrl
********************************************************************************
*/

function isEvent($var){
    if ($this->calEvents){
        $checkTime=$this->mkActiveTime(0,0,1,$this->actmonth,$var,$this->actyear);
        $selectedTime=$this->mkActiveTime(0,0,1,$this->selectedmonth,$this->selectedday,$this->selectedyear);
        $todayTime=$this->mkActiveTime(0,0,1,$this->monthtoday,$this->daytoday,$this->yeartoday);
        foreach($this->calEvents as $eventTime => $eventID){
            if ($eventTime==$checkTime){
                if ($eventTime==$selectedTime) $this->eventID="selected".$eventID;
                elseif ($eventTime==$todayTime) $this->eventID="today".$eventID;
                else $this->eventID=$eventID;
                if ($this->calEventsUrl[$eventTime]) $this->eventUrl=$this->calEventsUrl[$eventTime];
                return true;
            }
        }
    return false;
    }
}
/*
********************************************************************************
INTERN mkActiveDate() -> checks if ADOdb Date Library is loaded and calls the date function
********************************************************************************
*/

function mkActiveDate($param,$acttime=false){
    if (!$acttime) $acttime=time();
    if (function_exists("adodb_date")) return adodb_date($param,$acttime);
    else return date($param,$acttime);
}
/*
********************************************************************************
INTERN mkActiveTime() -> checks if ADOdb Date Library is loaded and calls the mktime function
********************************************************************************
*/

function mkActiveTime($hr,$min,$sec,$month=false,$day=false,$year=false){
    if (function_exists("adodb_mktime")) return adodb_mktime($hr,$min,$sec,$month,$day,$year);
    else return mktime($hr,$min,$sec,$month,$day,$year);
}
}
?>

There ya go. Works well (altho' there is some superfluous code in there cuz the class will also do just single months). If anybody knows how to to put the css formatting code into the php file please let me know...I'd rather do that than have it in the css file (cuz've potential conflicts with JW's code that's gonna be distributed as standard). Those of you that are non-north american will appreciate that you can set which day starts the monthly calendar (monday or sunday).

CategoryUserContributions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki