Calendar

 'SimpleCalendar',	'author'      => 'Aran Dunkley',	'description' => 'A simple calendar extension',	'url'         => 'http://www.mediawiki.org/wiki/Extension:SimpleCalendar',	'version'     => SIMPLECALENDAR_VERSION ); class SimpleCalendar { function __construct { global $wgExtensionFunctions; $wgExtensionFunctions[] = array( $this, 'setup' ); Hooks::register( 'LanguageGetMagic', $this ); }	public function onLanguageGetMagic( &$magicWords, $langCode = 0 ) { $magicWords['calendar'] = array( 0, 'calendar' ); return true; }	public function setup { global $wgParser, $wgResourceModules, $wgExtensionAssetsPath; // Register the parser-function $wgParser->setFunctionHook( 'calendar', array( $this, 'render' ) ); // Add CSS $path = $wgExtensionAssetsPath. '/' . basename( __DIR__ ); $wgResourceModules['ext.ajaxcomments'] = array(			'styles'       => array( 'simplecalendar.css' ),			'localBasePath'  => __DIR__,			'remoteBasePath' => $path,		); }	/**	 * Expands the "calendar" magic word to a table of all the individual month tables */	public function render( $parser ) { $parser->disableCache; // Retrieve args $argv = array; foreach ( func_get_args as $arg ) { if ( !is_object( $arg ) ) { if ( preg_match( '/^(.+?)\s*=\s*(.+)$/', $arg, $match ) ) { $argv[$match[1]] = $match[2]; }			}		}		// Set options to defaults or specified values $f = isset( $argv['format'] )    ? $argv['format']                : ( strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? '%#d %B %Y' : '%e %B %Y' ); $df = isset( $argv['dayformat'] ) ? $argv['dayformat']             : false; $p = isset( $argv['title'] )     ? $argv['title']. '/'           : '';		$q  = isset( $argv['query'] )     ? $argv['query']. '&action=edit' : 'action=edit'; $y = isset( $argv['year'] )      ? $argv['year']                  : date( 'Y' ); // If a month is specified, return only that month's table if ( isset( $argv['month'] ) ) { $m = $argv['month']; $table = $this->renderMonth( strftime( '%m', strtotime( "$y-$m-01" ) ), $y, $p, $q, $f, $df ); }		// Otherwise start month at 1 and build the main container table else { $m = 1; $table = " \n"; }		return array( $table, 'isHTML' => true, 'noparse' => true ); }	/**	 * Return a calendar table of the passed month and year */	private function renderMonth( $m, $y, $prefix, $query, $format, $dayformat ) { $thisDay = date( 'd' ); $thisMonth = date( 'n' ); $thisYear = date( 'Y' ); if ( !$d = date( 'w', $ts = mktime( 0, 0, 0, $m, 1, $y ) ) ) { $d = 7; }		$month = wfMessage( strtolower( strftime( '%B', $ts ) ) )->text; $days = array; foreach ( array( 'M', 'T', 'W', 'T', 'F', 'S', 'S' ) as $i => $day ) { $days[] = $dayformat ? wfMessage( strftime( $dayformat, mktime( 0, 0, 0, 2, $i, 2000 ) ) )->text : $day; }		$table = "\n "; return $table; } } new SimpleCalendar;