3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 * Secret special sauce.
26 class ResourceLoaderOOUIImageModule
extends ResourceLoaderImageModule
{
27 protected function loadFromDefinition() {
28 if ( $this->definition
=== null ) {
32 // Core default themes
33 $themes = array( 'default' => 'mediawiki' );
34 $themes +
= ExtensionRegistry
::getInstance()->getAttribute( 'SkinOOUIThemes' );
36 $name = $this->definition
['name'];
37 $rootPath = $this->definition
['rootPath'];
39 $definition = array();
40 foreach ( $themes as $skin => $theme ) {
41 // TODO Allow extensions to specify this path somehow
42 $dataPath = $this->localBasePath
. '/' . $rootPath . '/' . $theme . '/' . $name . '.json';
44 if ( file_exists( $dataPath ) ) {
45 $data = json_decode( file_get_contents( $dataPath ), true );
46 $fixPath = function ( &$path ) use ( $rootPath, $theme ) {
47 // TODO Allow extensions to specify this path somehow
48 $path = $rootPath . '/' . $theme . '/' . $path;
50 array_walk( $data['images'], function ( &$value ) use ( $fixPath ) {
51 if ( is_string( $value['file'] ) ) {
52 $fixPath( $value['file'] );
53 } elseif ( is_array( $value['file'] ) ) {
54 array_walk_recursive( $value['file'], $fixPath );
61 foreach ( $data as $key => $value ) {
65 $definition[$key][$skin] = $data[$key];
69 if ( !isset( $definition[$key] ) ) {
70 $definition[$key] = $data[$key];
71 } elseif ( $definition[$key] !== $data[$key] ) {
73 "Mismatched OOUI theme definitions are not supported: trying to load $key of $theme theme"
81 // Fields from definition silently override keys from JSON files
82 $this->definition +
= $definition;
84 parent
::loadFromDefinition();