Пример #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'])));
 }
Пример #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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 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;
     }
 }
Пример #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);
 }
Пример #6
0
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     OOUI\Theme::setSingleton(new OOUI\MediaWikiTheme());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles(array('oojs-ui.styles', 'oojs-ui.styles.icons', 'oojs-ui.styles.indicators', 'oojs-ui.styles.textures'));
 }
Пример #7
0
 /**
  * Helper function to setup the PHP implementation of OOUI to use in this request.
  *
  * @since 1.26
  * @param String $skinName The Skin name to determine the correct OOUI theme
  * @param String $dir Language direction
  */
 public static function setupOOUI($skinName = '', $dir = 'ltr')
 {
     $themes = ExtensionRegistry::getInstance()->getAttribute('SkinOOUIThemes');
     // Make keys (skin names) lowercase for case-insensitive matching.
     $themes = array_change_key_case($themes, CASE_LOWER);
     $theme = isset($themes[$skinName]) ? $themes[$skinName] : 'MediaWiki';
     // For example, 'OOUI\MediaWikiTheme'.
     $themeClass = "OOUI\\{$theme}Theme";
     OOUI\Theme::setSingleton(new $themeClass());
     OOUI\Element::setDefaultDir($dir);
 }
Пример #8
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;
     }
 }
Пример #9
0
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     $themes = ExtensionRegistry::getInstance()->getAttribute('SkinOOUIThemes');
     // Make keys (skin names) lowercase for case-insensitive matching.
     $themes = array_change_key_case($themes, CASE_LOWER);
     $skinName = strtolower($this->getSkin()->getSkinName());
     $theme = isset($themes[$skinName]) ? $themes[$skinName] : 'MediaWiki';
     // For example, 'OOUI\MediaWikiTheme'.
     $themeClass = "OOUI\\{$theme}Theme";
     OOUI\Theme::setSingleton(new $themeClass());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles(array('oojs-ui.styles', 'oojs-ui.styles.icons', 'oojs-ui.styles.indicators', 'oojs-ui.styles.textures', 'mediawiki.widgets.styles'));
 }
Пример #10
0
$autoload = '../vendor/autoload.php';
if (!file_exists($autoload)) {
    echo '<h1>Did you forget to run <code>composer install</code>?</h1>';
    exit;
}
require_once $autoload;
$theme = isset($_GET['theme']) && $_GET['theme'] === 'apex' ? 'apex' : 'mediawiki';
$themeClass = 'OOUI\\' . ($theme === 'apex' ? 'Apex' : 'MediaWiki') . 'Theme';
OOUI\Theme::setSingleton(new $themeClass());
$graphicSuffixMap = array('mixed' => '', 'vector' => '.vector', 'raster' => '.raster');
$graphic = isset($_GET['graphic']) && isset($graphicSuffixMap[$_GET['graphic']]) ? $_GET['graphic'] : 'vector';
$graphicSuffix = $graphicSuffixMap[$graphic];
$direction = isset($_GET['direction']) && $_GET['direction'] === 'rtl' ? 'rtl' : 'ltr';
$directionSuffix = $direction === 'rtl' ? '.rtl' : '';
OOUI\Element::setDefaultDir($direction);
$query = array('theme' => $theme, 'graphic' => $graphic, 'direction' => $direction);
$styleFileName = "oojs-ui-{$theme}{$graphicSuffix}{$directionSuffix}.css";
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
	<meta charset="UTF-8">
	<title>OOjs UI Widget Demo</title>
	<link rel="stylesheet" href="../dist/<?php 
echo $styleFileName;
?>
" title="theme">
	<link rel="stylesheet" href="styles/demo<?php 
echo $directionSuffix;
?>
Пример #11
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);
 }
Пример #12
0
 /**
  * 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);
 }
Пример #13
0
 /**
  * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
  * MediaWiki and this OutputPage instance.
  *
  * @since 1.25
  */
 public function enableOOUI()
 {
     OOUI\Theme::setSingleton(new OOUI\MediaWikiTheme());
     OOUI\Element::setDefaultDir($this->getLanguage()->getDir());
     $this->addModuleStyles('oojs-ui.styles');
 }
 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'])));
 }
Пример #15
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'])));
 }