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:
 *  

Also a second optional parameter allows the year to be specified, the current year is used if this is not supplied:
 *  

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 append it to your LocalSettings.php file as usual. You might want to check OrganicDesign:Extension:SimpleCalendar.php to see if a later version is available. <? $wgExtensionFunctions[]       = 'wfSetupSimpleCalendar'; $wgHooks['LanguageGetMagic'][] = 'wfCalendarLanguageGetMagic'; function wfCalendarLanguageGetMagic(&$magicWords,$langCode = 0) { $magicWords['calendar'] = array(0,'calendar'); return true; }

function wfSetupSimpleCalendar { global $wgParser; $wgParser->setFunctionHook('calendar','wfRenderCalendar'); return true; }

function wfRenderCalendar(&$parser,$p = '',$y = false) { if ($p) $p .= '/'; if ($y == false) $y = date('Y'); $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 = date('F',$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