User:Gardimuer/monaco.js

//============================================================= // BEGIN Countdown Extension // source: http://www.mediawiki.org/wiki/Extension:EventCountdown //=============================================================

<?php
 * 1) EventCountdown extension
 * 2) Copyright 2006 Matt Curtis (matt.r.curtis at gmail.com)
 * 3) Minor edits by Kaolin Fire to get rid of undefined index warnings
 * 4) License:
 * 5)  This program is free software; you can redistribute it and/or modify
 * 6)  it under the terms of the GNU General Public License as published by
 * 7)  the Free Software Foundation; either version 2 of the License, or
 * 8)  (at your option) any later version.
 * 9)  This program is distributed in the hope that it will be useful,
 * 10)  but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 11)  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 12)  GNU General Public License for more details.
 * 13)  You should have received a copy of the GNU General Public License
 * 14)  along with this program; if not, write to the Free Software
 * 15)  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 16) Usage:
 * 17) The tag is replaced with the number of days until the date.
 * 18) Formatting uses php's strtotime, so it's quite flexible on the input.
 * 19) The optional 'in="days"' argument will append "day" or "days" as
 * 20) appropriate.
 * 21)   E3 is 10 May 2005 away.
 * 22) The tag will show its contents only until the
 * 23) date arrives. The contents can be wikitext. For example:
 * 24)   Get ready for E3!
 * 25) They are most useful when combined. For example, to display "x days until
 * 26) E3 2006" with a link to E3:
 * 27)    10-May-2006
 * 28)     until E3 2006
 * 29) To activate the extension, include it from your LocalSettings.php
 * 30) with: require_once("extensions/EventCountdown.php");
 * 1) The tag will show its contents only until the
 * 2) date arrives. The contents can be wikitext. For example:
 * 3)   Get ready for E3!
 * 4) They are most useful when combined. For example, to display "x days until
 * 5) E3 2006" with a link to E3:
 * 6)    10-May-2006
 * 7)     until E3 2006
 * 8) To activate the extension, include it from your LocalSettings.php
 * 9) with: require_once("extensions/EventCountdown.php");
 * 1)     until E3 2006
 * 2) To activate the extension, include it from your LocalSettings.php
 * 3) with: require_once("extensions/EventCountdown.php");
 * 1) with: require_once("extensions/EventCountdown.php");

$wgExtensionFunctions[] = "wfEventCountdownExtension"; function wfEventCountdownExtension { global $wgParser; # register the extension with the WikiText parser # the first parameter is the name of the new tag. # In this case it defines the tag ...        # the second parameter is the callback function for # processing the text between the tags $wgParser->setHook( "daysuntil", "runDaysUntil" ); $wgParser->setHook( "eventcountdown", "runShowEventCountdown" ); } function runDaysUntil( $input, $argv ) { $now = time; $then = strtotime($input); $daysUntil = getDaysBetween($now, $then); $output = $daysUntil; if (!array_key_exists("in",$argv)) return $output; switch ($argv["in"]) { case "days": if ($daysUntil == 1) { $output .= " day"; }               else { $output .= " days"; }               break; default: }       return $output; } function runShowEventCountdown( $input, $argv ) { $now = time; if (!array_key_exists("date",$argv)) return ""; $then = strtotime($argv["date"]); $daysUntil = getDaysBetween($now, $then); $output = ""; if ($daysUntil > 0) { global $wgOut; $output = $wgOut->parse($input, false); }       return $output; } function getDaysBetween($date1, $date2) { $deltaSeconds = $date2 - $date1; $deltaDays = $deltaSeconds / (60 * 60 * 24); return ceil($deltaDays); }

//============================================================= // END Countdown Extension // source: http://www.mediawiki.org/wiki/Extension:EventCountdown //=============================================================