Example #1
0
 function getInputOOUI($value)
 {
     $options = [];
     foreach ($this->getOptions() as $label => $data) {
         $options[] = ['data' => $data, 'label' => $this->mOptionsLabelsNotFromMessage ? new OOUI\HtmlSnippet($label) : $label];
     }
     return new OOUI\RadioSelectInputWidget(['name' => $this->mName, 'id' => $this->mID, 'value' => $value, 'options' => $options, 'classes' => 'mw-htmlform-flatlist-item'] + OOUI\Element::configFromHtmlAttributes($this->getAttributes(['disabled', 'tabindex'])));
 }
Example #2
0
 function getInputOOUI($value)
 {
     $disabled = false;
     $allowedParams = ['tabindex'];
     $attribs = OOUI\Element::configFromHtmlAttributes($this->getAttributes($allowedParams));
     if ($this->mClass !== '') {
         $attribs['classes'] = [$this->mClass];
     }
     if (!empty($this->mParams['disabled'])) {
         $disabled = true;
     }
     return new OOUI\DropdownInputWidget(['name' => $this->mName, 'id' => $this->mID, 'options' => $this->getOptionsOOUI(), 'value' => strval($value), 'disabled' => $disabled] + $attribs);
 }
 protected function getOneCheckbox($checked, $attribs, $label)
 {
     if ($this->mParent instanceof OOUIHTMLForm) {
         if ($this->mOptionsLabelsNotFromMessage) {
             $label = new OOUI\HtmlSnippet($label);
         }
         return new OOUI\FieldLayout(new OOUI\CheckboxInputWidget(['name' => "{$this->mName}[]", 'selected' => $checked] + OOUI\Element::configFromHtmlAttributes($attribs)), ['label' => $label, 'align' => 'inline']);
     } else {
         $elementFunc = ['Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element'];
         $checkbox = Xml::check("{$this->mName}[]", $checked, $attribs) . ' ' . call_user_func($elementFunc, 'label', ['for' => $attribs['id']], $label);
         if ($this->mParent->getConfig()->get('UseMediaWikiUIEverywhere')) {
             $checkbox = Html::openElement('div', ['class' => 'mw-ui-checkbox']) . $checkbox . Html::closeElement('div');
         }
         return $checkbox;
     }
 }
 function getInputOOUI($value)
 {
     if (isset($this->mParams['cols'])) {
         throw new Exception("OOUIHTMLForm does not support the 'cols' parameter for textareas");
     }
     $attribs = $this->getTooltipAndAccessKey();
     if ($this->mClass !== '') {
         $attribs['classes'] = [$this->mClass];
     }
     if ($this->mPlaceholder !== '') {
         $attribs['placeholder'] = $this->mPlaceholder;
     }
     $allowedParams = ['tabindex', 'disabled', 'readonly', 'required', 'autofocus'];
     $attribs += OOUI\Element::configFromHtmlAttributes($this->getAttributes($allowedParams));
     return new OOUI\TextInputWidget(['id' => $this->mID, 'name' => $this->mName, 'multiline' => true, 'value' => $value, 'rows' => $this->getRows()] + $attribs);
 }
Example #5
0
 /**
  * Get the OOUI version of this field.
  * @since 1.26
  * @param string $value
  * @return OOUI\CheckboxInputWidget The checkbox widget.
  */
 public function getInputOOUI($value)
 {
     if (!empty($this->mParams['invert'])) {
         $value = !$value;
     }
     $attr = $this->getTooltipAndAccessKey();
     $attr['id'] = $this->mID;
     $attr['name'] = $this->mName;
     $attr += OOUI\Element::configFromHtmlAttributes($this->getAttributes(['disabled', 'tabindex']));
     if ($this->mClass !== '') {
         $attr['classes'] = [$this->mClass];
     }
     $attr['selected'] = $value;
     $attr['value'] = '1';
     // Nasty hack, but needed to make this work
     return new OOUI\CheckboxInputWidget($attr);
 }
Example #6
0
 protected function getOneCheckbox($checked, $attribs)
 {
     if ($this->mParent instanceof OOUIHTMLForm) {
         return new OOUI\CheckboxInputWidget(['name' => "{$this->mName}[]", 'selected' => $checked] + OOUI\Element::configFromHtmlAttributes($attribs));
     } else {
         $checkbox = Xml::check("{$this->mName}[]", $checked, $attribs);
         if ($this->mParent->getConfig()->get('UseMediaWikiUIEverywhere')) {
             $checkbox = Html::openElement('div', ['class' => 'mw-ui-checkbox']) . $checkbox . Html::element('label', ['for' => $attribs['id']]) . Html::closeElement('div');
         }
         return $checkbox;
     }
 }
Example #7
0
 function getInputOOUI($value)
 {
     if (!$this->isPersistent()) {
         $value = '';
     }
     $attribs = $this->getTooltipAndAccessKey();
     if ($this->mClass !== '') {
         $attribs['classes'] = [$this->mClass];
     }
     if ($this->mPlaceholder !== '') {
         $attribs['placeholder'] = $this->mPlaceholder;
     }
     # @todo Enforce pattern, step, required, readonly on the server side as
     # well
     $allowedParams = ['autofocus', 'autosize', 'disabled', 'flags', 'indicator', 'maxlength', 'readonly', 'required', 'tabindex', 'type'];
     $attribs += OOUI\Element::configFromHtmlAttributes($this->getAttributes($allowedParams));
     $type = $this->getType($attribs);
     return $this->getInputWidget(['id' => $this->mID, 'name' => $this->mName, 'value' => $value, 'type' => $type] + $attribs);
 }
 /**
  * Get the OOUI version of this field.
  *
  * @since 1.28
  * @param string[] $value
  * @return OOUI\CheckboxMultiselectInputWidget
  */
 public function getInputOOUI($value)
 {
     $this->mParent->getOutput()->addModules('oojs-ui-widgets');
     $attr = $this->getTooltipAndAccessKey();
     $attr['id'] = $this->mID;
     $attr['name'] = "{$this->mName}[]";
     $attr['value'] = $value;
     $attr['options'] = $this->getOptionsOOUI();
     if ($this->mOptionsLabelsNotFromMessage) {
         foreach ($attr['options'] as &$option) {
             $option['label'] = new OOUI\HtmlSnippet($option['label']);
         }
     }
     $attr += OOUI\Element::configFromHtmlAttributes($this->getAttributes(['disabled', 'tabindex']));
     if ($this->mClass !== '') {
         $attr['classes'] = [$this->mClass];
     }
     return new OOUI\CheckboxMultiselectInputWidget($attr);
 }
 public function getInputOOUI($value)
 {
     return new OOUI\ButtonInputWidget(['name' => $this->mButtonName, 'value' => $this->mButtonValue, 'type' => $this->mButtonType, 'label' => $this->mButtonValue, 'flags' => $this->mButtonFlags] + OOUI\Element::configFromHtmlAttributes($this->getAttributes(['disabled', 'tabindex'])));
 }
Example #10
0
 /**
  * Get the OOUI widget for this field.
  * @param string $value
  * @return OOUI\ButtonInputWidget
  */
 public function getInputOOUI($value)
 {
     return new OOUI\ButtonInputWidget(['name' => $this->mName, 'value' => $this->getDefault(), 'label' => !$this->isBadIE() && $this->buttonLabel ? new OOUI\HtmlSnippet($this->buttonLabel) : $this->getDefault(), 'type' => $this->buttonType, 'classes' => ['mw-htmlform-submit', $this->mClass], 'id' => $this->mID, 'flags' => $this->mFlags, 'useInputTag' => $this->isBadIE()] + OOUI\Element::configFromHtmlAttributes($this->getAttributes(['disabled', 'tabindex'])));
 }