mediawiki-extensions-Echo/includes/ResourceLoaderEchoImageModule.php
Moriel Schottlender 5fefbe4b03 Add a rasterized email icons to Echo modules for email
Make sure we send rasterized png emails instead of SVGs in the
email formatter.

Bug: T127794
Change-Id: Ia28757bda521ec182f75458c8e52d54847d15681
2016-08-16 00:21:13 +00:00

60 lines
1.8 KiB
PHP

<?php
/**
* 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
*/
/**
* A sibling of secret special sauce.
* @see ResourceLoaderOOUIImageModule for familial resemblence
*/
class ResourceLoaderEchoImageModule extends ResourceLoaderImageModule {
protected function loadFromDefinition() {
global $wgEchoNotificationIcons;
if ( $this->definition === null ) {
return;
}
$images = array();
foreach ( $wgEchoNotificationIcons as $iconName => $definition ) {
// FIXME: We also have a 'site' icon which is "magical"
// and uses witchcraft and should be handled specifically
$paths = '';
if ( isset( $definition[ 'path' ] ) ) {
if ( is_array( $definition[ 'path' ] ) ) {
foreach ( $definition[ 'path' ] as $dir => $p ) {
// Has both rtl and ltr definitions
$paths[ $dir ] = $p;
}
} else {
$paths = $definition[ 'path' ];
}
if ( !empty( $paths ) ) {
$images[ $iconName ][ 'file' ] = $paths;
}
}
}
$this->definition[ 'images' ] = $images;
$this->definition[ 'selector' ] = '.oo-ui-icon-{name}';
// Parent
parent::loadFromDefinition();
}
}