Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -327,10 +327,6 @@ |
328 | 328 | public function getMessageFile( $code ) { return $this->messageFile; } |
329 | 329 | public function setMessageFile( $value ) { $this->messageFile = $value; } |
330 | 330 | |
331 | | - public function getMessageFilePath( $code ) { |
332 | | - return $wgTranslateExtensionDirectory; |
333 | | - } |
334 | | - |
335 | 331 | public function setDescriptionMsg( $key, $url ) { |
336 | 332 | global $wgLang; |
337 | 333 | |
Index: trunk/extensions/Translate/utils/StringMatcher.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | interface StringMangler { |
4 | 4 | public static function EmptyMatcher(); |
| 5 | + public function setConf( $configuration ); |
5 | 6 | |
6 | 7 | // String or array |
7 | 8 | public function match( $string ); |
— | — | @@ -19,22 +20,16 @@ |
20 | 21 | return new StringMatcher( '', array() ); |
21 | 22 | } |
22 | 23 | |
23 | | - public function __construct( $conf ) { |
24 | | - $prefix = ''; |
25 | | - $patterns = array(); |
26 | | - |
27 | | - if ( isset($conf['prefix']) && is_string($conf['prefix']) ) { |
28 | | - $prefix = $conf['prefix']; |
29 | | - } |
30 | | - |
31 | | - if ( isset($conf['patterns']) && is_array($conf['patterns']) ) { |
32 | | - $patterns = $conf['patterns']; |
33 | | - } |
34 | | - |
| 24 | + public function __construct( $prefix, $patterns = array() ) { |
35 | 25 | $this->sPrefix = $prefix; |
36 | 26 | $this->init( $patterns ); |
37 | 27 | } |
38 | 28 | |
| 29 | + public function setConf( $conf ) { |
| 30 | + $this->sPrefix = $conf['prefix']; |
| 31 | + $this->init( $conf['patterns'] ); |
| 32 | + } |
| 33 | + |
39 | 34 | protected function init( Array $strings ) { |
40 | 35 | foreach ( $strings as $string ) { |
41 | 36 | $pos = strpos( $string, '*' ); |
Index: trunk/extensions/Translate/Groups.php |
— | — | @@ -81,7 +81,8 @@ |
82 | 82 | |
83 | 83 | // TODO: branch handling, merge with upper branch keys |
84 | 84 | $class = $this->getFromConf( 'MANGLER','class' ); |
85 | | - $this->mangler = new $class($this->conf['MANGLER']); |
| 85 | + $this->mangler = new $class(); |
| 86 | + $this->mangler->setConf( $this->conf['MANGLER'] ); |
86 | 87 | } |
87 | 88 | |
88 | 89 | return $this->mangler; |
— | — | @@ -97,20 +98,6 @@ |
98 | 99 | return $collection; |
99 | 100 | } |
100 | 101 | |
101 | | - public function load( $code ) { |
102 | | - if ( $this->exists() ) { |
103 | | - $cache = new MessageGroupCache( $this->getId() ); |
104 | | - if ( !$cache->exists($code) ) return array(); |
105 | | - $messages = array(); |
106 | | - foreach ( $cache->getKeys($code) as $key ) { |
107 | | - $messages[$key] = $cache->get($key); |
108 | | - } |
109 | | - return $messages; |
110 | | - } else { |
111 | | - throw new MWException( 'Not configured properly' ); |
112 | | - } |
113 | | - } |
114 | | - |
115 | 102 | protected function setTags( MessageCollection $collection ) { |
116 | 103 | if ( isset($this->conf['TAGS']) ) { |
117 | 104 | $tags = $this->conf['TAGS']; |
— | — | @@ -165,23 +152,14 @@ |
166 | 153 | class FileBasedMessageGroup extends MessageGroupBase { |
167 | 154 | public function exists() { |
168 | 155 | $ffs = $this->getFFS(); |
169 | | - if ( !$ffs ) throw new MWException( 'No FFS defined' ); |
170 | 156 | $data = $ffs->read( 'en' ); |
171 | 157 | return $data && count($data['MESSAGES']); |
172 | 158 | } |
173 | 159 | |
174 | 160 | public function load( $code ) { |
175 | | - $cache = new MessageGroupCache( $this->getId() ); |
176 | | - if ( $cache->exists() ) { |
177 | | - return parent::load( $code ); |
178 | | - } else { |
179 | | - // Short-circuit cache |
180 | | - $ffs = $this->getFFS(); |
181 | | - if ( !$ffs ) throw new MWException( 'No FFS defined' ); |
182 | | - $data = $ffs->read( $code ); |
183 | | - |
184 | | - return $data ? $data['MESSAGES'] : array(); |
185 | | - } |
| 161 | + $ffs = $this->getFFS(); |
| 162 | + $data = $ffs->read( $code ); |
| 163 | + return $data ? $data['MESSAGES'] : array(); |
186 | 164 | } |
187 | 165 | |
188 | 166 | public function getSourceFilePath( $code ) { |
— | — | @@ -220,10 +198,6 @@ |
221 | 199 | } |
222 | 200 | } |
223 | 201 | |
224 | | -/*class CollectionMessageGroup extends MessageGroupBase { |
225 | | - |
226 | | -}*/ |
227 | | - |
228 | 202 | class MediaWikiMessageGroup extends FileBasedMessageGroup { |
229 | 203 | protected function mapCode( $code ) { |
230 | 204 | return ucfirst( str_replace( '-', '_', parent::mapCode($code) ) ); |