Registered user can set their own language for the interface. See http://bugzilla...
[mediawiki.git] / includes / SpecialLockdb.php
blob363ac9141afeabcfdf4ecee1cb8b93fde1593afe
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
9 * Constructor
11 function wfSpecialLockdb()
13 global $wgUser, $wgOut, $wgRequest;
15 if ( ! $wgUser->isDeveloper() ) {
16 $wgOut->developerRequired();
17 return;
19 $action = $wgRequest->getText( 'action' );
20 $f = new DBLockForm();
22 if ( "success" == $action ) { $f->showSuccess(); }
23 else if ( "submit" == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
24 else { $f->showForm( "" ); }
27 /**
29 * @package MediaWiki
30 * @subpackage SpecialPage
32 class DBLockForm {
33 var $reason = '';
35 function DBLockForm() {
36 global $wgRequest;
37 $this->reason = $wgRequest->getText( 'wpLockReason' );
40 function showForm( $err )
42 global $wgOut, $wgUser, $wgLang;
44 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
45 $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
47 if ( "" != $err ) {
48 $wgOut->setSubtitle( wfMsg( "formerror" ) );
49 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
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" );
57 $wgOut->addHTML( "<p>
58 <form id=\"lockdb\" method=\"post\" action=\"{$action}\">
59 {$elr}:
60 <textarea name=\"wpLockReason\" rows=10 cols=60 wrap=virtual>
61 </textarea>
62 <table border=0><tr>
63 <td align=right>
64 <input type=checkbox name=\"wpLockConfirm\">
65 </td>
66 <td align=left>{$lc}<td>
67 </tr><tr>
68 <td>&nbsp;</td><td align=left>
69 <input type=submit name=\"wpLock\" value=\"{$lb}\">
70 </td></tr></table>
71 </form>\n" );
75 function doSubmit() {
76 global $wgOut, $wgUser, $wgLang, $wgRequest;
77 global $wgReadOnlyFile;
79 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) {
80 $this->showForm( wfMsg( "locknoconfirm" ) );
81 return;
83 $fp = fopen( $wgReadOnlyFile, "w" );
85 if ( false === $fp ) {
86 $wgOut->fileNotFoundError( $wgReadOnlyFile );
87 return;
89 fwrite( $fp, $this->reason );
90 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
91 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
92 fclose( $fp );
94 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" );
95 $wgOut->redirect( $titleObj->getFullURL( "action=success" ) );
98 function showSuccess() {
99 global $wgOut, $wgUser;
101 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
102 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
103 $wgOut->addWikiText( wfMsg( "lockdbsuccesstext" ) );