-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpecialViewWikitext.php
More file actions
66 lines (62 loc) · 2.58 KB
/
SpecialViewWikitext.php
File metadata and controls
66 lines (62 loc) · 2.58 KB
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
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is a MediaWiki extension. It is not a valid entry point' );
}
class SpecialViewWikitext extends SpecialPage {
function __construct( ) {
parent::__construct( 'ViewWikitext' );
}
function execute( $par ) {
$this->setHeaders();
$output = $this->getOutput();
global $wgScript;
$request = $this->getRequest();
if ( !$par ) {
$par = $request->getVal( 'page' );
}
$this->getOutput()->addHTML(
Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'viewwikitext-form1' ) ) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
Xml::fieldset( $this->msg( 'viewwikitext-lookup-page' )->text() ) .
Xml::inputLabel( $this->msg( 'viewwikitext-page-lookup' )->text(), 'page', 'username', 30, str_replace( '_', ' ', $par ), array( 'autofocus' => true ) ) . ' ' .
Xml::submitButton( $this->msg( 'htmlform-submit' )->text() ) .
Html::closeElement( 'fieldset' ) .
Html::closeElement( 'form' ) . "\n"
);
if ( $par ) {
$par = str_replace( '_', ' ', $par );
$title = Title::newFromText( $par );
if ( !$title ) {
$output->addWikiMsgArray( 'viewwikitext-badtitle', $par );
} else {
$revision = Revision::newFromTitle( $title );
if ( !$revision ) {
$output->addWikiMsgArray( 'viewwikitext-badtitle', $par );
} else {
$outputText = "'''<big>";
$outputText .= wfMessage( 'viewwikitext-intro', $par )->plain();
$outputText .= "</big>'''<br/><br/>";
$output->addWikitext( $outputText );
$content = $revision->getContent( Revision::FOR_THIS_USER, $this->getUser() );
$text = ContentHandler::getContentText( $content );
$pageLang = $title->getPageLanguage();
$params = array(
'id' => 'wpTextbox1',
'name' => 'wpTextbox1',
'cols' => $this->getUser()->getOption( 'cols' ),
'rows' => $this->getUser()->getOption( 'rows' ),
'readonly' => 'readonly',
'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
);
$output->addHTML( Html::element( 'textarea', $params, $text ) );
}
}
}
return;
}
function getRobotPolicy() {
global $wgViewWikitextRobotPolicy;
return $wgViewWikitextRobotPolicy;
}
}