Extension:SimpleCalendar

This is a very simple calendar extension which renders a table of all the months in the year with each day being a wiki article (see Calendar for example). Days which have nothing in them show up as a red link, clicking on it will create a new article as usual. It installs as a parser function, so the following syntax is used:
 *  

An optional name can be added so that different users or groups can have their own calendars, this could be used in conjunction with other functions, eg:
 *  

If a second optional parameter is supplied, it specifies the year, otherwise the current year is used:
 *  

If a third parameter is passed, it specifies the month which means to only render the table for that month, rather than all the month tables of the year. The month can be numeric or the short or long textual name, eg:
 *  
 *   - this example renders the May table for the current year


 * Note: the examples above use the CURRENTUSER variable which is not installed by default. See Extension:Variables if you're interested in adding variables.

CSS Styles
The generated calendar table uses CSS to allow customization of the look. Here's the CSS we use which you can use and adjust: table.calendar         { margin: 0; padding: 10px; } table.calendar td      { margin: 0; padding: 2px; vertical-align: top; } table.month .heading td { padding:2px; background-color:#d4d4d4; color:#aaa; text-align:center; font-size:120%; font-weight:bold; } table.month .dow td    { color:#aaa; text-align:center; font-size:110%; } table.month td.today   { background-color:#ddd; } table.month td { border: none; margin: 0; padding: 1pt 1.5pt; font-weight: bold; font-size: 8pt; text-align: right; background-color: #eee; }

Installation
Save the following code as a file in your extensions directory and include it from your LocalSettings.php file as usual. You might want to check OrganicDesign:Extension:SimpleCalendar.php to see if a later version is available. setFunctionHook('calendar','wfRenderCalendar'); return true; }

function wfRenderCalendar(&$parser,$p = '',$y = false,$m = false) { if ($p) $p .= '/'; if ($y == false) $y = date('Y'); if ($m) return wfRenderMonth(strftime('%m',strtotime("$y-$m-01")),$y,$p); $m = 1; $table = "{| class=\"calendar\"\n"; for ($rows = 3; $rows--; $table .= "|-\n") for ($cols = 0; $cols < 4; $cols++) $table .= '|'.wfRenderMonth($m++,$y,$p)."\n"; return "$table\n|}\n"; }
 * 1) Renders a table of all the individual month tables

function wfRenderMonth($m,$y,$prefix = '') { $thisDay  = date('d'); $thisMonth = date('n'); $thisYear = date('Y'); if (!$d = date('w',$ts = mktime(0,0,0,$m,1,$y))) $d = 7; $month = strftime('%B',$ts); $table = "\n{| class=\"month\"\n|- class=\"heading\"\n|colspan=\"7\"|$month\n|- class=\"dow\"\n"; $table .= "|M||T||W||T||F||S||S\n"; if ($d > 1) $table .= "|-".str_repeat("\n| \n",$d-1); for ($i = $day = $d; $day < 32; $i++) { $day = $i - $d + 1; $dd = $day < 10 ? "0$day" : $day; if ($day < 29 or checkdate($m,$day,$y)) { if ($i%7 == 1) $table .= "\n|-\n"; $t = ($day == $thisDay and $m == $thisMonth and $y == $thisYear) ? ' class="today"' : ''; $table .= "|$t|$day\n"; }               }        return "$table\n|}"; } ?>
 * 1) Return a calendar table of the passed month and year