r66053 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66052‎ | r66053 | r66054 >
Date:22:33, 7 May 2010
Author:tparscal
Status:ok
Tags:
Comment:
Updated the workflow to have 3 modes, anon, on and off.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitchLink.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitchLink.i18n.php
@@ -14,15 +14,18 @@
1515 * @author Trevor Parscal
1616 */
1717 $messages['en'] = array(
18 - 'prefswitch-link' => 'New!',
19 - 'tooltip-pt-prefswitch-link' => 'Try out new features',
 18+ 'prefswitch-link-anon' => 'New features',
 19+ 'tooltip-pt-prefswitch-link-anon' => 'Learn about new features',
 20+ 'prefswitch-link-on' => 'Take me back',
 21+ 'tooltip-pt-prefswitch-link-on' => 'Disable new features',
 22+ 'prefswitch-link-off' => 'New features',
 23+ 'tooltip-pt-prefswitch-link-off' => 'Try out new features',
2024 );
2125
2226 /** Message documentation (Message documentation)
2327 * @author EugeneZelenko
2428 */
2529 $messages['qqq'] = array(
26 - 'prefswitch-link' => '{{Identical|New}}',
2730 );
2831
2932 /** Arabic (العربية)
@@ -30,8 +33,7 @@
3134 * @author OsamaK
3235 */
3336 $messages['ar'] = array(
34 - 'prefswitch-link' => 'جديد!',
35 - 'tooltip-pt-prefswitch-link' => 'جرّب المزايا الجديدة',
 37+ 'tooltip-pt-prefswitch-link-off' => 'جرّب المزايا الجديدة',
3638 );
3739
3840 /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
@@ -39,179 +41,138 @@
4042 * @author Jim-by
4143 */
4244 $messages['be-tarask'] = array(
43 - 'prefswitch-link' => 'Новае!',
44 - 'tooltip-pt-prefswitch-link' => 'Паспрабуйце нашыя новыя магчымасьці',
 45+ 'tooltip-pt-prefswitch-link-off' => 'Паспрабуйце нашыя новыя магчымасьці',
4546 );
4647
4748 /** Bengali (বাংলা)
4849 * @author Bellayet
4950 */
5051 $messages['bn'] = array(
51 - 'prefswitch-link' => 'নতুন!',
52 - 'tooltip-pt-prefswitch-link' => 'নতুন বৈশিষ্ট্যগুলো ব্যবহার করুন',
 52+ 'tooltip-pt-prefswitch-link-off' => 'নতুন বৈশিষ্ট্যগুলো ব্যবহার করুন',
5353 );
5454
5555 /** Breton (Brezhoneg)
5656 * @author Y-M D
5757 */
5858 $messages['br'] = array(
59 - 'prefswitch-link' => 'Nevez',
60 - 'tooltip-pt-prefswitch-link' => 'Esaeañ elfennoù nevez',
 59+ 'tooltip-pt-prefswitch-link-off' => 'Esaeañ elfennoù nevez',
6160 );
6261
6362 /** Catalan (Català)
6463 * @author Paucabot
6564 */
6665 $messages['ca'] = array(
67 - 'prefswitch-link' => 'Nou!',
68 - 'tooltip-pt-prefswitch-link' => 'Proveu les noves funcions',
 66+ 'tooltip-pt-prefswitch-link-off' => 'Proveu les noves funcions',
6967 );
7068
7169 /** Czech (Česky)
7270 * @author Kuvaly
7371 */
7472 $messages['cs'] = array(
75 - 'prefswitch-link' => 'Novinky!',
76 - 'tooltip-pt-prefswitch-link' => 'Vyzkoušejte nové funkce',
 73+ 'tooltip-pt-prefswitch-link-off' => 'Vyzkoušejte nové funkce',
7774 );
7875
7976 /** German (Deutsch) */
8077 $messages['de'] = array(
81 - 'prefswitch-link' => 'Neu',
82 - 'tooltip-pt-prefswitch-link' => 'Neue Features ausprobieren',
 78+ 'tooltip-pt-prefswitch-link-off' => 'Neue Features ausprobieren',
8379 );
8480
8581 /** Lower Sorbian (Dolnoserbski)
8682 * @author Michawiki
8783 */
8884 $messages['dsb'] = array(
89 - 'prefswitch-link' => 'Nowy!',
90 - 'tooltip-pt-prefswitch-link' => 'Nowe funkcije wopytaś',
 85+ 'tooltip-pt-prefswitch-link-off' => 'Nowe funkcije wopytaś',
9186 );
9287
9388 /** Greek (Ελληνικά)
9489 * @author Απεργός
9590 */
9691 $messages['el'] = array(
97 - 'prefswitch-link' => 'Νέο!',
98 - 'tooltip-pt-prefswitch-link' => 'Δοκιμάστε καινούριες λειτουργίες',
 92+ 'tooltip-pt-prefswitch-link-off' => 'Δοκιμάστε καινούριες λειτουργίες',
9993 );
10094
10195 /** Esperanto (Esperanto)
10296 * @author Yekrats
10397 */
10498 $messages['eo'] = array(
105 - 'prefswitch-link' => 'Nova!',
106 - 'tooltip-pt-prefswitch-link' => 'Provi novajn funkciojn',
 99+ 'tooltip-pt-prefswitch-link-off' => 'Provi novajn funkciojn',
107100 );
108101
109102 /** Spanish (Español)
110103 * @author Pertile
111104 */
112105 $messages['es'] = array(
113 - 'prefswitch-link' => '¡Nuevo!',
114 - 'tooltip-pt-prefswitch-link' => 'Probar las nuevas características',
 106+ 'tooltip-pt-prefswitch-link-off' => 'Probar las nuevas características',
115107 );
116108
117 -/** Estonian (Eesti)
118 - * @author Hendrik
119 - */
120 -$messages['et'] = array(
121 - 'prefswitch-link' => 'Uus!',
122 -);
123 -
124 -/** Basque (Euskara)
125 - * @author Joxemai
126 - */
127 -$messages['eu'] = array(
128 - 'prefswitch-link' => 'Berria!',
129 -);
130 -
131109 /** Finnish (Suomi)
132110 * @author Crt
133111 */
134112 $messages['fi'] = array(
135 - 'prefswitch-link' => 'Uutta!',
136 - 'tooltip-pt-prefswitch-link' => 'Kokeile uusia ominaisuuksia',
 113+ 'tooltip-pt-prefswitch-link-off' => 'Kokeile uusia ominaisuuksia',
137114 );
138115
139116 /** French (Français)
140117 * @author IAlex
141118 */
142119 $messages['fr'] = array(
143 - 'prefswitch-link' => 'Nouveau !',
144 - 'tooltip-pt-prefswitch-link' => 'Essayer les nouvelles fonctionnalités',
 120+ 'tooltip-pt-prefswitch-link-off' => 'Essayer les nouvelles fonctionnalités',
145121 );
146122
147123 /** Galician (Galego)
148124 * @author Toliño
149125 */
150126 $messages['gl'] = array(
151 - 'prefswitch-link' => 'Novo!',
152 - 'tooltip-pt-prefswitch-link' => 'Probar as novas características',
 127+ 'tooltip-pt-prefswitch-link-off' => 'Probar as novas características',
153128 );
154129
155130 /** Swiss German (Alemannisch)
156131 * @author Als-Holder
157132 */
158133 $messages['gsw'] = array(
159 - 'prefswitch-link' => 'Nej!',
160 - 'tooltip-pt-prefswitch-link' => 'Di neje Funktione uusprobiere',
 134+ 'tooltip-pt-prefswitch-link-off' => 'Di neje Funktione uusprobiere',
161135 );
162136
163137 /** Hebrew (עברית)
164138 * @author Amire80
165139 */
166140 $messages['he'] = array(
167 - 'prefswitch-link' => 'חדש!',
168 - 'tooltip-pt-prefswitch-link' => 'לנסות תכונות חדשות',
 141+ 'tooltip-pt-prefswitch-link-off' => 'לנסות תכונות חדשות',
169142 );
170143
171 -/** Croatian (Hrvatski)
172 - * @author Ex13
173 - */
174 -$messages['hr'] = array(
175 - 'prefswitch-link' => 'Novo!',
176 -);
177 -
178144 /** Upper Sorbian (Hornjoserbsce)
179145 * @author Michawiki
180146 */
181147 $messages['hsb'] = array(
182 - 'prefswitch-link' => 'Nowy!',
183 - 'tooltip-pt-prefswitch-link' => 'Nowe funkcije wupruwować',
 148+ 'tooltip-pt-prefswitch-link-off' => 'Nowe funkcije wupruwować',
184149 );
185150
186151 /** Hungarian (Magyar)
187152 * @author Glanthor Reviol
188153 */
189154 $messages['hu'] = array(
190 - 'prefswitch-link' => 'Újdonság!',
191 - 'tooltip-pt-prefswitch-link' => 'Próbáld ki az új funkciókat',
 155+ 'tooltip-pt-prefswitch-link-off' => 'Próbáld ki az új funkciókat',
192156 );
193157
194158 /** Interlingua (Interlingua)
195159 * @author McDutchie
196160 */
197161 $messages['ia'] = array(
198 - 'prefswitch-link' => 'Nove!',
199 - 'tooltip-pt-prefswitch-link' => 'Probar nove functiones',
 162+ 'tooltip-pt-prefswitch-link-off' => 'Probar nove functiones',
200163 );
201164
202165 /** Indonesian (Bahasa Indonesia)
203166 * @author Kenrick95
204167 */
205168 $messages['id'] = array(
206 - 'prefswitch-link' => 'Baru!',
207 - 'tooltip-pt-prefswitch-link' => 'Coba fitur baru',
 169+ 'tooltip-pt-prefswitch-link-off' => 'Coba fitur baru',
208170 );
209171
210172 /** Italian (Italiano)
211173 * @author Una giornata uggiosa '94
212174 */
213175 $messages['it'] = array(
214 - 'prefswitch-link' => 'Nuovo!',
215 - 'tooltip-pt-prefswitch-link' => 'Prova le nuove funzioni',
 176+ 'tooltip-pt-prefswitch-link-off' => 'Prova le nuove funzioni',
216177 );
217178
218179 /** Japanese (日本語)
@@ -220,142 +181,124 @@
221182 * @author 青子守歌
222183 */
223184 $messages['ja'] = array(
224 - 'prefswitch-link' => '新機能!',
225 - 'tooltip-pt-prefswitch-link' => '新機能を試す',
 185+ 'tooltip-pt-prefswitch-link-off' => '新機能を試す',
226186 );
227187
228188 /** Georgian (ქართული)
229189 * @author გიორგიმელა
230190 */
231191 $messages['ka'] = array(
232 - 'prefswitch-link' => 'ახალი',
233 - 'tooltip-pt-prefswitch-link' => 'სცადეთ ახალი ხელსაწყოები',
 192+ 'tooltip-pt-prefswitch-link-off' => 'სცადეთ ახალი ხელსაწყოები',
234193 );
235194
236195 /** Korean (한국어)
237196 * @author Devunt
238197 */
239198 $messages['ko'] = array(
240 - 'prefswitch-link' => '새 기능!',
241 - 'tooltip-pt-prefswitch-link' => '새 기능 체험하기',
 199+ 'tooltip-pt-prefswitch-link-off' => '새 기능 체험하기',
242200 );
243201
244202 /** Luxembourgish (Lëtzebuergesch)
245203 * @author Robby
246204 */
247205 $messages['lb'] = array(
248 - 'prefswitch-link' => 'Nei!',
249 - 'tooltip-pt-prefswitch-link' => 'Probéiert déi nei Fonctionalitéiten aus',
 206+ 'tooltip-pt-prefswitch-link-off' => 'Probéiert déi nei Fonctionalitéiten aus',
250207 );
251208
252209 /** Latvian (Latviešu)
253210 * @author Papuass
254211 */
255212 $messages['lv'] = array(
256 - 'prefswitch-link' => 'Kas jauns?',
257213 );
258214
259215 /** Macedonian (Македонски)
260216 * @author Bjankuloski06
261217 */
262218 $messages['mk'] = array(
263 - 'prefswitch-link' => 'Ново!',
264 - 'tooltip-pt-prefswitch-link' => 'Испробајте нови функции',
 219+ 'tooltip-pt-prefswitch-link-off' => 'Испробајте нови функции',
265220 );
266221
267222 /** Malayalam (മലയാളം)
268223 * @author Praveenp
269224 */
270225 $messages['ml'] = array(
271 - 'prefswitch-link' => 'നൂതനം!',
272 - 'tooltip-pt-prefswitch-link' => 'പുതിയ സവിശേഷതകൾ പരീക്ഷിക്കുക',
 226+ 'tooltip-pt-prefswitch-link-off' => 'പുതിയ സവിശേഷതകൾ പരീക്ഷിക്കുക',
273227 );
274228
275229 /** Dutch (Nederlands)
276230 * @author Siebrand
277231 */
278232 $messages['nl'] = array(
279 - 'prefswitch-link' => 'Nieuw!',
280 - 'tooltip-pt-prefswitch-link' => 'Nieuwe mogelijkheden uitproberen',
 233+ 'tooltip-pt-prefswitch-link-off' => 'Nieuwe mogelijkheden uitproberen',
281234 );
282235
283236 /** Norwegian (bokmål)‬ (‪Norsk (bokmål)‬)
284237 * @author Nghtwlkr
285238 */
286239 $messages['no'] = array(
287 - 'prefswitch-link' => 'Ny',
288 - 'tooltip-pt-prefswitch-link' => 'Prøv nye funksjoner',
 240+ 'tooltip-pt-prefswitch-link-off' => 'Prøv nye funksjoner',
289241 );
290242
291243 /** Occitan (Occitan)
292244 * @author Cedric31
293245 */
294246 $messages['oc'] = array(
295 - 'prefswitch-link' => 'Novèl !',
296 - 'tooltip-pt-prefswitch-link' => 'Ensajatz las foncionalitats novèlas',
 247+ 'tooltip-pt-prefswitch-link-off' => 'Ensajatz las foncionalitats novèlas',
297248 );
298249
299250 /** Polish (Polski)
300251 * @author Sp5uhe
301252 */
302253 $messages['pl'] = array(
303 - 'prefswitch-link' => 'Nowy wygląd!',
304 - 'tooltip-pt-prefswitch-link' => 'Wypróbuj nowe funkcjonalności',
 254+ 'tooltip-pt-prefswitch-link-off' => 'Wypróbuj nowe funkcjonalności',
305255 );
306256
307257 /** Piedmontese (Piemontèis)
308258 * @author Dragonòt
309259 */
310260 $messages['pms'] = array(
311 - 'prefswitch-link' => 'Neuv!',
312 - 'tooltip-pt-prefswitch-link' => 'Preuva le neuve funsionalità',
 261+ 'tooltip-pt-prefswitch-link-off' => 'Preuva le neuve funsionalità',
313262 );
314263
315264 /** Portuguese (Português)
316265 * @author Hamilton Abreu
317266 */
318267 $messages['pt'] = array(
319 - 'prefswitch-link' => 'Novo!',
320 - 'tooltip-pt-prefswitch-link' => 'Experimente novas funcionalidades',
 268+ 'tooltip-pt-prefswitch-link-off' => 'Experimente novas funcionalidades',
321269 );
322270
323271 /** Russian (Русский)
324272 * @author Александр Сигачёв
325273 */
326274 $messages['ru'] = array(
327 - 'prefswitch-link' => 'Новинка!',
328 - 'tooltip-pt-prefswitch-link' => 'Опробуйте новые возможности',
 275+ 'tooltip-pt-prefswitch-link-off' => 'Опробуйте новые возможности',
329276 );
330277
331278 /** Slovenian (Slovenščina)
332279 * @author Dbc334
333280 */
334281 $messages['sl'] = array(
335 - 'prefswitch-link' => 'Novo!',
336 - 'tooltip-pt-prefswitch-link' => 'Preizkusite nove funkcije',
 282+ 'tooltip-pt-prefswitch-link-off' => 'Preizkusite nove funkcije',
337283 );
338284
339285 /** Telugu (తెలుగు)
340286 * @author Veeven
341287 */
342288 $messages['te'] = array(
343 - 'prefswitch-link' => 'కొత్తది!',
344 - 'tooltip-pt-prefswitch-link' => 'కొత్త సౌలభ్యాలను ప్రయత్నించండి',
 289+ 'tooltip-pt-prefswitch-link-off' => 'కొత్త సౌలభ్యాలను ప్రయత్నించండి',
345290 );
346291
347292 /** Turkish (Türkçe)
348293 * @author Joseph
349294 */
350295 $messages['tr'] = array(
351 - 'prefswitch-link' => 'Yeni!',
352 - 'tooltip-pt-prefswitch-link' => 'Yeni özellikleri dene',
 296+ 'tooltip-pt-prefswitch-link-off' => 'Yeni özellikleri dene',
353297 );
354298
355299 /** Vietnamese (Tiếng Việt)
356300 * @author Minh Nguyen
357301 */
358302 $messages['vi'] = array(
359 - 'prefswitch-link' => 'Mới!',
360 - 'tooltip-pt-prefswitch-link' => 'Hãy thử các tính năng mới',
 303+ 'tooltip-pt-prefswitch-link-off' => 'Hãy thử các tính năng mới',
361304 );
362305
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.i18n.php
@@ -79,6 +79,8 @@
8080 * Link wizard: An easy-to-use tool allows you to add links to other wiki pages as well as links to external sites.
8181 * Search improvements: We have improved search suggestions to get you to the page you are looking for more quickly.
8282 * Other new features: We have also introduced a table wizard to make creating tables easier and find and a replace feature to simplify page editing.",
 83+ 'prefswitch-main-anon' => "===Take Me Back===
 84+If you would like to turn off the new features, <span class=\"plainlinks\">[$1 click here]</span>. You will be asked to login or create an account first.",
8385 'prefswitch-main-on' => "===Feedback?===
8486 We would love to hear from you. Please visit our <span class=\"plainlinks\">[$1 feedback page]</span>.
8587 ===Take me back!===
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/SpecialPrefSwitch.php
@@ -46,6 +46,15 @@
4747 }
4848 return false;
4949 }
 50+ /*
 51+ * Returns a string representing the current state of a given user. There are 3 modes the system can be in, 'anon',
 52+ * 'on' or 'off'. If the user is not logged in, the mode is always 'anon'. If the user is logged in, the mode will
 53+ * be 'on' if SpecialPrefSwitch::isSwitchedOn() returns true, and 'off' otherwise.
 54+ * @param $user User object to check switched state for
 55+ */
 56+ public static function userState( $user ) {
 57+ return $user->isAnon() ? 'anon' : ( self::isSwitchedOn( $user ) ? 'on' : 'off' );
 58+ }
5059 /**
5160 * Switches a user's prefernces on
5261 * @param $user User object to set preferences for
@@ -225,28 +234,32 @@
226235 $wgOut->addWikiMsg(
227236 'prefswitch-main', array( 'parse' )
228237 );
229 - if ( $wgUser->isLoggedIn() ) {
230 - if ( self::isSwitchedOn( $wgUser ) ) {
231 - $wgOut->addWikiMsgArray(
232 - 'prefswitch-main-on',
233 - array(
234 - $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'feedback' ) ) ),
235 - $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'off' ) ) )
236 - ),
237 - array( 'parse' )
238 - );
239 - } else {
240 - $wgOut->addWikiMsgArray(
241 - 'prefswitch-main-off',
242 - array(
243 - $this->getTitle()->getFullURL(
244 - array_merge( $query, array( 'mode' => 'on', 'token' => $wgUser->editToken() ) )
 238+ $state = self::userState( $wgUser );
 239+ switch ( $state ) {
 240+ case 'anon':
 241+ $parameters = array(
 242+ SpecialPage::getTitleFor( 'Userlogin' )->getFullURL(
 243+ array( 'returnto' => $this->getTitle()->getPrefixedText(),
 244+ 'returntoquery' => wfArrayToCGI( array_merge( $query, array( 'mode' => 'off' ) ) )
245245 )
246 - ),
247 - array( 'parse' )
 246+ )
248247 );
249 - }
 248+ break;
 249+ case 'on':
 250+ $parameters = array(
 251+ $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'feedback' ) ) ),
 252+ $this->getTitle()->getFullURL( array_merge( $query, array( 'mode' => 'off' ) ) )
 253+ );
 254+ break;
 255+ case 'off':
 256+ $parameters = array(
 257+ $this->getTitle()->getFullURL(
 258+ array_merge( $query, array( 'mode' => 'on', 'token' => $wgUser->editToken() ) )
 259+ )
 260+ );
 261+ break;
250262 }
 263+ $wgOut->addWikiMsgArray( 'prefswitch-main-' . $state, $parameters, array( 'parse' ) );
251264 }
252265 }
253266 }
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.hooks.php
@@ -31,17 +31,18 @@
3232 } else {
3333 $query = array( 'from' => $title->getPrefixedDBKey(), 'fromquery' => wfArrayToCGI( $fromquery ) );
3434 }
 35+ $state = SpecialPrefSwitch::userState( $wgUser );
3536 // Inserts a link into personal tools
3637 $personal_urls = array_merge(
3738 array(
38 - 'prefswitch-link' => array(
39 - 'text' => wfMsg( 'prefswitch-link' ),
 39+ "prefswitch-link-{$state}" => array(
 40+ 'text' => wfMsg( 'prefswitch-link-' . $state ),
4041 'href' => SpecialPage::getTitleFor( 'PrefSwitch' )->getFullURL( $query ),
4142 'class' => 'no-text-transform',
4243 ),
4344 ),
4445 $personal_urls
45 - );
 46+ );
4647 return true;
4748 }
4849 }

Status & tagging log