== What == This method was "Copied from OOUI\Tag", which no longer does this since last year (I42c7a7b4d, 6e4e1a1796). Apply the same change here. == Why now == Triggering E_USER_ERROR is deprecated in PHP 8.4+. Bug: T381341 Bug: T379445 Change-Id: I1bac121caf746c30996dccd7fb95c4c240742951 (cherry picked from commit 751eca89fe473cc4a649e47dd54e9ab38f7c1957)
68 lines
1.4 KiB
PHP
68 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Widget;
|
|
|
|
use MediaWiki\Html\Html;
|
|
use Stringable;
|
|
|
|
/**
|
|
* PHP version of jquery.spinner.
|
|
*
|
|
* If used with jquery.spinner.styles, can be used to show a
|
|
* spinner before JavaScript has loaded.
|
|
*
|
|
* @copyright 2011-2020 MediaWiki Widgets Team and others; see AUTHORS.txt
|
|
* @license MIT
|
|
*/
|
|
class SpinnerWidget implements Stringable {
|
|
|
|
/** @var array */
|
|
private $attributes;
|
|
/** @var string */
|
|
private $content;
|
|
|
|
/**
|
|
* @param array $config Configuration options
|
|
*/
|
|
public function __construct( array $config = [] ) {
|
|
$size = $config['size'] ?? 'small';
|
|
$type = $config['type'] ?? 'inline';
|
|
|
|
$this->attributes = [];
|
|
|
|
if ( isset( $config['id'] ) ) {
|
|
$this->attributes['id'] = $config['id'];
|
|
}
|
|
|
|
// Initialization
|
|
$this->attributes['class'] = [
|
|
'mw-spinner',
|
|
$size === 'small' ? 'mw-spinner-small' : 'mw-spinner-large',
|
|
$type === 'inline' ? 'mw-spinner-inline' : 'mw-spinner-block',
|
|
];
|
|
|
|
$this->content =
|
|
'<div class="mw-spinner-container">' .
|
|
str_repeat( '<div></div>', 12 ) .
|
|
'</div>';
|
|
}
|
|
|
|
/**
|
|
* Render element into HTML.
|
|
* @return string HTML serialization
|
|
*/
|
|
public function toString() {
|
|
return Html::rawElement( 'div', $this->attributes, $this->content );
|
|
}
|
|
|
|
/**
|
|
* Magic method implementation.
|
|
*
|
|
* Copied from OOUI\Tag
|
|
*
|
|
* @return string
|
|
*/
|
|
public function __toString() {
|
|
return $this->toString();
|
|
}
|
|
}
|