-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetPageInfo.body.php
98 lines (63 loc) · 1.72 KB
/
GetPageInfo.body.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Main class for GetPageInfo MediaWiki extension
*/
class GetPageInfo {
public static function executeGetTitle( $parser, $frame, $args ) {
$fulltitle = "";
if ( isset( $args[0] ) ) {
$fulltitle = trim( $frame->expand( $args[0] ) );
}
$extra = "";
if (isset( $args[1] ) ) {
$extra = trim( $frame->expand( $args[1] ) );
}
$title = "";
if ( is_object( Title::newFromText( $fulltitle ) ) ) {
$title = Title::newFromText( $fulltitle )->getText();
}
if ( isset( $args[3]) ) {
$show = trim( $frame->expand( $args[3] ) );
if ( empty( $show ) ) {
$show = $title;
}
} else {
$show = $title;
}
if ( $extra == 'link' ) {
if ( isset( $args[2]) ) {
global $wgServer;
global $wgScript;
$revid = trim( $frame->expand( $args[2] ) ) ;
if ( empty( $revid ) ) {
$title = "[[$fulltitle|$show]]";
} else {
$urlfulltitle = urlencode( $fulltitle );
$title = "[".$wgServer.$wgScript."?title=".$urlfulltitle."&oldid=".$revid." ".$show."]";
}
} else {
$title = "[[$fulltitle|$show]]";
}
}
return( $title );
}
public static function executeGetNS( $parser, $frame, $args ) {
$fulltitle = trim( $frame->expand( $args[0] ) );
$ns = "";
if ( is_object( Title::newFromText( $fulltitle ) ) ) {
$ns = Title::newFromText( $fulltitle )->getNsText();
}
return( $ns );
}
public static function executeGetSummary( $parser, $frame, $args ) {
$revid = trim( $frame->expand( $args[0] ) );
$summary = "";
if ( is_numeric( $revid ) ) {
if ( is_object( Revision::newFromId( $revid ) ) ) {
$revobj = Revision::newFromId( $revid );
$summary = $revobj->getComment();
}
}
return( $summary );
}
}