Extension:When.php

From Organic Design wiki
Revision as of 21:23, 26 April 2007 by Nad (talk | contribs) (New page: <? # Extension:When{{#Security:*|dev}}{{#Security:view|*}}{{php}} # ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?

  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 .= '[[Category:'.strftime("%$f",$time).']$
       return $cats;
       }

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

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

?>