*
* @return string Valid HTML.
*/
- abstract function getInputHTML( $value );
+ abstract public function getInputHTML( $value );
/**
* Same as getInputHTML, but returns an OOUI object.
* @param string $value
* @return OOUI\Widget|false
*/
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
return false;
}
*
* @return Message
*/
- function msg() {
+ public function msg() {
$args = func_get_args();
if ( $this->mParent ) {
* @param array $alldata The data collected from the form
* @return bool
*/
- function isHidden( $alldata ) {
+ public function isHidden( $alldata ) {
if ( !$this->mHideIf ) {
return false;
}
*
* @return bool True to cancel the submission
*/
- function cancelSubmit( $value, $alldata ) {
+ public function cancelSubmit( $value, $alldata ) {
return false;
}
* @return bool|string True on success, or String error to display, or
* false to fail validation without displaying an error.
*/
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
if ( $this->isHidden( $alldata ) ) {
return true;
}
return true;
}
- function filter( $value, $alldata ) {
+ public function filter( $value, $alldata ) {
if ( isset( $this->mFilterCallback ) ) {
$value = call_user_func( $this->mFilterCallback, $value, $alldata, $this->mParent );
}
* @param WebRequest $request
* @return string The value
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $request->getCheck( $this->mName ) ) {
return $request->getText( $this->mName );
} else {
* @since 1.22 The 'label' attribute no longer accepts raw HTML, use 'label-raw' instead
* @throws MWException
*/
- function __construct( $params ) {
+ public function __construct( $params ) {
$this->mParams = $params;
if ( isset( $params['parent'] ) && $params['parent'] instanceof HTMLForm ) {
*
* @return string Complete HTML table row.
*/
- function getTableRow( $value ) {
+ public function getTableRow( $value ) {
list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( $value );
$inputHtml = $this->getInputHTML( $value );
$fieldType = get_class( $this );
* @since 1.28
* @return string[]
*/
- function getNotices() {
+ public function getNotices() {
$notices = [];
if ( isset( $this->mParams['notice-message'] ) ) {
/**
* @return string HTML
*/
- function getLabel() {
+ public function getLabel() {
return is_null( $this->mLabel ) ? '' : $this->mLabel;
}
- function getLabelHtml( $cellAttributes = [] ) {
+ public function getLabelHtml( $cellAttributes = [] ) {
# Don't output a for= attribute for labels with no associated input.
# Kind of hacky here, possibly we don't want these to be <label>s at all.
$for = [];
return $html;
}
- function getDefault() {
+ public function getDefault() {
if ( isset( $this->mDefault ) ) {
return $this->mDefault;
} else {
* @param array $array
* @return array
*/
- static function forceToStringRecursive( $array ) {
+ public static function forceToStringRecursive( $array ) {
if ( is_array( $array ) ) {
return array_map( [ __CLASS__, 'forceToStringRecursive' ], $array );
} else {
*
* @param array $data
*/
- function filterDataForSubmit( $data );
+ public function filterDataForSubmit( $data );
}
return $field;
}
- function getButtons() {
+ public function getButtons() {
$buttons = '';
// IE<8 has bugs with <button>, so we'll need to avoid them.
* @param string $elementsType
* @return string
*/
- function getErrorsOrWarnings( $elements, $elementsType ) {
+ public function getErrorsOrWarnings( $elements, $elementsType ) {
if ( !in_array( $elementsType, [ 'error', 'warning' ] ) ) {
throw new DomainException( $elementsType . ' is not a valid type.' );
}
return '';
}
- function getHeaderText( $section = null ) {
+ public function getHeaderText( $section = null ) {
if ( is_null( $section ) ) {
// We handle $this->mHeader elsewhere, in getBody()
return '';
}
}
- function getBody() {
+ public function getBody() {
$fieldset = parent::getBody();
// FIXME This only works for forms with no subsections
if ( $fieldset instanceof OOUI\FieldsetLayout ) {
return $fieldset;
}
- function wrapForm( $html ) {
+ public function wrapForm( $html ) {
$form = new OOUI\FormLayout( $this->getFormAttributes() + [
'classes' => [ 'mw-htmlform-ooui' ],
'content' => new OOUI\HtmlSnippet( $html ),
return $field;
}
- function getHTML( $submitResult ) {
+ public function getHTML( $submitResult ) {
// This is required for VForm HTMLForms that use that style regardless
// of wgUseMediaWikiUIEverywhere (since they pre-date it).
// When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
return $attribs;
}
- function wrapForm( $html ) {
+ public function wrapForm( $html ) {
// Always discard $this->mWrapperLegend
return Html::rawElement( 'form', $this->getFormAttributes(), $html );
}
- function getButtons() {
+ public function getButtons() {
$buttons = '';
if ( $this->mShowSubmit ) {
class HTMLAutoCompleteSelectField extends HTMLTextField {
protected $autocomplete = [];
- function __construct( $params ) {
+ public function __construct( $params ) {
$params += [
'require-match' => false,
];
}
}
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $request->getCheck( $this->mName ) ) {
$val = $request->getText( $this->mName . '-select', 'other' );
}
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
return $attribs;
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$oldClass = $this->mClass;
$this->mClass = (array)$this->mClass;
* @param string $value
* @return false
*/
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
// To be implemented, for now override the function from HTMLTextField
return false;
}
* A checkbox field
*/
class HTMLCheckField extends HTMLFormField {
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
global $wgUseMediaWikiUIEverywhere;
if ( !empty( $this->mParams['invert'] ) ) {
*
* @return string
*/
- function getLabel() {
+ public function getLabel() {
if ( $this->mParent instanceof OOUIHTMLForm ) {
return $this->mLabel;
} elseif (
*
* @return bool
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
$invert = isset( $this->mParams['invert'] ) && $this->mParams['invert'];
// GetCheck won't work like we want for checks.
parent::__construct( $params );
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$rows = $this->mParams['rows'];
$columns = $this->mParams['columns'];
*
* @return string
*/
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$html = '';
$tableContents = '';
$rows = $this->mParams['rows'];
*
* @return string Complete HTML table row
*/
- function getTableRow( $value ) {
+ public function getTableRow( $value ) {
list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( $value );
$inputHtml = $this->getInputHTML( $value );
$fieldType = get_class( $this );
*
* @return array
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $this->isSubmitAttempt( $request ) ) {
// Checkboxes are just not added to the request arrays if they're not checked,
// so it's perfectly possible for there not to be an entry at all
}
}
- function getDefault() {
+ public function getDefault() {
if ( isset( $this->mDefault ) ) {
return $this->mDefault;
} else {
}
}
- function filterDataForSubmit( $data ) {
+ public function filterDataForSubmit( $data ) {
$columns = HTMLFormField::flattenOptions( $this->mParams['columns'] );
$rows = HTMLFormField::flattenOptions( $this->mParams['rows'] );
$res = [];
return $attribs;
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$datalist = new XmlSelect( false, $this->mName . '-datalist' );
$datalist->setTagName( 'datalist' );
$datalist->addOptions( $this->getOptions() );
return parent::getInputHTML( $value ) . $datalist->getHTML();
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
$disabled = false;
$allowedParams = [ 'tabindex' ];
$attribs = OOUI\Element::configFromHtmlAttributes(
return $ret;
}
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( !$request->getCheck( $this->mName ) ) {
return $this->getDefault();
}
return $date ? $this->formatDate( $date ) : $value;
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
* A field that will contain a numeric value
*/
class HTMLFloatField extends HTMLTextField {
- function getSize() {
+ public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
parent::__construct( $info );
}
- function getDefault() {
+ public function getDefault() {
$default = parent::getDefault();
if ( $default instanceof Closure ) {
$default = call_user_func( $default, $this->mParams );
* A field that must contain a number
*/
class HTMLIntField extends HTMLFloatField {
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
}
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
}
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
if ( isset( $this->mParams['dropdown'] ) ) {
$this->mParent->getOutput()->addModules( 'jquery.chosen' );
}
return $html;
}
- function formatOptions( $options, $value ) {
+ public function formatOptions( $options, $value ) {
$html = '';
$attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
*
* @return string
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $this->isSubmitAttempt( $request ) ) {
// Checkboxes are just not added to the request arrays if they're not checked,
// so it's perfectly possible for there not to be an entry at all
}
}
- function getDefault() {
+ public function getDefault() {
if ( isset( $this->mDefault ) ) {
return $this->mDefault;
} else {
}
}
- function filterDataForSubmit( $data ) {
+ public function filterDataForSubmit( $data ) {
$data = HTMLFormField::forceToStringRecursive( $data );
$options = HTMLFormField::flattenOptions( $this->getOptions() );
}
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
*
* @return string
*/
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$html = $this->formatOptions( $this->getOptions(), strval( $value ) );
return $html;
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
$options = [];
foreach ( $this->getOptions() as $label => $data ) {
$options[] = [
return true;
}
- function formatOptions( $options, $value ) {
+ public function formatOptions( $options, $value ) {
global $wgUseMediaWikiUIEverywhere;
$html = '';
* @param WebRequest $request
* @return string|MWRestrictions Restrictions object or original string if invalid
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( !$request->getCheck( $this->mName ) ) {
return $this->getDefault();
}
* @todo FIXME: If made 'required', only the text field should be compulsory.
*/
class HTMLSelectAndOtherField extends HTMLSelectField {
- function __construct( $params ) {
+ public function __construct( $params ) {
if ( array_key_exists( 'other', $params ) ) {
// Do nothing
} elseif ( array_key_exists( 'other-message', $params ) ) {
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$select = parent::getInputHTML( $value[1] );
$textAttribs = [
return "$select<br />\n$textbox";
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
return false;
}
*
* @return array("<overall message>","<select value>","<text field value>")
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $request->getCheck( $this->mName ) ) {
$list = $request->getText( $this->mName );
$text = $request->getText( $this->mName . '-other' );
return [ $final, $list, $text ];
}
- function getSize() {
+ public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
}
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
# HTMLSelectField forces $value to be one of the options in the select
# field, which is not useful here. But we do want the validation further up
# the chain
* A select dropdown field. Basically a wrapper for Xmlselect class
*/
class HTMLSelectField extends HTMLFormField {
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
if ( $p !== true ) {
}
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$select = new XmlSelect( $this->mName, $this->mID, strval( $value ) );
if ( !empty( $this->mParams['disabled'] ) ) {
return $select->getHTML();
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
$disabled = false;
$allowedParams = [ 'tabindex' ];
$attribs = OOUI\Element::configFromHtmlAttributes(
* @param array $alldata
* @return bool
*/
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
if ( $value == '' ) {
return true;
}
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
return Html::namespaceSelector(
[
'selected' => $value,
* and should be used instead.
*/
class HTMLSelectOrOtherField extends HTMLTextField {
- function __construct( $params ) {
+ public function __construct( $params ) {
parent::__construct( $params );
$this->getOptions();
if ( !in_array( 'other', $this->mOptions, true ) ) {
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$valInSelect = false;
if ( $value !== false ) {
return "$select<br />\n$textbox";
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
return false;
}
*
* @return string
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $request->getCheck( $this->mName ) ) {
$val = $request->getText( $this->mName );
* size limits are represented using a negative integer.
*/
class HTMLSizeFilterField extends HTMLIntField {
- function getSize() {
+ public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 9;
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$attribs = [];
if ( !empty( $this->mParams['disabled'] ) ) {
$attribs['disabled'] = 'disabled';
}
// No OOUI yet
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
return false;
}
*
* @return string
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
$size = $request->getInt( $this->mName );
if ( !$size ) {
return $this->getDefault();
class HTMLTagFilter extends HTMLFormField {
protected $tagFilter;
- function getTableRow( $value ) {
+ public function getTableRow( $value ) {
$this->tagFilter = ChangeTags::buildTagFilterSelector( $value );
if ( $this->tagFilter ) {
return parent::getTableRow( $value );
return '';
}
- function getDiv( $value ) {
+ public function getDiv( $value ) {
$this->tagFilter = ChangeTags::buildTagFilterSelector( $value );
if ( $this->tagFilter ) {
return parent::getDiv( $value );
return '';
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
if ( $this->tagFilter ) {
// we only need the select field, HTMLForm should handle the label
return $this->tagFilter[1];
}
}
- function getCols() {
+ public function getCols() {
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
}
- function getRows() {
+ public function getRows() {
return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
}
- function getSpellCheck() {
+ public function getSpellCheck() {
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return null;
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
$attribs = [
'id' => $this->mID,
'cols' => $this->getCols(),
}
}
- function getSize() {
+ public function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
}
- function getSpellCheck() {
+ public function getSpellCheck() {
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return !( isset( $this->mParams['type'] ) && $this->mParams['type'] === 'password' );
}
- function getInputHTML( $value ) {
+ public function getInputHTML( $value ) {
if ( !$this->isPersistent() ) {
$value = '';
}
return $type;
}
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
if ( !$this->isPersistent() ) {
$value = '';
}