(bug 737) only use the post-parse link placeholders within replaceInternalLinks().
[lhc/web/wiklou.git] / includes / SpecialLockdb.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 * Constructor
10 */
11 function wfSpecialLockdb()
12 {
13 global $wgUser, $wgOut, $wgRequest;
14
15 if ( ! $wgUser->isDeveloper() ) {
16 $wgOut->developerRequired();
17 return;
18 }
19 $action = $wgRequest->getVal( 'action' );
20 $f = new DBLockForm();
21
22 if ( "success" == $action ) { $f->showSuccess(); }
23 else if ( "submit" == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
24 else { $f->showForm( "" ); }
25 }
26
27 /**
28 *
29 * @package MediaWiki
30 * @subpackage SpecialPage
31 */
32 class DBLockForm {
33 var $reason = '';
34
35 function DBLockForm() {
36 global $wgRequest;
37 $this->reason = $wgRequest->getText( 'wpLockReason' );
38 }
39
40 function showForm( $err )
41 {
42 global $wgOut, $wgUser, $wgLang;
43
44 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
45 $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
46
47 if ( "" != $err ) {
48 $wgOut->setSubtitle( wfMsg( "formerror" ) );
49 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
50 }
51 $lc = wfMsg( "lockconfirm" );
52 $lb = wfMsg( "lockbtn" );
53 $elr = wfMsg( "enterlockreason" );
54 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
55 $action = $titleObj->escapeLocalURL( "action=submit" );
56
57 $wgOut->addHTML( <<<END
58 <form id="lockdb" method="post" action="{$action}">
59 {$elr}:
60 <textarea name="wpLockReason" rows="10" cols="60" wrap="virtual"></textarea>
61 <table border="0">
62 <tr>
63 <td align="right">
64 <input type="checkbox" name="wpLockConfirm" />
65 </td>
66 <td align="left">{$lc}</td>
67 </tr>
68 <tr>
69 <td>&nbsp;</td>
70 <td align="left">
71 <input type="submit" name="wpLock" value="{$lb}" />
72 </td>
73 </tr>
74 </table>
75 </form>
76 END
77 );
78
79 }
80
81 function doSubmit() {
82 global $wgOut, $wgUser, $wgLang, $wgRequest;
83 global $wgReadOnlyFile;
84
85 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) {
86 $this->showForm( wfMsg( "locknoconfirm" ) );
87 return;
88 }
89 $fp = fopen( $wgReadOnlyFile, "w" );
90
91 if ( false === $fp ) {
92 $wgOut->fileNotFoundError( $wgReadOnlyFile );
93 return;
94 }
95 fwrite( $fp, $this->reason );
96 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
97 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
98 fclose( $fp );
99
100 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
101 $wgOut->redirect( $titleObj->getFullURL( "action=success" ) );
102 }
103
104 function showSuccess() {
105 global $wgOut, $wgUser;
106
107 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
108 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
109 $wgOut->addWikiText( wfMsg( "lockdbsuccesstext" ) );
110 }
111 }
112
113 ?>