Extension:When.php

From Organic Design wiki
Revision as of 05:51, 10 May 2007 by Nad (talk | contribs) (When.php moved to Extension:When.php)

<?

  1. Extension:When{{#Security:*|dev}}{{#Security:view|*}}Template:Php
  2. - See http://www.mediawiki.org/Extension:When for installation and usage details
  3. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)

$wgExtensionFunctions[] = 'wfSetupWhen'; $wgHooks['LanguageGetMagic'][] = 'wfWhenLanguageGetMagic';

function wfSetupWhen() {

       global $wgParser;
       $wgParser->setFunctionHook('when','wfExpandWhen');
       return true;
       }

function wfExpandWhen(&$parser,$when) {

       $time = strtotime($when);
       $cats = ;
       $formats = array('A','d','B','Y');
       if (ereg(':|[ap]m',$when)) array_unshift($formats,'T');
       foreach($formats as $f) $cats .= ;
       return $cats;
       }

function wfWhenLanguageGetMagic(&$magicWords,$langCode = 0) {

       $magicWords['when'] = array(0,'when');
       return true;
       }

?>