forked from bvibber/mediawiki-svn
/
Sort.php
48 lines (42 loc) · 1.15 KB
/
Sort.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Parser hook extension adds a <sort> tag to wiki markup
*
* @addtogroup Extensions
* @author Rob Church <robchur@gmail.com>
* @copyright © 2006 Rob Church
* @licence GNU General Public Licence 2.0
*/
if( defined( 'MEDIAWIKI' ) ) {
$wgAutoloadClasses['Sorter'] = dirname( __FILE__ ) . '/Sort.class.php';
$wgExtensionFunctions[] = 'efSort';
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Sort',
'author' => 'Rob Church',
'description' => 'Create simple sorted lists using <tt><sort></tt>',
'url' => 'http://www.mediawiki.org/wiki/Extension:Sort',
);
/**
* Register hook function
*/
function efSort() {
global $wgParser;
$wgParser->setHook( 'sort', 'efRenderSort' );
}
/**
* Hook callback for <sort>
*
* @param string $input Input text
* @param array $args Tag arguments
* @param Parser $parser Parent parser
* @return string
*/
function efRenderSort( $input, $args, &$parser ) {
$sorter = new Sorter( $parser );
$sorter->loadSettings( $args );
return $sorter->sort( $input );
}
} else {
echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
exit( 1 );
}