Difference between revisions of "Extension:When.php"

From Organic Design wiki
m
(No difference)

Revision as of 05:51, 10 May 2007

<?

  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;
       }

?>