Difference between revisions of "Extension:When.php"
From Organic Design wiki
m |
(rm trailing ?>) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | <? | + | <?php |
− | # Extension:When{{ | + | # Extension:When{{php}}{{Category:Extensions|When}} |
# - See http://www.mediawiki.org/Extension:When for installation and usage details | # - See http://www.mediawiki.org/Extension:When for installation and usage details | ||
+ | # - Started 2007-04-27 | ||
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html) | # - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html) | ||
+ | # - Author: http://www.organicdesign.co.nz/nad | ||
+ | |||
+ | if (!defined('MEDIAWIKI')) die('Not an entry point.'); | ||
+ | |||
+ | define('WHEN_VERSION', '1.0.1, 2007-05-10'); | ||
+ | $wgExtensionCredits['parserhook'][] = array( | ||
+ | 'name' => 'When', | ||
+ | 'author' => '[http://www.organicdesign.co.nz/nad User:Nad]', | ||
+ | 'description' => 'adds a new parser function called #when which expands to easily queryable time categorisation', | ||
+ | 'url' => 'http://www.mediawiki.org/wiki/Extension:When', | ||
+ | 'version' => WHEN_VERSION | ||
+ | ); | ||
+ | |||
$wgExtensionFunctions[] = 'wfSetupWhen'; | $wgExtensionFunctions[] = 'wfSetupWhen'; | ||
$wgHooks['LanguageGetMagic'][] = 'wfWhenLanguageGetMagic'; | $wgHooks['LanguageGetMagic'][] = 'wfWhenLanguageGetMagic'; | ||
Line 26: | Line 40: | ||
return true; | return true; | ||
} | } | ||
− |
Latest revision as of 19:45, 28 December 2008
<?php
- Extension:WhenTemplate:Php
- - See http://www.mediawiki.org/Extension:When for installation and usage details
- - Started 2007-04-27
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: http://www.organicdesign.co.nz/nad
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('WHEN_VERSION', '1.0.1, 2007-05-10');
$wgExtensionCredits['parserhook'][] = array( 'name' => 'When', 'author' => 'User:Nad', 'description' => 'adds a new parser function called #when which expands to easily queryable time categorisation', 'url' => 'http://www.mediawiki.org/wiki/Extension:When', 'version' => WHEN_VERSION );
$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; }