-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetPageInfo.php
42 lines (30 loc) · 1.17 KB
/
GetPageInfo.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
<?php
if (!defined('MEDIAWIKI')) {
die('Not an entry point.');
}
$GLOBALS['wgExtensionCredits']['parserhook'][] = array(
'path' => __FILE__,
'name' => "GetPageInfo",
'description' => "Print some info or metadata of a wiki page",
'version' => 0.1,
'author' => "@toniher",
'url' => "https://mediawiki.org/wiki/User:Toniher",
);
# Define a setup function
$GLOBALS['wgHooks']['ParserFirstCallInit'][] = 'wfGetPageProp_Setup';
# Add a hook to initialise the magic word
$GLOBALS['wgHooks']['LanguageGetMagic'][] = 'wfGetPageProp_Magic';
# Autoload
$GLOBALS['wgAutoloadClasses']['GetPageInfo'] = __DIR__ . '/GetPageInfo.body.php';
function wfGetPageProp_Setup( &$parser ) {
$parser->setFunctionHook( 'getTitle', 'GetPageInfo::executeGetTitle', SFH_OBJECT_ARGS );
$parser->setFunctionHook( 'getNS', 'GetPageInfo::executeGetNS', SFH_OBJECT_ARGS );
$parser->setFunctionHook( 'getSummary', 'GetPageInfo::executeGetSummary', SFH_OBJECT_ARGS );
return true;
}
function wfGetPageProp_Magic( &$magicWords, $langCode ) {
$magicWords['getTitle'] = array( 0, 'getTitle' );
$magicWords['getNS'] = array( 0, 'getNS' );
$magicWords['getSummary'] = array( 0, 'getSummary' );
return true;
}