Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| UploadSourceField | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getLabelHtml | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
12 | |||
| getSize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials\FormFields; |
| 8 | |
| 9 | use MediaWiki\Html\Html; |
| 10 | use MediaWiki\HTMLForm\Field\HTMLTextField; |
| 11 | |
| 12 | /** |
| 13 | * A form field that contains a radio box in the label |
| 14 | */ |
| 15 | class UploadSourceField extends HTMLTextField { |
| 16 | |
| 17 | /** |
| 18 | * @param array $cellAttributes |
| 19 | * @return string |
| 20 | */ |
| 21 | public function getLabelHtml( $cellAttributes = [] ) { |
| 22 | $id = $this->mParams['id']; |
| 23 | $label = Html::rawElement( 'label', [ 'for' => $id ], $this->mLabel ); |
| 24 | |
| 25 | if ( !empty( $this->mParams['radio'] ) ) { |
| 26 | $radioId = $this->mParams['radio-id'] ?? |
| 27 | // Old way. For the benefit of extensions that do not define |
| 28 | // the 'radio-id' key. |
| 29 | 'wpSourceType' . $this->mParams['upload-type']; |
| 30 | |
| 31 | $attribs = [ |
| 32 | 'name' => 'wpSourceType', |
| 33 | 'type' => 'radio', |
| 34 | 'id' => $radioId, |
| 35 | 'value' => $this->mParams['upload-type'], |
| 36 | ]; |
| 37 | |
| 38 | if ( !empty( $this->mParams['checked'] ) ) { |
| 39 | $attribs['checked'] = 'checked'; |
| 40 | } |
| 41 | |
| 42 | $label .= Html::element( 'input', $attribs ); |
| 43 | } |
| 44 | |
| 45 | return Html::rawElement( 'td', [ 'class' => 'mw-label' ] + $cellAttributes, $label ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return int |
| 50 | */ |
| 51 | public function getSize() { |
| 52 | return $this->mParams['size'] ?? 60; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** @deprecated class alias since 1.46 */ |
| 57 | class_alias( UploadSourceField::class, 'UploadSourceField' ); |