MediaWiki  master
SpinnerWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
15 
16  private $attributes;
17  private $content;
18 
22  public function __construct( array $config = [] ) {
23  $size = $config['size'] ?? 'small';
24  $type = $config['type'] ?? 'inline';
25 
26  $this->attributes = [];
27 
28  if ( isset( $config['id'] ) ) {
29  $this->attributes['id'] = $config['id'];
30  }
31 
32  // Initialization
33  $this->attributes['class'] = [
34  'mw-spinner',
35  $size === 'small' ? 'mw-spinner-small' : 'mw-spinner-large',
36  $type === 'inline' ? 'mw-spinner-inline' : 'mw-spinner-block',
37  ];
38 
39  $this->content =
40  '<div class="mw-spinner-container">' .
41  str_repeat( '<div></div>', 12 ) .
42  '</div>';
43  }
44 
49  public function toString() {
50  return \Html::rawElement( 'div', $this->attributes, $this->content );
51  }
52 
60  public function __toString() {
61  try {
62  return $this->toString();
63  } catch ( \Exception $ex ) {
64  trigger_error( (string)$ex, E_USER_ERROR );
65  return '';
66  }
67  }
68 }
MediaWiki\Widget\SpinnerWidget\$content
$content
Definition: SpinnerWidget.php:17
MediaWiki\Widget\SpinnerWidget\__toString
__toString()
Magic method implementation.
Definition: SpinnerWidget.php:60
MediaWiki\Widget\SpinnerWidget\$attributes
$attributes
Definition: SpinnerWidget.php:16
MediaWiki\Widget
Definition: CheckMatrixWidget.php:3
MediaWiki\$config
Config $config
Definition: MediaWiki.php:42
MediaWiki\Widget\SpinnerWidget\toString
toString()
Render element into HTML.
Definition: SpinnerWidget.php:49
MediaWiki\Widget\SpinnerWidget
PHP version of jquery.spinner.
Definition: SpinnerWidget.php:14
MediaWiki\Widget\SpinnerWidget\__construct
__construct(array $config=[])
Definition: SpinnerWidget.php:22
$type
$type
Definition: testCompression.php:52