summaryrefslogtreecommitdiff
path: root/vendor/oojs/oojs-ui/php/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/oojs/oojs-ui/php/widgets')
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/ButtonGroupWidget.php28
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/ButtonInputWidget.php110
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php166
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/CheckboxInputWidget.php70
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/DropdownInputWidget.php99
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/IconWidget.php34
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/IndicatorWidget.php32
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/InputWidget.php144
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/LabelWidget.php48
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/RadioInputWidget.php60
-rw-r--r--vendor/oojs/oojs-ui/php/widgets/TextInputWidget.php151
11 files changed, 942 insertions, 0 deletions
diff --git a/vendor/oojs/oojs-ui/php/widgets/ButtonGroupWidget.php b/vendor/oojs/oojs-ui/php/widgets/ButtonGroupWidget.php
new file mode 100644
index 00000000..79d3aaa1
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/ButtonGroupWidget.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Group widget for multiple related buttons.
+ *
+ * Use together with ButtonWidget.
+ */
+class ButtonGroupWidget extends Widget {
+ /**
+ * @param array $config Configuration options
+ * @param ButtonWidget[] $config['items'] Buttons to add
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new GroupElement( $this, array_merge( $config, array( 'group' => $this ) ) ) );
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-buttonGroupWidget' ) );
+ if ( isset( $config['items'] ) ) {
+ $this->addItems( $config['items'] );
+ }
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/ButtonInputWidget.php b/vendor/oojs/oojs-ui/php/widgets/ButtonInputWidget.php
new file mode 100644
index 00000000..b3bcb63b
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/ButtonInputWidget.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * A button that is an input widget. Intended to be used within a FormLayout.
+ */
+class ButtonInputWidget extends InputWidget {
+ /* Properties */
+
+ /**
+ * Whether to use `<input/>` rather than `<button/>`.
+ *
+ * @var boolean
+ */
+ protected $useInputTag;
+
+ private $labelElementMixin;
+
+ /**
+ * @param array $config Configuration options
+ * @param string $config['type'] HTML tag `type` attribute, may be 'button', 'submit' or 'reset'
+ * (default: 'button')
+ * @param boolean $config['useInputTag'] Whether to use `<input/>` rather than `<button/>`. Only
+ * useful if you need IE 6 support in a form with multiple buttons. If you use this option,
+ * icons and indicators will not be displayed, it won't be possible to have a non-plaintext
+ * label, and it won't be possible to set a value (which will internally become identical to the
+ * label). (default: false)
+ */
+ public function __construct( array $config = array() ) {
+ // Configuration initialization
+ $config = array_merge( array( 'type' => 'button', 'useInputTag' => false ), $config );
+
+ // Properties (must be set before parent constructor, which calls setValue())
+ $this->useInputTag = $config['useInputTag'];
+
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new ButtonElement( $this,
+ array_merge( $config, array( 'button' => $this->input ) ) ) );
+ $this->mixin( new IconElement( $this, $config ) );
+ $this->mixin( new IndicatorElement( $this, $config ) );
+ // HACK: We need to have access to the mixin to override the setLabel() method
+ $this->mixin( $this->labelElementMixin = new LabelElement( $this, $config ) );
+ $this->mixin( new TitledElement( $this,
+ array_merge( $config, array( 'titled' => $this->input ) ) ) );
+
+ // Initialization
+ if ( !$config['useInputTag'] ) {
+ $this->input->appendContent( $this->icon, $this->label, $this->indicator );
+ }
+
+ // HACK: This is done in LabelElement mixin, but doesn't call our overridden method because of
+ // how we implement mixins. Switching to traits will fix that.
+ $this->setLabel( isset( $config['label'] ) ? $config['label'] : null );
+
+ $this->addClasses( array( 'oo-ui-buttonInputWidget' ) );
+ }
+
+ protected function getInputElement( $config ) {
+ $input = new Tag( $config['useInputTag'] ? 'input' : 'button' );
+ $input->setAttributes( array( 'type' => $config['type'] ) );
+ return $input;
+ }
+
+ /**
+ * Set label value.
+ *
+ * Overridden to support setting the 'value' of `<input/>` elements.
+ *
+ * @param string|null $label Label text
+ * @chainable
+ */
+ public function setLabel( $label ) {
+ $this->labelElementMixin->setLabel( $label );
+
+ if ( $this->useInputTag ) {
+ // Discard non-plaintext labels
+ $label = is_string( $label ) ? $label : '';
+ $this->input->setValue( $label );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set the value of the input.
+ *
+ * Overridden to disable for `<input/>` elements, which have value identical to the label.
+ *
+ * @param string $value New value
+ * @chainable
+ */
+ public function setValue( $value ) {
+ if ( !$this->useInputTag ) {
+ parent::setValue( $value );
+ }
+ return $this;
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->useInputTag ) {
+ $config['useInputTag'] = true;
+ }
+ $config['type'] = $this->input->getAttribute( 'type' );
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php b/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php
new file mode 100644
index 00000000..f26608b1
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php
@@ -0,0 +1,166 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Generic widget for buttons.
+ */
+class ButtonWidget extends Widget {
+
+ /**
+ * Hyperlink to visit when clicked.
+ *
+ * @var string
+ */
+ protected $href = null;
+
+ /**
+ * Target to open hyperlink in.
+ *
+ * @var string
+ */
+ protected $target = null;
+
+ /**
+ * Search engine traversal hint.
+ *
+ * True if search engines should avoid following this hyperlink.
+ *
+ * @var boolean
+ */
+ protected $noFollow = true;
+
+ /**
+ * @param array $config Configuration options
+ * @param string $config['href'] Hyperlink to visit when clicked
+ * @param string $config['target'] Target to open hyperlink in
+ * @param boolean $config['noFollow'] Search engine traversal hint (default: true)
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new ButtonElement( $this, $config ) );
+ $this->mixin( new IconElement( $this, $config ) );
+ $this->mixin( new IndicatorElement( $this, $config ) );
+ $this->mixin( new LabelElement( $this, $config ) );
+ $this->mixin( new TitledElement( $this,
+ array_merge( $config, array( 'titled' => $this->button ) ) ) );
+ $this->mixin( new FlaggedElement( $this, $config ) );
+ $this->mixin( new TabIndexedElement( $this,
+ array_merge( $config, array( 'tabIndexed' => $this->button ) ) ) );
+
+ // Initialization
+ $this->button->appendContent( $this->icon, $this->label, $this->indicator );
+ $this
+ ->addClasses( array( 'oo-ui-buttonWidget' ) )
+ ->appendContent( $this->button );
+
+ $this->setHref( isset( $config['href'] ) ? $config['href'] : null );
+ $this->setTarget( isset( $config['target'] ) ? $config['target'] : null );
+ $this->setNoFollow( isset( $config['noFollow'] ) ? $config['noFollow'] : true );
+ }
+
+ /**
+ * Get hyperlink location.
+ *
+ * @return string Hyperlink location
+ */
+ public function getHref() {
+ return $this->href;
+ }
+
+ /**
+ * Get hyperlink target.
+ *
+ * @return string Hyperlink target
+ */
+ public function getTarget() {
+ return $this->target;
+ }
+
+ /**
+ * Get search engine traversal hint.
+ *
+ * @return boolean Whether search engines should avoid traversing this hyperlink
+ */
+ public function getNoFollow() {
+ return $this->noFollow;
+ }
+
+ /**
+ * Set hyperlink location.
+ *
+ * @param string|null $href Hyperlink location, null to remove
+ */
+ public function setHref( $href ) {
+ $this->href = is_string( $href ) ? $href : null;
+
+ $this->updateHref();
+
+ return $this;
+ }
+
+ /**
+ * Update the href attribute, in case of changes to href or disabled
+ * state.
+ *
+ * @chainable
+ */
+ public function updateHref() {
+ if ( $this->href !== null && !$this->isDisabled() ) {
+ $this->button->setAttributes( array( 'href' => $this->href ) );
+ } else {
+ $this->button->removeAttributes( array( 'href' ) );
+ }
+ return $this;
+ }
+
+ /**
+ * Set hyperlink target.
+ *
+ * @param string|null $target Hyperlink target, null to remove
+ */
+ public function setTarget( $target ) {
+ $this->target = is_string( $target ) ? $target : null;
+
+ if ( $this->target !== null ) {
+ $this->button->setAttributes( array( 'target' => $target ) );
+ } else {
+ $this->button->removeAttributes( array( 'target' ) );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set search engine traversal hint.
+ *
+ * @param boolean $noFollow True if search engines should avoid traversing this hyperlink
+ */
+ public function setNoFollow( $noFollow ) {
+ $this->noFollow = is_bool( $noFollow ) ? $noFollow : true;
+
+ if ( $this->noFollow ) {
+ $this->button->setAttributes( array( 'rel' => 'nofollow' ) );
+ } else {
+ $this->button->removeAttributes( array( 'rel' ) );
+ }
+
+ return $this;
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->href !== null ) {
+ $config['href'] = $this->href;
+ }
+ if ( $this->target !== null ) {
+ $config['target'] = $this->target;
+ }
+ if ( $this->noFollow !== true ) {
+ $config['noFollow'] = $this->noFollow;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/CheckboxInputWidget.php b/vendor/oojs/oojs-ui/php/widgets/CheckboxInputWidget.php
new file mode 100644
index 00000000..bda09c66
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/CheckboxInputWidget.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Checkbox input widget.
+ */
+class CheckboxInputWidget extends InputWidget {
+
+ /* Properties */
+
+ /**
+ * Whether the checkbox is selected.
+ *
+ * @var boolean
+ */
+ protected $selected;
+
+ /**
+ * @param array $config Configuration options
+ * @param boolean $config['selected'] Whether the checkbox is initially selected
+ * (default: false)
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-checkboxInputWidget' ) );
+ $this->setSelected( isset( $config['selected'] ) ? $config['selected'] : false );
+ }
+
+ protected function getInputElement( $config ) {
+ $input = new Tag( 'input' );
+ $input->setAttributes( array( 'type' => 'checkbox' ) );
+ return $input;
+ }
+
+ /**
+ * Set selection state of this checkbox.
+ *
+ * @param boolean $state Whether the checkbox is selected
+ * @chainable
+ */
+ public function setSelected( $state ) {
+ $this->selected = (bool)$state;
+ if ( $this->selected ) {
+ $this->input->setAttributes( array( 'checked' => 'checked' ) );
+ } else {
+ $this->input->removeAttributes( array( 'checked' ) );
+ }
+ return $this;
+ }
+
+ /**
+ * Check if this checkbox is selected.
+ *
+ * @return boolean Checkbox is selected
+ */
+ public function isSelected() {
+ return $this->selected;
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->selected ) {
+ $config['selected'] = $this->selected;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/DropdownInputWidget.php b/vendor/oojs/oojs-ui/php/widgets/DropdownInputWidget.php
new file mode 100644
index 00000000..ae541a66
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/DropdownInputWidget.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Dropdown input widget, wrapping a `<select>` element. Intended to be used within a
+ * OO.ui.FormLayout.
+ */
+class DropdownInputWidget extends InputWidget {
+
+ /**
+ * HTML `<option>` tags for this widget.
+ * @var Tag[]
+ */
+ protected $options = array();
+
+ /**
+ * @param array $config Configuration options
+ * @param array[] $config['options'] Array of menu options in the format
+ * `array( 'data' => …, 'label' => … )`
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Initialization
+ $this->setOptions( isset( $config['options'] ) ? $config['options'] : array() );
+ $this->addClasses( array( 'oo-ui-dropdownInputWidget' ) );
+ }
+
+ protected function getInputElement( $config ) {
+ return new Tag( 'select' );
+ }
+
+ public function setValue( $value ) {
+ $this->value = $this->cleanUpValue( $value );
+ foreach ( $this->options as &$opt ) {
+ if ( $opt->getAttribute( 'value' ) === $this->value ) {
+ $opt->setAttributes( array( 'selected' => 'selected' ) );
+ } else {
+ $opt->removeAttributes( array( 'selected' ) );
+ }
+ }
+ return $this;
+ }
+
+
+ /**
+ * Set the options available for this input.
+ *
+ * @param array[] $options Array of menu options in the format
+ * `array( 'data' => …, 'label' => … )`
+ * @chainable
+ */
+ public function setOptions( $options ) {
+ $value = $this->getValue();
+ $isValueAvailable = false;
+ $this->options = array();
+
+ // Rebuild the dropdown menu
+ $this->input->clearContent();
+ foreach ( $options as $opt ) {
+ $option = new Tag( 'option' );
+ $option->setAttributes( array( 'value' => $opt['data'] ) );
+ $option->appendContent( isset( $opt['label'] ) ? $opt['label'] : $opt['data'] );
+
+ if ( $value === $opt['data'] ) {
+ $isValueAvailable = true;
+ }
+
+ $this->options[] = $option;
+ $this->input->appendContent( $option );
+ }
+
+ // Restore the previous value, or reset to something sensible
+ if ( $isValueAvailable ) {
+ // Previous value is still available
+ $this->setValue( $value );
+ } else {
+ // No longer valid, reset
+ if ( count( $options ) ) {
+ $this->setValue( $options[0]['data'] );
+ }
+ }
+
+ return $this;
+ }
+
+ public function getConfig( &$config ) {
+ $o = array();
+ foreach ( $this->options as $option ) {
+ $label = $option->content[0];
+ $data = $option->getAttribute( 'value' );
+ $o[] = array( 'data' => $data, 'label' => $label );
+ }
+ $config['options'] = $o;
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/IconWidget.php b/vendor/oojs/oojs-ui/php/widgets/IconWidget.php
new file mode 100644
index 00000000..f8273f37
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/IconWidget.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Icon widget.
+ *
+ * See IconElement for more information.
+ */
+class IconWidget extends Widget {
+
+ /* Static properties */
+
+ public static $tagName = 'span';
+
+ /**
+ * @param array $config Configuration options
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new IconElement( $this,
+ array_merge( $config, array( 'iconElement' => $this ) ) ) );
+ $this->mixin( new TitledElement( $this,
+ array_merge( $config, array( 'titled' => $this ) ) ) );
+ $this->mixin( new FlaggedElement( $this,
+ array_merge( $config, array( 'flagged' => $this ) ) ) );
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-iconWidget' ) );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/IndicatorWidget.php b/vendor/oojs/oojs-ui/php/widgets/IndicatorWidget.php
new file mode 100644
index 00000000..01f2055d
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/IndicatorWidget.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Indicator widget.
+ *
+ * See IndicatorElement for more information.
+ */
+class IndicatorWidget extends Widget {
+
+ /* Static properties */
+
+ public static $tagName = 'span';
+
+ /**
+ * @param array $config Configuration options
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new IndicatorElement( $this,
+ array_merge( $config, array( 'indicatorElement' => $this ) ) ) );
+ $this->mixin( new TitledElement( $this,
+ array_merge( $config, array( 'titled' => $this ) ) ) );
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-indicatorWidget' ) );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/InputWidget.php b/vendor/oojs/oojs-ui/php/widgets/InputWidget.php
new file mode 100644
index 00000000..234d3145
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/InputWidget.php
@@ -0,0 +1,144 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Base class for input widgets.
+ *
+ * @abstract
+ */
+class InputWidget extends Widget {
+
+ /* Properties */
+
+ /**
+ * Input element.
+ *
+ * @var Tag
+ */
+ protected $input;
+
+ /**
+ * Input value.
+ *
+ * @var string
+ */
+ protected $value = '';
+
+ /**
+ * @param array $config Configuration options
+ * @param string $config['name'] HTML input name (default: '')
+ * @param string $config['value'] Input value (default: '')
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Properties
+ $this->input = $this->getInputElement( $config );
+
+ // Mixins
+ $this->mixin( new FlaggedElement( $this,
+ array_merge( $config, array( 'flagged' => $this ) ) ) );
+ $this->mixin( new TabIndexedElement( $this,
+ array_merge( $config, array( 'tabIndexed' => $this->input ) ) ) );
+
+ // Initialization
+ if ( isset( $config['name'] ) ) {
+ $this->input->setAttributes( array( 'name' => $config['name'] ) );
+ }
+ if ( $this->isDisabled() ) {
+ $this->input->setAttributes( array( 'disabled' => 'disabled' ) );
+ }
+ $this
+ ->addClasses( array( 'oo-ui-inputWidget' ) )
+ ->appendContent( $this->input );
+ $this->appendContent( new Tag( 'span' ) );
+ $this->setValue( isset( $config['value'] ) ? $config['value'] : null );
+ }
+
+ /**
+ * Get input element.
+ *
+ * @param array $config Configuration options
+ * @return Tag Input element
+ */
+ protected function getInputElement( $config ) {
+ return new Tag( 'input' );
+ }
+
+ /**
+ * Get the value of the input.
+ *
+ * @return string Input value
+ */
+ public function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Sets the direction of the current input, either RTL or LTR
+ *
+ * @param boolean $isRTL
+ */
+ public function setRTL( $isRTL ) {
+ if ( $isRTL ) {
+ $this->input->removeClasses( array( 'oo-ui-ltr' ) );
+ $this->input->addClasses( array( 'oo-ui-rtl' ) );
+ } else {
+ $this->input->removeClasses( array( 'oo-ui-rtl' ) );
+ $this->input->addClasses( array( 'oo-ui-ltr' ) );
+ }
+ }
+
+ /**
+ * Set the value of the input.
+ *
+ * @param string $value New value
+ * @chainable
+ */
+ public function setValue( $value ) {
+ $this->value = $this->cleanUpValue( $value );
+ $this->input->setValue( $this->value );
+ return $this;
+ }
+
+ /**
+ * Clean up incoming value.
+ *
+ * Ensures value is a string, and converts null to empty string.
+ *
+ * @param string $value Original value
+ * @return string Cleaned up value
+ */
+ protected function cleanUpValue( $value ) {
+ if ( $value === null ) {
+ return '';
+ } else {
+ return (string)$value;
+ }
+ }
+
+ public function setDisabled( $state ) {
+ parent::setDisabled( $state );
+ if ( isset( $this->input ) ) {
+ if ( $this->isDisabled() ) {
+ $this->input->setAttributes( array( 'disabled' => 'disabled' ) );
+ } else {
+ $this->input->removeAttributes( array( 'disabled' ) );
+ }
+ }
+ return $this;
+ }
+
+ public function getConfig( &$config ) {
+ $name = $this->input->getAttribute( 'name' );
+ if ( $name !== null ) {
+ $config['name'] = $name;
+ }
+ if ( $this->value !== '' ) {
+ $config['value'] = $this->value;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/LabelWidget.php b/vendor/oojs/oojs-ui/php/widgets/LabelWidget.php
new file mode 100644
index 00000000..b59a5f25
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/LabelWidget.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Label widget.
+ */
+class LabelWidget extends Widget {
+
+ /* Static properties */
+
+ public static $tagName = 'span';
+
+ /* Properties */
+
+ /**
+ * Associated input element.
+ *
+ * @var InputWidget|null
+ */
+ protected $input;
+
+ /**
+ * @param array $config Configuration options
+ * @param InputWidget $config['input'] Input widget this label is for
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Mixins
+ $this->mixin( new LabelElement( $this,
+ array_merge( $config, array( 'labelElement' => $this ) ) ) );
+
+ // Properties
+ $this->input = isset( $config['input'] ) ? $config['input'] : null;
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-labelWidget' ) );
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->input !== null ) {
+ $config['input'] = $this->input;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/RadioInputWidget.php b/vendor/oojs/oojs-ui/php/widgets/RadioInputWidget.php
new file mode 100644
index 00000000..26da29d0
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/RadioInputWidget.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Radio input widget.
+ */
+class RadioInputWidget extends InputWidget {
+
+ /**
+ * @param array $config Configuration options
+ * @param boolean $config['selected'] Whether the radio button is initially selected
+ * (default: false)
+ */
+ public function __construct( array $config = array() ) {
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Initialization
+ $this->addClasses( array( 'oo-ui-radioInputWidget' ) );
+ $this->setSelected( isset( $config['selected'] ) ? $config['selected'] : false );
+ }
+
+ protected function getInputElement( $config ) {
+ $input = new Tag( 'input' );
+ $input->setAttributes( array( 'type' => 'radio' ) );
+ return $input;
+ }
+
+ /**
+ * Set selection state of this radio button.
+ *
+ * @param boolean $state Whether the button is selected
+ */
+ public function setSelected( $state ) {
+ // RadioInputWidget doesn't track its state.
+ if ( $state ) {
+ $this->input->setAttributes( array( 'checked' => 'checked' ) );
+ } else {
+ $this->input->removeAttributes( array( 'checked' ) );
+ }
+ return $this;
+ }
+
+ /**
+ * Check if this radio button is selected.
+ *
+ * @return boolean Radio is selected
+ */
+ public function isSelected() {
+ return $this->input->getAttribute( 'checked' ) === 'checked';
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->isSelected() ) {
+ $config['selected'] = true;
+ }
+ return parent::getConfig( $config );
+ }
+}
diff --git a/vendor/oojs/oojs-ui/php/widgets/TextInputWidget.php b/vendor/oojs/oojs-ui/php/widgets/TextInputWidget.php
new file mode 100644
index 00000000..a5f31f74
--- /dev/null
+++ b/vendor/oojs/oojs-ui/php/widgets/TextInputWidget.php
@@ -0,0 +1,151 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Input widget with a text field.
+ */
+class TextInputWidget extends InputWidget {
+
+ /* Properties */
+
+ /**
+ * Prevent changes.
+ *
+ * @var boolean
+ */
+ protected $readOnly = false;
+
+ /**
+ * Allow multiple lines of text.
+ *
+ * @var boolean
+ */
+ protected $multiline = false;
+
+ /**
+ * @param array $config Configuration options
+ * @param string $config['type'] HTML tag `type` attribute (default: 'text')
+ * @param string $config['placeholder'] Placeholder text
+ * @param boolean $config['autofocus'] Ask the browser to focus this widget, using the 'autofocus'
+ * HTML attribute (default: false)
+ * @param boolean $config['readOnly'] Prevent changes (default: false)
+ * @param number $config['maxLength'] Maximum allowed number of characters to input
+ * @param boolean $config['multiline'] Allow multiple lines of text (default: false)
+ * @param boolean $config['required'] Mark the field as required (default: false)
+ */
+ public function __construct( array $config = array() ) {
+ // Config initialization
+ $config = array_merge( array(
+ 'readOnly' => false,
+ 'autofocus' => false,
+ 'required' => false,
+ ), $config );
+
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Properties
+ $this->multiline = isset( $config['multiline'] ) ? (bool)$config['multiline'] : false;
+
+ // Mixins
+ $this->mixin( new IconElement( $this, $config ) );
+ $this->mixin( new IndicatorElement( $this, $config ) );
+
+ // Initialization
+ $this
+ ->addClasses( array( 'oo-ui-textInputWidget' ) )
+ ->appendContent( $this->icon, $this->indicator );
+ $this->setReadOnly( $config['readOnly'] );
+ if ( isset( $config['placeholder'] ) ) {
+ $this->input->setAttributes( array( 'placeholder' => $config['placeholder'] ) );
+ }
+ if ( isset( $config['maxLength'] ) ) {
+ $this->input->setAttributes( array( 'maxlength' => $config['maxLength'] ) );
+ }
+ if ( $config['autofocus'] ) {
+ $this->input->setAttributes( array( 'autofocus' => 'autofocus' ) );
+ }
+ if ( $config['required'] ) {
+ $this->input->setAttributes( array( 'required' => 'required', 'aria-required' => 'true' ) );
+ }
+ }
+
+ /**
+ * Check if the widget is read-only.
+ *
+ * @return boolean
+ */
+ public function isReadOnly() {
+ return $this->readOnly;
+ }
+
+ /**
+ * Set the read-only state of the widget. This should probably change the widget's appearance and
+ * prevent it from being used.
+ *
+ * @param boolean $state Make input read-only
+ * @chainable
+ */
+ public function setReadOnly( $state ) {
+ $this->readOnly = (bool)$state;
+ if ( $this->readOnly ) {
+ $this->input->setAttributes( array( 'readonly' => 'readonly' ) );
+ } else {
+ $this->input->removeAttributes( array( 'readonly' ) );
+ }
+ return $this;
+ }
+
+ protected function getInputElement( $config ) {
+ if ( isset( $config['multiline'] ) && $config['multiline'] ) {
+ return new Tag( 'textarea' );
+ } else {
+ $type = isset( $config['type'] ) ? $config['type'] : 'text';
+ $input = new Tag( 'input' );
+ $input->setAttributes( array( 'type' => $type ) );
+ return $input;
+ }
+ }
+
+ /**
+ * Check if input supports multiple lines.
+ *
+ * @return boolean
+ */
+ public function isMultiline() {
+ return (bool)$this->multiline;
+ }
+
+ public function getConfig( &$config ) {
+ if ( $this->isMultiline() ) {
+ $config['multiline'] = true;
+ } else {
+ $type = $this->input->getAttribute( 'type' );
+ if ( $type !== 'text' ) {
+ $config['type'] = $type;
+ }
+ }
+ if ( $this->isReadOnly() ) {
+ $config['readOnly'] = true;
+ }
+ $placeholder = $this->input->getAttribute( 'placeholder' );
+ if ( $placeholder !== null ) {
+ $config['placeholder'] = $placeholder;
+ }
+ $maxlength = $this->input->getAttribute( 'maxlength' );
+ if ( $maxlength !== null ) {
+ $config['maxLength'] = $maxlength;
+ }
+ $autofocus = $this->input->getAttribute( 'autofocus' );
+ if ( $autofocus !== null ) {
+ $config['autofocus'] = true;
+ }
+ $required = $this->input->getAttribute( 'required' );
+ $ariarequired = $this->input->getAttribute( 'aria-required' );
+ if ( ( $required !== null ) || ( $ariarequired !== null ) ) {
+ $config['required'] = true;
+ }
+ return parent::getConfig( $config );
+ }
+}