Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
SpecialLockdb.php
Go to the documentation of this file.
1<?php
7namespaceMediaWiki\Specials;
8
9useMediaWiki\Exception\ErrorPageError;
10useMediaWiki\HTMLForm\HTMLForm;
11useMediaWiki\MainConfigNames;
12useMediaWiki\SpecialPage\FormSpecialPage;
13useMediaWiki\Status\Status;
14useMediaWiki\User\User;
15use Wikimedia\AtEase\AtEase;
16
24classSpecialLockdbextendsFormSpecialPage {
25
26publicfunction__construct() {
27 parent::__construct('Lockdb','siteadmin' );
28 }
29
31publicfunctiondoesWrites() {
32returnfalse;
33 }
34
36publicfunctionrequiresWrite() {
37returnfalse;
38 }
39
40publicfunctioncheckExecutePermissions(User $user ) {
41 parent::checkExecutePermissions( $user );
42 # If the lock file isn't writable, we can do sweet bugger all
43if ( !is_writable( dirname( $this->getConfig()->get(MainConfigNames::ReadOnlyFile ) ) ) ) {
44thrownewErrorPageError('lockdb','lockfilenotwritable' );
45 }
46if ( file_exists( $this->getConfig()->get(MainConfigNames::ReadOnlyFile ) ) ) {
47thrownewErrorPageError('lockdb','databaselocked' );
48 }
49 }
50
52protectedfunctiongetFormFields() {
53return [
54'Reason' => [
55'type' =>'textarea',
56'rows' => 4,
57'label-message' =>'enterlockreason',
58 ],
59'Confirm' => [
60'type' =>'toggle',
61'label-message' =>'lockconfirm',
62 ],
63 ];
64 }
65
66protectedfunctionalterForm(HTMLForm $form ) {
67 $form->setWrapperLegend(false )
68 ->setHeaderHtml( $this->msg('lockdbtext' )->parseAsBlock() )
69 ->setSubmitTextMsg('lockbtn' );
70 }
71
73publicfunctiononSubmit( array $data ) {
74if ( !$data['Confirm'] ) {
75return Status::newFatal('locknoconfirm' );
76 }
77
78 AtEase::suppressWarnings();
79 $fp = fopen( $this->getConfig()->get(MainConfigNames::ReadOnlyFile ),'w' );
80 AtEase::restoreWarnings();
81
82if ( $fp ===false ) {
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...
86return Status::newFatal('lockfilenotwritable' );
87 }
88 fwrite( $fp, $data['Reason'] );
89 $timestamp =wfTimestampNow();
90 $contLang = $this->getContentLanguage();
91 fwrite( $fp,"\n<p>" . $this->msg('lockedbyandtime',
92 $this->getUser()->getName(),
93 $contLang->date( $timestamp,false,false ),
94 $contLang->time( $timestamp,false,false )
95 )->inContentLanguage()->text() ."</p>\n" );
96 fclose( $fp );
97
98return Status::newGood();
99 }
100
101publicfunctiononSuccess() {
102 $out = $this->getOutput();
103 $out->addSubtitle( $this->msg('lockdbsuccesssub' ) );
104 $out->addWikiMsg('lockdbsuccesstext' );
105 }
106
108protectedfunctiongetDisplayFormat() {
109return'ooui';
110 }
111
113protectedfunctiongetGroupName() {
114return'wiki';
115 }
116}
117
119class_alias( SpecialLockdb::class,'SpecialLockdb' );
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
DefinitionGlobalFunctions.php:1329
MediaWiki\Exception\ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
DefinitionErrorPageError.php:21
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
DefinitionHTMLForm.php:195
MediaWiki\HTMLForm\HTMLForm\setWrapperLegend
setWrapperLegend( $legend)
Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element.
DefinitionHTMLForm.php:1721
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
DefinitionMainConfigNames.php:22
MediaWiki\MainConfigNames\ReadOnlyFile
const ReadOnlyFile
Name constant for the ReadOnlyFile setting, for use with Config::get()
DefinitionMainConfigNames.php:3580
MediaWiki\SpecialPage\FormSpecialPage
Special page which uses an HTMLForm to handle processing.
DefinitionFormSpecialPage.php:26
MediaWiki\SpecialPage\SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
DefinitionSpecialPage.php:884
MediaWiki\SpecialPage\SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
DefinitionSpecialPage.php:949
MediaWiki\SpecialPage\SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
DefinitionSpecialPage.php:985
MediaWiki\SpecialPage\SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
DefinitionSpecialPage.php:874
MediaWiki\SpecialPage\SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
DefinitionSpecialPage.php:924
MediaWiki\SpecialPage\SpecialPage\getName
getName()
Get the canonical, unlocalized name of this special page without namespace.
DefinitionSpecialPage.php:211
MediaWiki\Specials\SpecialLockdb
A form to make the database read-only (eg for maintenance purposes).
DefinitionSpecialLockdb.php:24
MediaWiki\Specials\SpecialLockdb\__construct
__construct()
DefinitionSpecialLockdb.php:26
MediaWiki\Specials\SpecialLockdb\checkExecutePermissions
checkExecutePermissions(User $user)
Called from execute() to check if the given user can perform this action.
DefinitionSpecialLockdb.php:40
MediaWiki\Specials\SpecialLockdb\getDisplayFormat
getDisplayFormat()
Get display format for the form.See HTMLForm documentation for available values.1....
DefinitionSpecialLockdb.php:108
MediaWiki\Specials\SpecialLockdb\getFormFields
getFormFields()
Get an HTMLForm descriptor array.array
DefinitionSpecialLockdb.php:52
MediaWiki\Specials\SpecialLockdb\onSuccess
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
DefinitionSpecialLockdb.php:101
MediaWiki\Specials\SpecialLockdb\requiresWrite
requiresWrite()
Whether this action requires the wiki not to be locked, default to requiresPost()bool
DefinitionSpecialLockdb.php:36
MediaWiki\Specials\SpecialLockdb\onSubmit
onSubmit(array $data)
Process the form on submission.bool|string|array|Status As documented for HTMLForm::trySubmit.
DefinitionSpecialLockdb.php:73
MediaWiki\Specials\SpecialLockdb\doesWrites
doesWrites()
Indicates whether POST requests to this special page require write access to the wiki....
DefinitionSpecialLockdb.php:31
MediaWiki\Specials\SpecialLockdb\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
DefinitionSpecialLockdb.php:113
MediaWiki\Specials\SpecialLockdb\alterForm
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
DefinitionSpecialLockdb.php:66
MediaWiki\Status\Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
DefinitionStatus.php:44
MediaWiki\User\User
User class for the MediaWiki software.
DefinitionUser.php:109
MediaWiki\Specials

[8]ページ先頭

©2009-2025 Movatter.jp