Difference between revisions of "Extension:When.php"
From Organic Design wiki
(New page: <? # Extension:When{{#Security:*|dev}}{{#Security:view|*}}{{php}} # ...) |
m |
||
Line 18: | Line 18: | ||
$formats = array('A','d','B','Y'); | $formats = array('A','d','B','Y'); | ||
if (ereg(':|[ap]m',$when)) array_unshift($formats,'T'); | if (ereg(':|[ap]m',$when)) array_unshift($formats,'T'); | ||
− | foreach($formats as $f) $cats .= '[[Category:'.strftime("%$f",$time).'] | + | foreach($formats as $f) $cats .= '[[Category:'.strftime("%$f",$time).']]'; |
return $cats; | return $cats; | ||
} | } |
Revision as of 21:24, 26 April 2007
<?
- Extension:When{{#Security:*|dev}}{{#Security:view|*}}Template:Php
- - See http://www.mediawiki.org/Extension:When for installation and usage details
- - 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; }
?>