Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7420792
DefaultTextConstraint.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DefaultTextConstraint.php
View Options
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace
MediaWiki\EditPage\Constraint
;
use
MediaWiki\Title\Title
;
use
StatusValue
;
/**
* Don't save a new page if it's blank or if it's a MediaWiki:
* message with content equivalent to default (allow empty pages
* in this case to disable messages, see T52124)
*
* @since 1.36
* @internal
* @author DannyS712
*/
class
DefaultTextConstraint
implements
IEditConstraint
{
private
Title
$title
;
private
bool
$allowBlank
;
private
string
$userProvidedText
;
private
string
$result
;
/**
* @param Title $title
* @param bool $allowBlank
* @param string $userProvidedText
*/
public
function
__construct
(
Title
$title
,
bool
$allowBlank
,
string
$userProvidedText
)
{
$this
->
title
=
$title
;
$this
->
allowBlank
=
$allowBlank
;
$this
->
userProvidedText
=
$userProvidedText
;
}
public
function
checkConstraint
():
string
{
$defaultMessageText
=
$this
->
title
->
getDefaultMessageText
();
if
(
$this
->
title
->
getNamespace
()
===
NS_MEDIAWIKI
&&
$defaultMessageText
!==
false
)
{
$defaultText
=
$defaultMessageText
;
}
else
{
$defaultText
=
''
;
}
if
(
!
$this
->
allowBlank
&&
$this
->
userProvidedText
===
$defaultText
)
{
$this
->
result
=
self
::
CONSTRAINT_FAILED
;
}
else
{
$this
->
result
=
self
::
CONSTRAINT_PASSED
;
}
return
$this
->
result
;
}
public
function
getLegacyStatus
():
StatusValue
{
$statusValue
=
StatusValue
::
newGood
();
if
(
$this
->
result
===
self
::
CONSTRAINT_FAILED
)
{
$statusValue
->
fatal
(
'blankarticle'
);
$statusValue
->
setResult
(
false
,
self
::
AS_BLANK_ARTICLE
);
}
return
$statusValue
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 05:08 (1 d, 3 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d9/3b/10fdb4c93ee05398030d79d20d10
Default Alt Text
DefaultTextConstraint.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment