Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SpecialLockdb.php

Go to the documentation of this file.
00001 <?php 00002 00003 function wfSpecialLockdb() 00004 { 00005 global $wgUser, $wgOut, $wgRequest; 00006 00007 if ( ! $wgUser->isDeveloper() ) { 00008 $wgOut->developerRequired(); 00009 return; 00010 } 00011 $action = $wgRequest->getText( 'action' ); 00012 $f = new DBLockForm(); 00013 00014 if ( "success" == $action ) { $f->showSuccess(); } 00015 else if ( "submit" == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); } 00016 else { $f->showForm( "" ); } 00017 } 00018 00019 class DBLockForm { 00020 var $reason = ""; 00021 00022 function DBLockForm() { 00023 global $wgRequest; 00024 $this->reason = $wgRequest->getText( 'wpLockReason' ); 00025 } 00026 00027 function showForm( $err ) 00028 { 00029 global $wgOut, $wgUser, $wgLang; 00030 00031 $wgOut->setPagetitle( wfMsg( "lockdb" ) ); 00032 $wgOut->addWikiText( wfMsg( "lockdbtext" ) ); 00033 00034 if ( "" != $err ) { 00035 $wgOut->setSubtitle( wfMsg( "formerror" ) ); 00036 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" ); 00037 } 00038 $lc = wfMsg( "lockconfirm" ); 00039 $lb = wfMsg( "lockbtn" ); 00040 $elr = wfMsg( "enterlockreason" ); 00041 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" ); 00042 $action = $titleObj->escapeLocalURL( "action=submit" ); 00043 00044 $wgOut->addHTML( "<p> 00045 <form id=\"lockdb\" method=\"post\" action=\"{$action}\"> 00046 {$elr}: 00047 <textarea name=\"wpLockReason\" rows=10 cols=60 wrap=virtual> 00048 </textarea> 00049 <table border=0><tr> 00050 <td align=right> 00051 <input type=checkbox name=\"wpLockConfirm\"> 00052 </td> 00053 <td align=left>{$lc}<td> 00054 </tr><tr> 00055 <td>&nbsp;</td><td align=left> 00056 <input type=submit name=\"wpLock\" value=\"{$lb}\"> 00057 </td></tr></table> 00058 </form>\n" ); 00059 00060 } 00061 00062 function doSubmit() 00063 { 00064 global $wgOut, $wgUser, $wgLang, $wgRequest; 00065 global $wgReadOnlyFile; 00066 00067 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) { 00068 $this->showForm( wfMsg( "locknoconfirm" ) ); 00069 return; 00070 } 00071 $fp = fopen( $wgReadOnlyFile, "w" ); 00072 00073 if ( false === $fp ) { 00074 $wgOut->fileNotFoundError( $wgReadOnlyFile ); 00075 return; 00076 } 00077 fwrite( $fp, $this->reason ); 00078 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " . 00079 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" ); 00080 fclose( $fp ); 00081 00082 $titleObj = Title::makeTitle( NS_SPECIAL, "Lockdb" ); 00083 $wgOut->redirect( $titleObj->getFullURL( "action=success" ) ); 00084 } 00085 00086 function showSuccess() 00087 { 00088 global $wgOut, $wgUser; 00089 00090 $wgOut->setPagetitle( wfMsg( "lockdb" ) ); 00091 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) ); 00092 $wgOut->addWikiText( wfMsg( "lockdbsuccesstext" ) ); 00093 } 00094 } 00095 00096 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7