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