Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4051089
JsSelectToInput.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
JsSelectToInput.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\Utilities
;
use
MediaWiki\Context\RequestContext
;
use
MediaWiki\Xml\Xml
;
use
MediaWiki\Xml\XmlSelect
;
use
RuntimeException
;
/**
* Code for JavaScript enhanced \<option> selectors.
* @author Niklas Laxström
* @license GPL-2.0-or-later
*/
final
class
JsSelectToInput
{
/** Id of the text field where stuff is appended */
private
string
$targetId
;
private
XmlSelect
$select
;
public
function
__construct
(
XmlSelect
$select
)
{
$this
->
select
=
$select
;
}
public
function
setTargetId
(
string
$id
)
{
$this
->
targetId
=
$id
;
}
/**
* Returns the whole input element and injects needed JavaScript
* @return string Html code.
*/
public
function
getHtmlAndPrepareJS
():
string
{
$sourceId
=
$this
->
select
->
getAttribute
(
'id'
);
if
(
!
is_string
(
$sourceId
)
)
{
throw
new
RuntimeException
(
'ID needs to be specified for the selector'
);
}
RequestContext
::
getMain
()->
getOutput
()->
addModules
(
'ext.translate.selecttoinput'
);
$html
=
$this
->
select
->
getHTML
();
$html
.=
Xml
::
element
(
'input'
,
[
'type'
=>
'button'
,
'value'
=>
wfMessage
(
'translate-jssti-add'
)->
text
(),
'class'
=>
'mw-translate-jssti'
,
'data-translate-jssti-sourceid'
=>
$sourceId
,
'data-translate-jssti-targetid'
=>
$this
->
targetId
]
);
return
$html
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 15 2026, 17:46 (13 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cc/77/d26c1765069c97dccfe338e5442b
Default Alt Text
JsSelectToInput.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment