Index: trunk/extensions/LocalisationUpdate/QuickArrayReader.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | */ |
11 | 11 | class QuickArrayReader { |
12 | 12 | var $vars = array(); |
13 | | - |
| 13 | + |
14 | 14 | function __construct( $string ) { |
15 | 15 | $scalarTypes = array( |
16 | 16 | T_LNUMBER => true, |
— | — | @@ -36,30 +36,30 @@ |
37 | 37 | // '$messages' -> 'messages' |
38 | 38 | $varname = trim( substr( $tokens[$i][1], 1 ) ); |
39 | 39 | $varindex = null; |
40 | | - |
| 40 | + |
41 | 41 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
42 | | - |
| 42 | + |
43 | 43 | if( $tokens[$i] === '[' ) { |
44 | 44 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
45 | | - |
| 45 | + |
46 | 46 | if( isset($scalarTypes[$tokens[$i][0]] ) ) { |
47 | 47 | $varindex = $this->parseScalar( $tokens[$i] ); |
48 | 48 | } else { |
49 | 49 | throw $this->except( $tokens[$i], 'scalar index' ); |
50 | 50 | } |
51 | 51 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
52 | | - |
| 52 | + |
53 | 53 | if( $tokens[$i] !== ']' ) { |
54 | 54 | throw $this->except( $tokens[$i], ']' ); |
55 | 55 | } |
56 | 56 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
57 | 57 | } |
58 | | - |
| 58 | + |
59 | 59 | if( $tokens[$i] !== '=' ) { |
60 | 60 | throw $this->except( $tokens[$i], '=' ); |
61 | 61 | } |
62 | 62 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
63 | | - |
| 63 | + |
64 | 64 | if( isset($scalarTypes[$tokens[$i][0]] ) ) { |
65 | 65 | $buildval = $this->parseScalar( $tokens[$i] ); |
66 | 66 | } elseif( $tokens[$i][0] === T_ARRAY ) { |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | $buildval = array(); |
72 | 72 | do { |
73 | 73 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
74 | | - |
| 74 | + |
75 | 75 | if( $tokens[$i] === ')' ) { |
76 | 76 | break; |
77 | 77 | } |
— | — | @@ -78,18 +78,18 @@ |
79 | 79 | $key = $this->parseScalar( $tokens[$i] ); |
80 | 80 | } |
81 | 81 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
82 | | - |
| 82 | + |
83 | 83 | if( $tokens[$i][0] !== T_DOUBLE_ARROW ) { |
84 | 84 | throw $this->except( $tokens[$i], '=>' ); |
85 | 85 | } |
86 | 86 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
87 | | - |
| 87 | + |
88 | 88 | if( isset($scalarTypes[$tokens[$i][0]] ) ) { |
89 | 89 | $val = $this->parseScalar( $tokens[$i] ); |
90 | 90 | } |
91 | 91 | @$buildval[$key] = $val; |
92 | 92 | while( isset($skipTypes[$tokens[++$i][0]] ) ); |
93 | | - |
| 93 | + |
94 | 94 | if( $tokens[$i] === ',' ) { |
95 | 95 | continue; |
96 | 96 | } elseif( $tokens[$i] === ')' ) { |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | | - |
| 121 | + |
122 | 122 | private function except( $got, $expected ) { |
123 | 123 | if( is_array( $got ) ) { |
124 | 124 | $got = token_name( $got[0] ) . " ('" . $got[1] . "')"; |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | // be useful for a change |
162 | 162 | return $str; |
163 | 163 | } |
164 | | - |
| 164 | + |
165 | 165 | function getVar( $varname ) { |
166 | 166 | if( isset( $this->vars[$varname] ) ) { |
167 | 167 | return $this->vars[$varname]; |
Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | | - * Update the Mediawiki Core Messages. |
| 128 | + * Update the MediaWiki Core Messages. |
129 | 129 | * |
130 | 130 | * @param $verbose Boolean |
131 | 131 | * |
— | — | @@ -179,7 +179,7 @@ |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Log some nice info. |
183 | | - self::myLog( "{$changedCount} Mediawiki messages are updated" ); |
| 183 | + self::myLog( "{$changedCount} MediaWiki messages are updated" ); |
184 | 184 | |
185 | 185 | return $changedCount; |
186 | 186 | } |
— | — | @@ -606,6 +606,11 @@ |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
| 610 | + /** |
| 611 | + * @param $php |
| 612 | + * @param $varname |
| 613 | + * @return bool|array |
| 614 | + */ |
610 | 615 | public static function parsePHP( $php, $varname ) { |
611 | 616 | try { |
612 | 617 | $reader = new QuickArrayReader("<?php $php"); |