From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../oojs/oojs-ui/php/layouts/ActionFieldLayout.php | 55 ++++++++++++++++ vendor/oojs/oojs-ui/php/layouts/FieldLayout.php | 73 +++++++++++++++++++++- vendor/oojs/oojs-ui/php/layouts/FormLayout.php | 2 +- .../oojs/oojs-ui/php/layouts/HorizontalLayout.php | 27 ++++++++ 4 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 vendor/oojs/oojs-ui/php/layouts/ActionFieldLayout.php create mode 100644 vendor/oojs/oojs-ui/php/layouts/HorizontalLayout.php (limited to 'vendor/oojs/oojs-ui/php/layouts') diff --git a/vendor/oojs/oojs-ui/php/layouts/ActionFieldLayout.php b/vendor/oojs/oojs-ui/php/layouts/ActionFieldLayout.php new file mode 100644 index 00000000..bf908184 --- /dev/null +++ b/vendor/oojs/oojs-ui/php/layouts/ActionFieldLayout.php @@ -0,0 +1,55 @@ +buttonWidget = $buttonWidget; + $this->button = new Tag( 'div' ); + $this->input = new Tag( 'div' ); + + // Initialization + $this->addClasses( array( 'oo-ui-actionFieldLayout' ) ); + $this->button + ->addClasses( array( 'oo-ui-actionFieldLayout-button' ) ) + ->appendContent( $this->buttonWidget ); + $this->input + ->addClasses( array( 'oo-ui-actionFieldLayout-input' ) ) + ->appendContent( $this->fieldWidget ); + $this->field + ->clearContent() + ->appendContent( $this->input, $this->button ); + } + + public function getConfig( &$config ) { + $config['buttonWidget'] = $this->buttonWidget; + return parent::getConfig( $config ); + } +} diff --git a/vendor/oojs/oojs-ui/php/layouts/FieldLayout.php b/vendor/oojs/oojs-ui/php/layouts/FieldLayout.php index ef0d4c6c..bfa25afe 100644 --- a/vendor/oojs/oojs-ui/php/layouts/FieldLayout.php +++ b/vendor/oojs/oojs-ui/php/layouts/FieldLayout.php @@ -31,14 +31,37 @@ class FieldLayout extends Layout { */ protected $fieldWidget; - private $field, $body, $help; + /** + * Error messages. + * + * @var array + */ + protected $errors; + + /** + * Notice messages. + * + * @var array + */ + protected $notices; + + /** + * @var ButtonWidget|string + */ + protected $help; + + protected $field, $body, $messages; /** * @param Widget $fieldWidget Field widget * @param array $config Configuration options * @param string $config['align'] Alignment mode, either 'left', 'right', 'top' or 'inline' * (default: 'left') - * @param string $config['help'] Explanatory text shown as a '?' icon. + * @param array $config['errors'] Error messages about the widget, as strings or HtmlSnippet + * instances. + * @param array $config['notices'] Notices about the widget, as strings or HtmlSnippet instances. + * @param string|HtmlSnippet $config['help'] Explanatory text shown as a '?' icon. + * @throws Exception An exception is thrown if no widget is specified */ public function __construct( $fieldWidget, array $config = array() ) { // Allow passing positional parameters inside the config array @@ -47,7 +70,12 @@ class FieldLayout extends Layout { $fieldWidget = $config['fieldWidget']; } - $hasInputWidget = $fieldWidget instanceof InputWidget; + // Make sure we have required constructor arguments + if ( $fieldWidget === null ) { + throw new Exception( 'Widget not found' ); + } + + $hasInputWidget = $fieldWidget::$supportsSimpleLabel; // Config initialization $config = array_merge( array( 'align' => 'left' ), $config ); @@ -57,7 +85,10 @@ class FieldLayout extends Layout { // Properties $this->fieldWidget = $fieldWidget; + $this->errors = isset( $config['errors'] ) ? $config['errors'] : array(); + $this->notices = isset( $config['notices'] ) ? $config['notices'] : array(); $this->field = new Tag( 'div' ); + $this->messages = new Tag( 'ul' ); $this->body = new Tag( $hasInputWidget ? 'label' : 'div' ); if ( isset( $config['help'] ) ) { $this->help = new ButtonWidget( array( @@ -72,20 +103,54 @@ class FieldLayout extends Layout { // Mixins $this->mixin( new LabelElement( $this, $config ) ); + $this->mixin( new TitledElement( $this, + array_merge( $config, array( 'titled' => $this->label ) ) ) ); // Initialization $this ->addClasses( array( 'oo-ui-fieldLayout' ) ) ->appendContent( $this->help, $this->body ); + if ( count( $this->errors ) || count( $this->notices ) ) { + $this->appendContent( $this->messages ); + } $this->body->addClasses( array( 'oo-ui-fieldLayout-body' ) ); + $this->messages->addClasses( array( 'oo-ui-fieldLayout-messages' ) ); $this->field ->addClasses( array( 'oo-ui-fieldLayout-field' ) ) ->toggleClasses( array( 'oo-ui-fieldLayout-disable' ), $this->fieldWidget->isDisabled() ) ->appendContent( $this->fieldWidget ); + foreach ( $this->notices as $text ) { + $this->messages->appendContent( $this->makeMessage( 'notice', $text ) ); + } + foreach ( $this->errors as $text ) { + $this->messages->appendContent( $this->makeMessage( 'error', $text ) ); + } + $this->setAlignment( $config['align'] ); } + /** + * @param string $kind 'error' or 'notice' + * @param string|HtmlSnippet $text + * @return Tag + */ + private function makeMessage( $kind, $text ) { + $listItem = new Tag( 'li' ); + if ( $kind === 'error' ) { + $icon = new IconWidget( array( 'icon' => 'alert', 'flags' => array( 'warning' ) ) ); + } elseif ( $kind === 'notice' ) { + $icon = new IconWidget( array( 'icon' => 'info' ) ); + } else { + $icon = null; + } + $message = new LabelWidget( array( 'label' => $text ) ); + $listItem + ->appendContent( $icon, $message ) + ->addClasses( array( "oo-ui-fieldLayout-messages-$kind" ) ); + return $listItem; + } + /** * Get the field. * @@ -132,6 +197,8 @@ class FieldLayout extends Layout { public function getConfig( &$config ) { $config['fieldWidget'] = $this->fieldWidget; $config['align'] = $this->align; + $config['errors'] = $this->errors; + $config['notices'] = $this->notices; if ( $this->help !== '' ) { $config['help'] = $this->help->getTitle(); } diff --git a/vendor/oojs/oojs-ui/php/layouts/FormLayout.php b/vendor/oojs/oojs-ui/php/layouts/FormLayout.php index ebeb89de..eadf2750 100644 --- a/vendor/oojs/oojs-ui/php/layouts/FormLayout.php +++ b/vendor/oojs/oojs-ui/php/layouts/FormLayout.php @@ -7,7 +7,7 @@ namespace OOUI; */ class FormLayout extends Layout { - /* Static properties */ + /* Static Properties */ public static $tagName = 'form'; diff --git a/vendor/oojs/oojs-ui/php/layouts/HorizontalLayout.php b/vendor/oojs/oojs-ui/php/layouts/HorizontalLayout.php new file mode 100644 index 00000000..d4acb216 --- /dev/null +++ b/vendor/oojs/oojs-ui/php/layouts/HorizontalLayout.php @@ -0,0 +1,27 @@ +mixin( new GroupElement( $this, array_merge( $config, array( 'group' => $this ) ) ) ); + + // Initialization + $this->addClasses( array( 'oo-ui-horizontalLayout' ) ); + if ( isset( $config['items'] ) ) { + $this->addItems( $config['items'] ); + } + } +} -- cgit v1.2.3-54-g00ecf