2016-08-11 19:22:27 +00:00
|
|
|
<?php
|
2022-11-13 07:53:42 +00:00
|
|
|
|
|
|
|
namespace MediaWiki\Extension\Notifications;
|
|
|
|
|
2016-08-11 19:22:27 +00:00
|
|
|
/**
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
2022-05-20 02:11:31 +00:00
|
|
|
use MediaWiki\ResourceLoader as RL;
|
2022-11-13 07:53:42 +00:00
|
|
|
use RuntimeException;
|
2022-05-20 02:11:31 +00:00
|
|
|
|
2016-08-11 19:22:27 +00:00
|
|
|
/**
|
|
|
|
* A sibling of secret special sauce.
|
2022-05-20 02:11:31 +00:00
|
|
|
* @see RL\OOUIImageModule for familial resemblence
|
2016-08-11 19:22:27 +00:00
|
|
|
*/
|
2022-05-20 02:11:31 +00:00
|
|
|
class ResourceLoaderEchoImageModule extends RL\ImageModule {
|
2016-08-11 19:22:27 +00:00
|
|
|
protected function loadFromDefinition() {
|
|
|
|
if ( $this->definition === null ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-02 05:01:56 +00:00
|
|
|
// Check to make sure icons are set
|
|
|
|
if ( !isset( $this->definition['icons'] ) ) {
|
2023-06-07 17:46:16 +00:00
|
|
|
throw new RuntimeException( 'Icons must be set.' );
|
2017-03-02 05:01:56 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
$images = [];
|
2017-03-02 05:01:56 +00:00
|
|
|
foreach ( $this->definition['icons'] as $iconName => $definition ) {
|
2016-08-11 19:22:27 +00:00
|
|
|
// FIXME: We also have a 'site' icon which is "magical"
|
|
|
|
// and uses witchcraft and should be handled specifically
|
2023-10-22 09:12:41 +00:00
|
|
|
if ( isset( $definition[ 'path' ] ) && $definition[ 'path' ] ) {
|
|
|
|
// string or array, if array, has both rtl and ltr definitions
|
|
|
|
$images[ $iconName ][ 'file' ] = $definition[ 'path' ];
|
2016-08-11 19:22:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->definition[ 'images' ] = $images;
|
|
|
|
$this->definition[ 'selector' ] = '.oo-ui-icon-{name}';
|
2019-10-23 10:31:35 +00:00
|
|
|
|
2016-08-11 19:22:27 +00:00
|
|
|
parent::loadFromDefinition();
|
|
|
|
}
|
|
|
|
}
|