MediaWiki REL1_33
Finder.php
Go to the documentation of this file.
1<?php
8namespace LocalisationUpdate;
9
14class Finder {
15
19 private $php;
20
24 private $json;
25
29 private $core;
35 public function __construct( $php, $json, $core ) {
36 $this->php = $php;
37 $this->json = $json;
38 $this->core = $core;
39 }
40
44 public function getComponents() {
45 $components = [];
46
47 // For older versions of Mediawiki, pull json updates even though its still using php
48 if ( !isset( $this->json['core'] ) ) {
49 $components['core'] = [
50 'repo' => 'mediawiki',
51 'orig' => "file://{$this->core}/languages/messages/Messages*.php",
52 'path' => 'languages/messages/i18n/*.json',
53 ];
54 }
55
56 foreach ( $this->json as $key => $value ) {
57 // Json should take priority if both exist
58 unset( $this->php[$key] );
59
60 foreach ( (array)$value as $subkey => $subvalue ) {
61 // Mediawiki core files
62 $matches = [];
63 if ( preg_match( '~/(?P<path>(?:includes|languages|resources)/.*)$~', $subvalue, $matches ) ) {
64 $components["$key-$subkey"] = [
65 'repo' => 'mediawiki',
66 'orig' => "file://$value/*.json",
67 'path' => "{$matches['path']}/*.json",
68 ];
69 continue;
70 }
71
72 $item = $this->getItem( 'extensions', $subvalue );
73 if ( $item !== null ) {
74 $item['repo'] = 'extension';
75 $components["$key-$subkey"] = $item;
76 continue;
77 }
78
79 $item = $this->getItem( 'skins', $subvalue );
80 if ( $item !== null ) {
81 $item['repo'] = 'skin';
82 $components["$key-$subkey"] = $item;
83 continue;
84 }
85 }
86 }
87
88 foreach ( $this->php as $key => $value ) {
89 $matches = [];
90 $ok = preg_match( '~/extensions/(?P<name>[^/]+)/(?P<path>.*\.i18n\.php)$~', $value, $matches );
91 if ( !$ok ) {
92 continue;
93 }
94
95 $components[$key] = [
96 'repo' => 'extension',
97 'name' => $matches['name'],
98 'orig' => "file://$value",
99 'path' => $matches['path'],
100 ];
101 }
102
103 return $components;
104 }
105
111 private function getItem( $dir, $subvalue ) {
112 // This ignores magic, alias etc. non message files
113 $matches = [];
114 if ( !preg_match( "~/$dir/(?P<name>[^/]+)/(?P<path>.*)$~", $subvalue, $matches ) ) {
115 return null;
116 }
117
118 return [
119 'name' => $matches['name'],
120 'orig' => "file://$subvalue/*.json",
121 'path' => "{$matches['path']}/*.json",
122 ];
123 }
124}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
The package json
Definition README.txt:1
Interface for classes which provide list of components, which should be included for l10n updates.
Definition Finder.php:14
__construct( $php, $json, $core)
Definition Finder.php:35
getItem( $dir, $subvalue)
Definition Finder.php:111
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))