Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427383
HTMLJsSelectToInputField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HTMLJsSelectToInputField.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\Utilities
;
use
MediaWiki\HTMLForm\Field\HTMLTextField
;
/**
* Implementation of JsSelectToInput class which is compatible with MediaWiki's preferences system
* @author Niklas Laxström
* @copyright Copyright © 2010 Niklas Laxström
* @license GPL-2.0-or-later
*/
class
HTMLJsSelectToInputField
extends
HTMLTextField
{
/** @inheritDoc */
public
function
getInputHTML
(
$value
):
string
{
$input
=
parent
::
getInputHTML
(
$value
);
if
(
isset
(
$this
->
mParams
[
'select'
]
)
)
{
/** @var JsSelectToInput $select */
$select
=
$this
->
mParams
[
'select'
];
$input
=
$select
->
getHtmlAndPrepareJS
()
.
'<br />'
.
$input
;
}
return
$input
;
}
/** @return string[] */
protected
function
tidy
(
string
$value
):
array
{
$value
=
array_map
(
'trim'
,
explode
(
','
,
$value
)
);
$value
=
array_unique
(
array_filter
(
$value
)
);
return
$value
;
}
/** @inheritDoc */
public
function
validate
(
$value
,
$alldata
)
{
$p
=
parent
::
validate
(
$value
,
$alldata
);
if
(
$p
!==
true
)
{
return
$p
;
}
if
(
!
isset
(
$this
->
mParams
[
'valid-values'
]
)
)
{
return
true
;
}
if
(
$value
===
'default'
)
{
return
true
;
}
$codes
=
$this
->
tidy
(
$value
);
$valid
=
array_flip
(
$this
->
mParams
[
'valid-values'
]
);
foreach
(
$codes
as
$code
)
{
if
(
!
isset
(
$valid
[
$code
]
)
)
{
return
wfMessage
(
'translate-pref-editassistlang-bad'
,
$code
)->
parseAsBlock
();
}
}
return
true
;
}
/** @inheritDoc */
public
function
filter
(
$value
,
$alldata
)
{
$value
=
parent
::
filter
(
$value
,
$alldata
);
return
implode
(
', '
,
$this
->
tidy
(
$value
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:33 (1 d, 8 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9b/39/608f0618c36eca5feff08ebd634e
Default Alt Text
HTMLJsSelectToInputField.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment