MediaWiki  1.23.1
SpecialLockdb.php
Go to the documentation of this file.
1 <?php
30  var $reason = '';
31 
32  public function __construct() {
33  parent::__construct( 'Lockdb', 'siteadmin' );
34  }
35 
36  public function requiresWrite() {
37  return false;
38  }
39 
40  public function checkExecutePermissions( User $user ) {
41  global $wgReadOnlyFile;
42 
43  parent::checkExecutePermissions( $user );
44  # If the lock file isn't writable, we can do sweet bugger all
45  if ( !is_writable( dirname( $wgReadOnlyFile ) ) ) {
46  throw new ErrorPageError( 'lockdb', 'lockfilenotwritable' );
47  }
48  }
49 
50  protected function getFormFields() {
51  return array(
52  'Reason' => array(
53  'type' => 'textarea',
54  'rows' => 4,
55  'vertical-label' => true,
56  'label-message' => 'enterlockreason',
57  ),
58  'Confirm' => array(
59  'type' => 'toggle',
60  'label-message' => 'lockconfirm',
61  ),
62  );
63  }
64 
65  protected function alterForm( HTMLForm $form ) {
66  $form->setWrapperLegend( false );
67  $form->setHeaderText( $this->msg( 'lockdbtext' )->parseAsBlock() );
68  $form->setSubmitTextMsg( 'lockbtn' );
69  }
70 
71  public function onSubmit( array $data ) {
72  global $wgContLang, $wgReadOnlyFile;
73 
74  if ( !$data['Confirm'] ) {
75  return Status::newFatal( 'locknoconfirm' );
76  }
77 
79  $fp = fopen( $wgReadOnlyFile, 'w' );
81 
82  if ( false === $fp ) {
83  # This used to show a file not found error, but the likeliest reason for fopen()
84  # to fail at this point is insufficient permission to write to the file...good old
85  # is_writable() is plain wrong in some cases, it seems...
86  return Status::newFatal( 'lockfilenotwritable' );
87  }
88  fwrite( $fp, $data['Reason'] );
90  fwrite( $fp, "\n<p>" . $this->msg( 'lockedbyandtime',
91  $this->getUser()->getName(),
92  $wgContLang->date( $timestamp, false, false ),
93  $wgContLang->time( $timestamp, false, false )
94  )->inContentLanguage()->text() . "</p>\n" );
95  fclose( $fp );
96 
97  return Status::newGood();
98  }
99 
100  public function onSuccess() {
101  $out = $this->getOutput();
102  $out->addSubtitle( $this->msg( 'lockdbsuccesssub' ) );
103  $out->addWikiMsg( 'lockdbsuccesstext' );
104  }
105 
106  protected function getGroupName() {
107  return 'wiki';
108  }
109 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
SpecialLockdb\__construct
__construct()
Definition: SpecialLockdb.php:32
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2573
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
Status\newGood
static newGood( $value=null)
Factory function for good results.
Definition: Status.php:77
FormSpecialPage
Special page which uses an HTMLForm to handle processing.
Definition: FormSpecialPage.php:31
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:139
SpecialLockdb\alterForm
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
Definition: SpecialLockdb.php:65
SpecialLockdb\requiresWrite
requiresWrite()
Whether this action requires the wiki not to be locked.
Definition: SpecialLockdb.php:36
$out
$out
Definition: UtfNormalGenerate.php:167
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
SpecialLockdb\$reason
$reason
Definition: SpecialLockdb.php:30
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2514
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
SpecialLockdb
A form to make the database readonly (eg for maintenance purposes).
Definition: SpecialLockdb.php:29
SpecialLockdb\onSuccess
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
Definition: SpecialLockdb.php:100
SpecialLockdb\getFormFields
getFormFields()
Get an HTMLForm descriptor array.
Definition: SpecialLockdb.php:50
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
SpecialLockdb\onSubmit
onSubmit(array $data)
Process the form on POST submission.
Definition: SpecialLockdb.php:71
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
SpecialLockdb\checkExecutePermissions
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
Definition: SpecialLockdb.php:40
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59
SpecialLockdb\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialLockdb.php:106
Status\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: Status.php:63
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms.
Definition: HTMLForm.php:100