[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * @author Niklas Laxström 5 * @license GPL-2.0+ 6 */ 7 8 /** 9 * Interface for classes which provide list of components, which should be 10 * included for l10n updates. 11 */ 12 class LU_Finder { 13 /** 14 * @param array $php See $wgExtensionMessagesFiles 15 * @param array $json See $wgMessagesDirs 16 * @param string $core Absolute path to MediaWiki core 17 */ 18 public function __construct( $php, $json, $core ) { 19 $this->php = $php; 20 $this->json = $json; 21 $this->core = $core; 22 } 23 24 /** 25 * @return array 26 */ 27 public function getComponents() { 28 $components = array(); 29 30 // For older versions of Mediawiki, pull json updates even though its still using php 31 if ( !isset( $this->json['core'] ) ) { 32 $components['core'] = array( 33 'repo' => 'mediawiki', 34 'orig' => "file://{$this->core}/languages/messages/Messages*.php", 35 'path' => 'languages/messages/i18n/*.json', 36 ); 37 } 38 39 foreach ( $this->json as $key => $value ) { 40 // Json should take priority if both exist 41 unset( $this->php[$key] ); 42 43 foreach ( (array)$value as $subkey => $subvalue ) { 44 // This ignores magic, alias etc. non message files 45 $matches = array(); 46 $ok = preg_match( '~/extensions/(?P<name>[^/]+)/(?P<path>.*)$~', $subvalue, $matches ); 47 if ( !$ok ) { 48 continue; 49 } 50 51 $components["$key-$subkey"] = array( 52 'repo' => 'extension', 53 'name' => $matches['name'], 54 'orig' => "file://$subvalue/*.json", 55 'path' => "{$matches['path']}/*.json", 56 ); 57 } 58 } 59 60 foreach ( $this->php as $key => $value ) { 61 // This currently skips core i18n files like resources/oojs-ui/i18n 62 $matches = array(); 63 $ok = preg_match( '~/extensions/(?P<name>[^/]+)/(?P<path>.*\.i18n\.php)$~', $value, $matches ); 64 if ( !$ok ) { 65 continue; 66 } 67 68 $components[$key] = array( 69 'repo' => 'extension', 70 'name' => $matches['name'], 71 'orig' => "file://$value", 72 'path' => $matches['path'], 73 ); 74 } 75 76 return $components; 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |