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