Index: trunk/extensions/LiquidThreads/compat/Lqt-compat.i18n.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | // This file is generated automatically by generateCompatibilityLocalisation.php |
4 | 4 | $messages = array ( |
5 | | - 'ar' => |
| 5 | + 'ar' => |
6 | 6 | array ( |
7 | 7 | 'htmlform-reset' => 'الرجوع عن التغييرات', |
8 | 8 | 'htmlform-submit' => 'تنفيذ', |
— | — | @@ -12,13 +12,13 @@ |
13 | 13 | 'htmlform-selectorother-other' => 'أخرى', |
14 | 14 | 'htmlform-invalid-input' => 'توجد مشكلات ضمن بعض من مدخلاتك', |
15 | 15 | ), |
16 | | - 'arc' => |
| 16 | + 'arc' => |
17 | 17 | array ( |
18 | 18 | 'htmlform-reset' => 'ܠܐ ܥܒܘܕ ܫܘܚܠܦ̈ܐ', |
19 | 19 | 'htmlform-submit' => 'ܫܕܪ', |
20 | 20 | 'htmlform-selectorother-other' => 'ܐܚܪܢܐ', |
21 | 21 | ), |
22 | | - 'arz' => |
| 22 | + 'arz' => |
23 | 23 | array ( |
24 | 24 | 'htmlform-reset' => 'الرجوع فى التغييرات', |
25 | 25 | 'htmlform-submit' => 'تقديم', |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | 'htmlform-selectorother-other' => 'تانيين', |
31 | 31 | 'htmlform-invalid-input' => 'فى مشاكل فى المدخلات بتاعتك', |
32 | 32 | ), |
33 | | - 'bcc' => |
| 33 | + 'bcc' => |
34 | 34 | array ( |
35 | 35 | 'htmlform-reset' => 'ترینگ تغییرات', |
36 | 36 | 'htmlform-submit' => 'دیم دی', |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | 'htmlform-selectorother-other' => 'دگه', |
42 | 42 | 'htmlform-invalid-input' => 'لهتی چه ورودی شما مشکل هست', |
43 | 43 | ), |
44 | | - 'be-tarask' => |
| 44 | + 'be-tarask' => |
45 | 45 | array ( |
46 | 46 | 'htmlform-reset' => 'Адмяніць зьмены', |
47 | 47 | 'htmlform-submit' => 'Захаваць', |
— | — | @@ -51,13 +51,13 @@ |
52 | 52 | 'htmlform-selectorother-other' => 'Іншае', |
53 | 53 | 'htmlform-invalid-input' => 'Узьніклі праблемы з некаторымі з Вашых уваходных зьвестак', |
54 | 54 | ), |
55 | | - 'bg' => |
| 55 | + 'bg' => |
56 | 56 | array ( |
57 | 57 | 'htmlform-reset' => 'Отказване на промените', |
58 | 58 | 'htmlform-submit' => 'Изпращане', |
59 | 59 | 'htmlform-selectorother-other' => 'Друга', |
60 | 60 | ), |
61 | | - 'br' => |
| 61 | + 'br' => |
62 | 62 | array ( |
63 | 63 | 'htmlform-reset' => 'Dizober ar c\'hemmoù', |
64 | 64 | 'htmlform-submit' => 'Kas', |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | 'htmlform-selectorother-other' => 'Unan all', |
70 | 70 | 'htmlform-invalid-input' => 'Kudennoù zo gant talvoudennoù zo merket ganeoc\'h.', |
71 | 71 | ), |
72 | | - 'bs' => |
| 72 | + 'bs' => |
73 | 73 | array ( |
74 | 74 | 'htmlform-reset' => 'Vrati izmjene', |
75 | 75 | 'htmlform-submit' => 'Pošalji', |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | 'htmlform-selectorother-other' => 'Ostalo', |
81 | 81 | 'htmlform-invalid-input' => 'Postoje određeni problemi s Vašim unosom', |
82 | 82 | ), |
83 | | - 'ca' => |
| 83 | + 'ca' => |
84 | 84 | array ( |
85 | 85 | 'htmlform-reset' => 'Desfés els canvis', |
86 | 86 | 'htmlform-submit' => 'Tramet', |
— | — | @@ -90,11 +90,11 @@ |
91 | 91 | 'htmlform-selectorother-other' => 'Altres', |
92 | 92 | 'htmlform-invalid-input' => 'Hi ha problemes amb alguna de les seves entrades', |
93 | 93 | ), |
94 | | - 'ckb-arab' => |
| 94 | + 'ckb-arab' => |
95 | 95 | array ( |
96 | 96 | 'htmlform-reset' => 'گەڕانەوەی گۆڕانکاری', |
97 | 97 | ), |
98 | | - 'cs' => |
| 98 | + 'cs' => |
99 | 99 | array ( |
100 | 100 | 'htmlform-reset' => 'Vrátit změny', |
101 | 101 | 'htmlform-submit' => 'Odeslat', |
— | — | @@ -105,12 +105,12 @@ |
106 | 106 | 'htmlform-selectorother-other' => 'Jiná hodnota', |
107 | 107 | 'htmlform-invalid-input' => 'Některé vámi zadané údaje jsou chybné', |
108 | 108 | ), |
109 | | - 'cy' => |
| 109 | + 'cy' => |
110 | 110 | array ( |
111 | 111 | 'htmlform-reset' => 'Datod y newidiadau', |
112 | 112 | 'htmlform-selectorother-other' => 'Arall', |
113 | 113 | ), |
114 | | - 'da' => |
| 114 | + 'da' => |
115 | 115 | array ( |
116 | 116 | 'htmlform-reset' => 'Annuller ændringer', |
117 | 117 | 'htmlform-submit' => 'Gem', |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | 'htmlform-selectorother-other' => 'Anden', |
123 | 123 | 'htmlform-invalid-input' => 'Det er problemer med dine angivelser', |
124 | 124 | ), |
125 | | - 'de' => |
| 125 | + 'de' => |
126 | 126 | array ( |
127 | 127 | 'htmlform-reset' => 'Änderungen rückgängig machen', |
128 | 128 | 'htmlform-submit' => 'Übertragen', |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | 'htmlform-selectorother-other' => 'Andere', |
134 | 134 | 'htmlform-invalid-input' => 'Mit einigen Eingaben gibt es Probleme', |
135 | 135 | ), |
136 | | - 'dsb' => |
| 136 | + 'dsb' => |
137 | 137 | array ( |
138 | 138 | 'htmlform-reset' => 'Změny anulěrowaś', |
139 | 139 | 'htmlform-submit' => 'Wótpósłaś', |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | 'htmlform-selectorother-other' => 'Druge', |
145 | 145 | 'htmlform-invalid-input' => 'Su někotare problemy z twójim zapodaśim', |
146 | 146 | ), |
147 | | - 'el' => |
| 147 | + 'el' => |
148 | 148 | array ( |
149 | 149 | 'htmlform-reset' => 'Αναστροφή αλλαγών', |
150 | 150 | 'htmlform-submit' => 'Υποβολή', |
— | — | @@ -154,7 +154,7 @@ |
155 | 155 | 'htmlform-selectorother-other' => 'Άλλο', |
156 | 156 | 'htmlform-invalid-input' => 'Υπάρχουν κάποια προβλήματα με μερικές από τις εισροές σας', |
157 | 157 | ), |
158 | | - 'en' => |
| 158 | + 'en' => |
159 | 159 | array ( |
160 | 160 | 'htmlform-reset' => 'Undo changes', |
161 | 161 | 'htmlform-submit' => 'Submit', |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | 'htmlform-selectorother-other' => 'Other', |
167 | 167 | 'htmlform-invalid-input' => 'There are problems with some of your input', |
168 | 168 | ), |
169 | | - 'eo' => |
| 169 | + 'eo' => |
170 | 170 | array ( |
171 | 171 | 'htmlform-reset' => 'Malfari ŝanĝojn', |
172 | 172 | 'htmlform-submit' => 'Ek!', |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | 'htmlform-selectorother-other' => 'Alia', |
178 | 178 | 'htmlform-invalid-input' => 'Estas problemoj kun iom da via enigo', |
179 | 179 | ), |
180 | | - 'es' => |
| 180 | + 'es' => |
181 | 181 | array ( |
182 | 182 | 'htmlform-reset' => 'Deshacer cambios', |
183 | 183 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -187,13 +187,13 @@ |
188 | 188 | 'htmlform-selectorother-other' => 'Otro', |
189 | 189 | 'htmlform-invalid-input' => 'Hay problemas con alguno de tus ingresos', |
190 | 190 | ), |
191 | | - 'eu' => |
| 191 | + 'eu' => |
192 | 192 | array ( |
193 | 193 | 'htmlform-reset' => 'Aldaketak desegin', |
194 | 194 | 'htmlform-submit' => 'Bidali', |
195 | 195 | 'htmlform-selectorother-other' => 'Beste bat', |
196 | 196 | ), |
197 | | - 'fa' => |
| 197 | + 'fa' => |
198 | 198 | array ( |
199 | 199 | 'htmlform-reset' => 'خنثی کردن تغییرات', |
200 | 200 | 'htmlform-submit' => 'ارسال', |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | 'htmlform-selectorother-other' => 'دیگر', |
206 | 206 | 'htmlform-invalid-input' => 'بخشی از ورودی شما مشکل دارد', |
207 | 207 | ), |
208 | | - 'fi' => |
| 208 | + 'fi' => |
209 | 209 | array ( |
210 | 210 | 'htmlform-reset' => 'Kumoa muutokset', |
211 | 211 | 'htmlform-submit' => 'Lähetä', |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | 'htmlform-selectorother-other' => 'Muu', |
217 | 217 | 'htmlform-invalid-input' => 'Antamassasi syötteessä on ongelmia', |
218 | 218 | ), |
219 | | - 'fr' => |
| 219 | + 'fr' => |
220 | 220 | array ( |
221 | 221 | 'htmlform-reset' => 'Défaire les modifications', |
222 | 222 | 'htmlform-submit' => 'Soumettre', |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | 'htmlform-selectorother-other' => 'Autre', |
228 | 228 | 'htmlform-invalid-input' => 'Des problèmes sont survenus avec certaines valeurs', |
229 | 229 | ), |
230 | | - 'frp' => |
| 230 | + 'frp' => |
231 | 231 | array ( |
232 | 232 | 'htmlform-reset' => 'Dèfâre los changements', |
233 | 233 | 'htmlform-submit' => 'Sometre', |
— | — | @@ -237,7 +237,7 @@ |
238 | 238 | 'htmlform-selectorother-other' => 'Ôtro', |
239 | 239 | 'htmlform-invalid-input' => 'Des problèmos sont arrevâs avouéc quârques valors', |
240 | 240 | ), |
241 | | - 'gl' => |
| 241 | + 'gl' => |
242 | 242 | array ( |
243 | 243 | 'htmlform-reset' => 'Desfacer os cambios', |
244 | 244 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | 'htmlform-selectorother-other' => 'Outra', |
250 | 250 | 'htmlform-invalid-input' => 'Hai algún problema con partes do texto que inseriu', |
251 | 251 | ), |
252 | | - 'grc' => |
| 252 | + 'grc' => |
253 | 253 | array ( |
254 | 254 | 'htmlform-reset' => 'Ἀναστρέφειν μεταβολάς', |
255 | 255 | 'htmlform-submit' => 'Ὑποβάλλειν', |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | 'htmlform-selectorother-other' => 'Ἄλλον', |
261 | 261 | 'htmlform-invalid-input' => 'Μέρος τῶν εἰσαγομένων δεδομένων σου προβληματικὸν ἐστίν', |
262 | 262 | ), |
263 | | - 'gsw' => |
| 263 | + 'gsw' => |
264 | 264 | array ( |
265 | 265 | 'htmlform-reset' => 'Änderige ruckgängig mache', |
266 | 266 | 'htmlform-submit' => 'Ibertrage', |
— | — | @@ -270,7 +270,7 @@ |
271 | 271 | 'htmlform-selectorother-other' => 'Anderi', |
272 | 272 | 'htmlform-invalid-input' => 'Mit e Teil Yygabe git s Probläm', |
273 | 273 | ), |
274 | | - 'he' => |
| 274 | + 'he' => |
275 | 275 | array ( |
276 | 276 | 'htmlform-reset' => 'ביטול השינויים', |
277 | 277 | 'htmlform-submit' => 'שליחה', |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | 'htmlform-selectorother-other' => 'אחר', |
283 | 283 | 'htmlform-invalid-input' => 'יש בעיות עם חלק מהקלט שהכנסתם', |
284 | 284 | ), |
285 | | - 'hr' => |
| 285 | + 'hr' => |
286 | 286 | array ( |
287 | 287 | 'htmlform-reset' => 'Poništi izmjene', |
288 | 288 | 'htmlform-submit' => 'Pošalji', |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | 'htmlform-selectorother-other' => 'Drugi', |
294 | 294 | 'htmlform-invalid-input' => 'Postoje problemi s nekim od vaših unosa', |
295 | 295 | ), |
296 | | - 'hsb' => |
| 296 | + 'hsb' => |
297 | 297 | array ( |
298 | 298 | 'htmlform-reset' => 'Změny cofnyć', |
299 | 299 | 'htmlform-submit' => 'Wotpósłać', |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | 'htmlform-selectorother-other' => 'Druhe', |
305 | 305 | 'htmlform-invalid-input' => 'Su problemy z twojim zapodaćom', |
306 | 306 | ), |
307 | | - 'hu' => |
| 307 | + 'hu' => |
308 | 308 | array ( |
309 | 309 | 'htmlform-reset' => 'Változtatások visszavonása', |
310 | 310 | 'htmlform-submit' => 'Elküldés', |
— | — | @@ -314,7 +314,7 @@ |
315 | 315 | 'htmlform-selectorother-other' => 'egyéb', |
316 | 316 | 'htmlform-invalid-input' => 'Probléma van az általad megadott értékkel', |
317 | 317 | ), |
318 | | - 'ia' => |
| 318 | + 'ia' => |
319 | 319 | array ( |
320 | 320 | 'htmlform-reset' => 'Disfacer modificationes', |
321 | 321 | 'htmlform-submit' => 'Submitter', |
— | — | @@ -325,7 +325,7 @@ |
326 | 326 | 'htmlform-selectorother-other' => 'Altere', |
327 | 327 | 'htmlform-invalid-input' => 'Il ha problemas con alique que tu entrava', |
328 | 328 | ), |
329 | | - 'id' => |
| 329 | + 'id' => |
330 | 330 | array ( |
331 | 331 | 'htmlform-reset' => 'Batalkan perubahan', |
332 | 332 | 'htmlform-submit' => 'Kirim', |
— | — | @@ -336,7 +336,7 @@ |
337 | 337 | 'htmlform-selectorother-other' => 'Lain-lain', |
338 | 338 | 'htmlform-invalid-input' => 'Ada kesalahan dalam beberapa input Anda', |
339 | 339 | ), |
340 | | - 'it' => |
| 340 | + 'it' => |
341 | 341 | array ( |
342 | 342 | 'htmlform-reset' => 'Annulla modifiche', |
343 | 343 | 'htmlform-submit' => 'Invia', |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | 'htmlform-selectorother-other' => 'Altro', |
349 | 349 | 'htmlform-invalid-input' => 'Ci sono problemi con l\'input inserito', |
350 | 350 | ), |
351 | | - 'ja' => |
| 351 | + 'ja' => |
352 | 352 | array ( |
353 | 353 | 'htmlform-reset' => '変更を取り消す', |
354 | 354 | 'htmlform-submit' => '送信', |
— | — | @@ -358,7 +358,7 @@ |
359 | 359 | 'htmlform-selectorother-other' => 'その他', |
360 | 360 | 'htmlform-invalid-input' => '入力になんらかの問題があります', |
361 | 361 | ), |
362 | | - 'jv' => |
| 362 | + 'jv' => |
363 | 363 | array ( |
364 | 364 | 'htmlform-reset' => 'Batalna pangowahan', |
365 | 365 | 'htmlform-int-invalid' => 'Aji sing panjenengan lebokaké dudu angka wutuh (integer).', |
— | — | @@ -368,7 +368,7 @@ |
369 | 369 | 'htmlform-selectorother-other' => 'Liya', |
370 | 370 | 'htmlform-invalid-input' => 'Ana masalah jroning sawetara input panjenengan', |
371 | 371 | ), |
372 | | - 'ka' => |
| 372 | + 'ka' => |
373 | 373 | array ( |
374 | 374 | 'htmlform-reset' => 'ცვლილებების გაუქმება', |
375 | 375 | 'htmlform-submit' => 'შენახვა', |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | 'htmlform-selectorother-other' => 'სხვა', |
381 | 381 | 'htmlform-invalid-input' => 'თქვენს მიერ შეყვანილი ინფორმაციის ნაწილმა გამოიწვია პრობლემები', |
382 | 382 | ), |
383 | | - 'ko' => |
| 383 | + 'ko' => |
384 | 384 | array ( |
385 | 385 | 'htmlform-reset' => '변경한 것을 되돌리기', |
386 | 386 | 'htmlform-submit' => '저장', |
— | — | @@ -390,7 +390,7 @@ |
391 | 391 | 'htmlform-selectorother-other' => '기타', |
392 | 392 | 'htmlform-invalid-input' => '당신이 입력한 값에 문제가 있습니다.', |
393 | 393 | ), |
394 | | - 'ksh' => |
| 394 | + 'ksh' => |
395 | 395 | array ( |
396 | 396 | 'htmlform-reset' => 'Änderunge retuur nämme', |
397 | 397 | 'htmlform-submit' => 'Loß Jonn!', |
— | — | @@ -401,11 +401,11 @@ |
402 | 402 | 'htmlform-selectorother-other' => 'Annder', |
403 | 403 | 'htmlform-invalid-input' => 'Mer han e Problem met jet wat De enjejovve häß', |
404 | 404 | ), |
405 | | - 'la' => |
| 405 | + 'la' => |
406 | 406 | array ( |
407 | 407 | 'htmlform-selectorother-other' => 'Aliud', |
408 | 408 | ), |
409 | | - 'lb' => |
| 409 | + 'lb' => |
410 | 410 | array ( |
411 | 411 | 'htmlform-reset' => 'Ännerungen zrécksetzen', |
412 | 412 | 'htmlform-submit' => 'Späicheren', |
— | — | @@ -416,7 +416,7 @@ |
417 | 417 | 'htmlform-selectorother-other' => 'Anerer', |
418 | 418 | 'htmlform-invalid-input' => 'Et gëtt Problemer mat de Werter déi dir aginn hutt.', |
419 | 419 | ), |
420 | | - 'lt' => |
| 420 | + 'lt' => |
421 | 421 | array ( |
422 | 422 | 'htmlform-reset' => 'Atšaukti pakeitimus', |
423 | 423 | 'htmlform-submit' => 'Siųsti', |
— | — | @@ -427,7 +427,7 @@ |
428 | 428 | 'htmlform-selectorother-other' => 'Kita', |
429 | 429 | 'htmlform-invalid-input' => 'Yra problemų su jūsų įvestimi', |
430 | 430 | ), |
431 | | - 'lzh' => |
| 431 | + 'lzh' => |
432 | 432 | array ( |
433 | 433 | 'htmlform-reset' => '復', |
434 | 434 | 'htmlform-submit' => '呈', |
— | — | @@ -438,7 +438,7 @@ |
439 | 439 | 'htmlform-selectorother-other' => '他', |
440 | 440 | 'htmlform-invalid-input' => '爾之輸問也', |
441 | 441 | ), |
442 | | - 'mk' => |
| 442 | + 'mk' => |
443 | 443 | array ( |
444 | 444 | 'htmlform-reset' => 'Откажи промени', |
445 | 445 | 'htmlform-submit' => 'Зачувај', |
— | — | @@ -449,11 +449,11 @@ |
450 | 450 | 'htmlform-selectorother-other' => 'Друго', |
451 | 451 | 'htmlform-invalid-input' => 'Има проблеми со дел од вашиот внес', |
452 | 452 | ), |
453 | | - 'ml' => |
| 453 | + 'ml' => |
454 | 454 | array ( |
455 | 455 | 'htmlform-reset' => 'മാറ്റങ്ങള് വേണ്ട', |
456 | 456 | ), |
457 | | - 'ms' => |
| 457 | + 'ms' => |
458 | 458 | array ( |
459 | 459 | 'htmlform-reset' => 'Undur perubahan', |
460 | 460 | 'htmlform-submit' => 'Hantar', |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | 'htmlform-selectorother-other' => 'Lain-lain', |
464 | 464 | 'htmlform-invalid-input' => 'Terdapat beberapa masalah dengan input anda', |
465 | 465 | ), |
466 | | - 'mt' => |
| 466 | + 'mt' => |
467 | 467 | array ( |
468 | 468 | 'htmlform-reset' => 'Annulla l-modifiki', |
469 | 469 | 'htmlform-submit' => 'Ibgħat', |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | 'htmlform-selectorother-other' => 'Oħrajn', |
475 | 475 | 'htmlform-invalid-input' => 'Hemm xi problemi f\'dak li daħħalt', |
476 | 476 | ), |
477 | | - 'nds' => |
| 477 | + 'nds' => |
478 | 478 | array ( |
479 | 479 | 'htmlform-reset' => 'Ännern trüchsetten', |
480 | 480 | 'htmlform-submit' => 'Afspiekern', |
— | — | @@ -484,7 +484,7 @@ |
485 | 485 | 'htmlform-selectorother-other' => 'Annere', |
486 | 486 | 'htmlform-invalid-input' => 'Mit welk vun de angeven Weerten gifft dat Problemen', |
487 | 487 | ), |
488 | | - 'nds-nl' => |
| 488 | + 'nds-nl' => |
489 | 489 | array ( |
490 | 490 | 'htmlform-reset' => 'Wiezigingen ongedaonmaken', |
491 | 491 | 'htmlform-submit' => 'Opslaon', |
— | — | @@ -495,7 +495,7 @@ |
496 | 496 | 'htmlform-selectorother-other' => 'Aanders', |
497 | 497 | 'htmlform-invalid-input' => 'Der bin preblemen mit een paor in-egeven weerden', |
498 | 498 | ), |
499 | | - 'nl' => |
| 499 | + 'nl' => |
500 | 500 | array ( |
501 | 501 | 'htmlform-reset' => 'Wijzigingen ongedaan maken', |
502 | 502 | 'htmlform-submit' => 'Opslaan', |
— | — | @@ -506,7 +506,7 @@ |
507 | 507 | 'htmlform-selectorother-other' => 'Anders', |
508 | 508 | 'htmlform-invalid-input' => 'Er zijn problemen met enkele ingegeven waarden', |
509 | 509 | ), |
510 | | - 'nn' => |
| 510 | + 'nn' => |
511 | 511 | array ( |
512 | 512 | 'htmlform-reset' => 'Gjer om endringar', |
513 | 513 | 'htmlform-submit' => 'Lagre', |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | 'htmlform-selectorother-other' => 'Andre', |
519 | 519 | 'htmlform-invalid-input' => 'Det finst problem med innskrivinga di', |
520 | 520 | ), |
521 | | - 'no' => |
| 521 | + 'no' => |
522 | 522 | array ( |
523 | 523 | 'htmlform-reset' => 'Omgjør endringer', |
524 | 524 | 'htmlform-submit' => 'Lagre', |
— | — | @@ -528,7 +528,7 @@ |
529 | 529 | 'htmlform-selectorother-other' => 'Andre', |
530 | 530 | 'htmlform-invalid-input' => 'Det er problemer med noen av inndatene dine', |
531 | 531 | ), |
532 | | - 'oc' => |
| 532 | + 'oc' => |
533 | 533 | array ( |
534 | 534 | 'htmlform-reset' => 'Desfar las modificacions', |
535 | 535 | 'htmlform-submit' => 'Sometre', |
— | — | @@ -539,11 +539,11 @@ |
540 | 540 | 'htmlform-selectorother-other' => 'Autre', |
541 | 541 | 'htmlform-invalid-input' => 'De problèmas son arribats amb d\'unas valors', |
542 | 542 | ), |
543 | | - 'pdc' => |
| 543 | + 'pdc' => |
544 | 544 | array ( |
545 | 545 | 'htmlform-selectorother-other' => 'Annere', |
546 | 546 | ), |
547 | | - 'pl' => |
| 547 | + 'pl' => |
548 | 548 | array ( |
549 | 549 | 'htmlform-reset' => 'Cofnij zmiany', |
550 | 550 | 'htmlform-submit' => 'Zapisz', |
— | — | @@ -554,11 +554,11 @@ |
555 | 555 | 'htmlform-selectorother-other' => 'Inne', |
556 | 556 | 'htmlform-invalid-input' => 'Wystąpił problem z wprowadzonymi danymi', |
557 | 557 | ), |
558 | | - 'pnt' => |
| 558 | + 'pnt' => |
559 | 559 | array ( |
560 | 560 | 'htmlform-selectorother-other' => 'Άλλον', |
561 | 561 | ), |
562 | | - 'pt' => |
| 562 | + 'pt' => |
563 | 563 | array ( |
564 | 564 | 'htmlform-reset' => 'Desfazer alterações', |
565 | 565 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -569,7 +569,7 @@ |
570 | 570 | 'htmlform-selectorother-other' => 'Outros', |
571 | 571 | 'htmlform-invalid-input' => 'Existem problemas com alguns dos dados introduzidos', |
572 | 572 | ), |
573 | | - 'qu' => |
| 573 | + 'qu' => |
574 | 574 | array ( |
575 | 575 | 'htmlform-reset' => 'Hukchasqakunata kutichiy', |
576 | 576 | 'htmlform-submit' => 'Kachay', |
— | — | @@ -580,7 +580,7 @@ |
581 | 581 | 'htmlform-selectorother-other' => 'Wakin', |
582 | 582 | 'htmlform-invalid-input' => 'Yaykuchisqaykiwanqa sasachakuykunam kachkan', |
583 | 583 | ), |
584 | | - 'ro' => |
| 584 | + 'ro' => |
585 | 585 | array ( |
586 | 586 | 'htmlform-reset' => 'Anulează modificările', |
587 | 587 | 'htmlform-submit' => 'Trimite', |
— | — | @@ -591,7 +591,7 @@ |
592 | 592 | 'htmlform-selectorother-other' => 'Altul', |
593 | 593 | 'htmlform-invalid-input' => 'Există probleme la valorile introduse', |
594 | 594 | ), |
595 | | - 'roa-tara' => |
| 595 | + 'roa-tara' => |
596 | 596 | array ( |
597 | 597 | 'htmlform-reset' => 'Annulle le cangiaminde', |
598 | 598 | 'htmlform-submit' => 'Conferme', |
— | — | @@ -602,7 +602,7 @@ |
603 | 603 | 'htmlform-selectorother-other' => 'Otre', |
604 | 604 | 'htmlform-invalid-input' => 'Stonne probbleme cu certe input ca tu è mise', |
605 | 605 | ), |
606 | | - 'ru' => |
| 606 | + 'ru' => |
607 | 607 | array ( |
608 | 608 | 'htmlform-reset' => 'Отменить изменения', |
609 | 609 | 'htmlform-submit' => 'Отправить', |
— | — | @@ -613,7 +613,7 @@ |
614 | 614 | 'htmlform-selectorother-other' => 'Иное', |
615 | 615 | 'htmlform-invalid-input' => 'Часть введённых вами данных вызвала проблемы', |
616 | 616 | ), |
617 | | - 'sah' => |
| 617 | + 'sah' => |
618 | 618 | array ( |
619 | 619 | 'htmlform-reset' => 'Уларытыыны төннөр', |
620 | 620 | 'htmlform-submit' => 'Ыыт', |
— | — | @@ -624,11 +624,11 @@ |
625 | 625 | 'htmlform-selectorother-other' => 'Атын', |
626 | 626 | 'htmlform-invalid-input' => 'Киллэрбит сибидиэнньэҥ сорҕото алҕаһы таһаарда', |
627 | 627 | ), |
628 | | - 'sc' => |
| 628 | + 'sc' => |
629 | 629 | array ( |
630 | 630 | 'htmlform-selectorother-other' => 'Àteru', |
631 | 631 | ), |
632 | | - 'sh' => |
| 632 | + 'sh' => |
633 | 633 | array ( |
634 | 634 | 'htmlform-reset' => 'Vrati izmjene', |
635 | 635 | 'htmlform-submit' => 'Unesi', |
— | — | @@ -639,7 +639,7 @@ |
640 | 640 | 'htmlform-selectorother-other' => 'Ostalo', |
641 | 641 | 'htmlform-invalid-input' => 'Postoje određeni problemi sa Vašim unosom', |
642 | 642 | ), |
643 | | - 'si' => |
| 643 | + 'si' => |
644 | 644 | array ( |
645 | 645 | 'htmlform-reset' => 'වෙනස්කිරීම් අහෝසිකරන්න', |
646 | 646 | 'htmlform-submit' => 'යොමුකරන්න', |
— | — | @@ -650,7 +650,7 @@ |
651 | 651 | 'htmlform-selectorother-other' => 'වෙනත්', |
652 | 652 | 'htmlform-invalid-input' => 'ඔබගේ සමහරක් ප්රදානයන් විෂයයෙහි ගැටළු ඇත', |
653 | 653 | ), |
654 | | - 'sk' => |
| 654 | + 'sk' => |
655 | 655 | array ( |
656 | 656 | 'htmlform-reset' => 'Vrátiť zmeny', |
657 | 657 | 'htmlform-submit' => 'Odoslať', |
— | — | @@ -661,7 +661,7 @@ |
662 | 662 | 'htmlform-selectorother-other' => 'Iné', |
663 | 663 | 'htmlform-invalid-input' => 'Niekotrý z údajov, ktoré ste zadali je problematický', |
664 | 664 | ), |
665 | | - 'sr-ec' => |
| 665 | + 'sr-ec' => |
666 | 666 | array ( |
667 | 667 | 'htmlform-reset' => 'Врати измене', |
668 | 668 | 'htmlform-submit' => 'Пошаљи', |
— | — | @@ -672,7 +672,7 @@ |
673 | 673 | 'htmlform-selectorother-other' => 'Друго', |
674 | 674 | 'htmlform-invalid-input' => 'Има проблема са делом Вашег уноса', |
675 | 675 | ), |
676 | | - 'sv' => |
| 676 | + 'sv' => |
677 | 677 | array ( |
678 | 678 | 'htmlform-reset' => 'Ogör ändringar', |
679 | 679 | 'htmlform-submit' => 'Spara', |
— | — | @@ -683,15 +683,15 @@ |
684 | 684 | 'htmlform-selectorother-other' => 'Andra', |
685 | 685 | 'htmlform-invalid-input' => 'Det finns problem med din inmatning', |
686 | 686 | ), |
687 | | - 'sw' => |
| 687 | + 'sw' => |
688 | 688 | array ( |
689 | 689 | 'htmlform-selectorother-other' => 'Nyingine', |
690 | 690 | ), |
691 | | - 'te' => |
| 691 | + 'te' => |
692 | 692 | array ( |
693 | 693 | 'htmlform-selectorother-other' => 'ఇతర', |
694 | 694 | ), |
695 | | - 'tr' => |
| 695 | + 'tr' => |
696 | 696 | array ( |
697 | 697 | 'htmlform-reset' => 'Değişiklikleri geri al', |
698 | 698 | 'htmlform-submit' => 'Gönder', |
— | — | @@ -702,7 +702,7 @@ |
703 | 703 | 'htmlform-selectorother-other' => 'Diğer', |
704 | 704 | 'htmlform-invalid-input' => 'Girdinizin bir kısmıyla ilgili sorunlar var', |
705 | 705 | ), |
706 | | - 'uk' => |
| 706 | + 'uk' => |
707 | 707 | array ( |
708 | 708 | 'htmlform-reset' => 'Відкотити зміни', |
709 | 709 | 'htmlform-submit' => 'Відправити', |
— | — | @@ -713,7 +713,7 @@ |
714 | 714 | 'htmlform-selectorother-other' => 'Інше', |
715 | 715 | 'htmlform-invalid-input' => 'Частина введених вами даних викликала проблеми', |
716 | 716 | ), |
717 | | - 'vec' => |
| 717 | + 'vec' => |
718 | 718 | array ( |
719 | 719 | 'htmlform-reset' => 'Scancèla modifiche', |
720 | 720 | 'htmlform-submit' => 'Manda', |
— | — | @@ -723,7 +723,7 @@ |
724 | 724 | 'htmlform-select-badoption' => 'El valor che te ghè indicà no\'l xe mia valido.', |
725 | 725 | 'htmlform-invalid-input' => 'Ghe xe problemi con l\'input che te ghè inserìo', |
726 | 726 | ), |
727 | | - 'vi' => |
| 727 | + 'vi' => |
728 | 728 | array ( |
729 | 729 | 'htmlform-reset' => 'Hủy các thay đổi', |
730 | 730 | 'htmlform-submit' => 'Đăng', |
— | — | @@ -734,15 +734,15 @@ |
735 | 735 | 'htmlform-selectorother-other' => 'Khác', |
736 | 736 | 'htmlform-invalid-input' => 'Có vấn đề trong dữ liệu bạn vừa đưa vào', |
737 | 737 | ), |
738 | | - 'vo' => |
| 738 | + 'vo' => |
739 | 739 | array ( |
740 | 740 | 'htmlform-selectorother-other' => 'Votik', |
741 | 741 | ), |
742 | | - 'xal' => |
| 742 | + 'xal' => |
743 | 743 | array ( |
744 | 744 | 'htmlform-reset' => 'Сольлһдудиг уга кех', |
745 | 745 | ), |
746 | | - 'yue' => |
| 746 | + 'yue' => |
747 | 747 | array ( |
748 | 748 | 'htmlform-reset' => '復原更改', |
749 | 749 | 'htmlform-submit' => '遞交', |
— | — | @@ -753,7 +753,7 @@ |
754 | 754 | 'htmlform-selectorother-other' => '其它', |
755 | 755 | 'htmlform-invalid-input' => '響你嘅輸入度有一啲問題', |
756 | 756 | ), |
757 | | - 'zh-hans' => |
| 757 | + 'zh-hans' => |
758 | 758 | array ( |
759 | 759 | 'htmlform-reset' => '撤销更改', |
760 | 760 | 'htmlform-submit' => '提交', |
— | — | @@ -764,7 +764,7 @@ |
765 | 765 | 'htmlform-selectorother-other' => '其他', |
766 | 766 | 'htmlform-invalid-input' => '您输入的内容存在问题', |
767 | 767 | ), |
768 | | - 'zh-hant' => |
| 768 | + 'zh-hant' => |
769 | 769 | array ( |
770 | 770 | 'htmlform-reset' => '復原更改', |
771 | 771 | 'htmlform-submit' => '遞交', |
Index: trunk/extensions/LiquidThreads/compat/generateCompatibilityLocalisation.php |
— | — | @@ -2,27 +2,27 @@ |
3 | 3 | |
4 | 4 | // Utility script to generate an extension messages file for backwards-compatibility. |
5 | 5 | |
6 | | -require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
7 | | - ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
| 6 | +require_once ( getenv('MW_INSTALL_PATH') !== false |
| 7 | + ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
8 | 8 | : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
9 | 9 | |
10 | | -$messages = array( |
11 | | - 'htmlform-reset', |
12 | | - 'htmlform-submit', |
13 | | - 'htmlform-int-invalid', |
14 | | - 'htmlform-int-toolow', |
15 | | - 'htmlform-int-toohigh', |
16 | | - 'htmlform-select-badoption', |
17 | | - 'htmlform-selectorother-other', |
18 | | - 'htmlform-invalid-input', |
19 | | -); |
| 10 | +$messages = array( |
| 11 | + 'htmlform-reset', |
| 12 | + 'htmlform-submit', |
| 13 | + 'htmlform-int-invalid', |
| 14 | + 'htmlform-int-toolow', |
| 15 | + 'htmlform-int-toohigh', |
| 16 | + 'htmlform-select-badoption', |
| 17 | + 'htmlform-selectorother-other', |
| 18 | + 'htmlform-invalid-input', |
| 19 | + ); |
20 | 20 | |
21 | | -$languages = array_keys( Language::getLanguageNames( false ) ); |
| 21 | +$languages = array_keys(Language::getLanguageNames( false )); |
22 | 22 | $data = array_fill_keys( $languages, array() ); |
23 | 23 | |
24 | | -foreach ( $messages as $msg ) { |
| 24 | +foreach( $messages as $msg ) { |
25 | 25 | print "\nGetting localisation for $msg..."; |
26 | | - foreach ( $languages as $lang ) { |
| 26 | + foreach( $languages as $lang ) { |
27 | 27 | $data[$lang][$msg] = $wgMessageCache->get( $msg, false, $lang ); |
28 | 28 | print " $lang "; |
29 | 29 | } |
— | — | @@ -33,24 +33,24 @@ |
34 | 34 | |
35 | 35 | print "Eliminating redundant data... "; |
36 | 36 | |
37 | | -foreach ( $languages as $lang ) { |
| 37 | +foreach( $languages as $lang ) { |
38 | 38 | $fallback = Language::getFallbackFor( $lang ); |
39 | | - |
| 39 | + |
40 | 40 | print " [$lang from $fallback] "; |
41 | 41 | $lastFallback = $lang; |
42 | | - |
43 | | - while ( $fallback && !isset( $originalData[$fallback] ) && $fallback != $lastFallback ) { |
| 42 | + |
| 43 | + while ($fallback && !isset($originalData[$fallback]) && $fallback != $lastFallback) { |
44 | 44 | $lastFallback = $fallback; |
45 | 45 | $fallback = Language::getFallbackFor( $lang ); |
46 | 46 | } |
47 | | - |
48 | | - if ( $fallback && isset( $originalData[$fallback] ) ) { |
| 47 | + |
| 48 | + if ( $fallback && isset($originalData[$fallback]) ) { |
49 | 49 | $fallbackData = $originalData[$fallback]; |
50 | | - |
| 50 | + |
51 | 51 | $data[$lang] = array_diff_assoc( $originalData[$lang], $fallbackData ); |
52 | | - |
53 | | - if ( !count( $data[$lang] ) ) |
54 | | - unset( $data[$lang] ); |
| 52 | + |
| 53 | + if (!count($data[$lang])) |
| 54 | + unset($data[$lang]); |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | |
60 | 60 | $export = "<?php\n" . |
61 | 61 | "// This file is generated automatically by generateCompatibilityLocalisation.php\n" . |
62 | | - '$messages = ' . var_export( $data, true ) . ";\n"; |
| 62 | + '$messages = '.var_export($data, true).";\n"; |
63 | 63 | |
64 | 64 | file_put_contents( 'Lqt-compat.i18n.php', $export ); |
65 | 65 | |
Index: trunk/extensions/LiquidThreads/compat/HTMLForm.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class HTMLForm { |
| 5 | + |
5 | 6 | static $jsAdded = false; |
6 | 7 | |
7 | 8 | /* The descriptor is an array of arrays. |
— | — | @@ -25,14 +26,14 @@ |
26 | 27 | |
27 | 28 | function __construct( $descriptor, $messagePrefix ) { |
28 | 29 | wfLoadExtensionMessages( 'Lqt-Compat' ); |
29 | | - |
| 30 | + |
30 | 31 | $this->mMessagePrefix = $messagePrefix; |
31 | 32 | |
32 | 33 | // Expand out into a tree. |
33 | 34 | $loadedDescriptor = array(); |
34 | 35 | $this->mFlatFields = array(); |
35 | 36 | |
36 | | - foreach ( $descriptor as $fieldname => $info ) { |
| 37 | + foreach( $descriptor as $fieldname => $info ) { |
37 | 38 | $section = ''; |
38 | 39 | if ( isset( $info['section'] ) ) |
39 | 40 | $section = $info['section']; |
— | — | @@ -43,10 +44,10 @@ |
44 | 45 | $field->mParent = $this; |
45 | 46 | |
46 | 47 | $setSection =& $loadedDescriptor; |
47 | | - if ( $section ) { |
| 48 | + if( $section ) { |
48 | 49 | $sectionParts = explode( '/', $section ); |
49 | 50 | |
50 | | - while ( count( $sectionParts ) ) { |
| 51 | + while( count( $sectionParts ) ) { |
51 | 52 | $newName = array_shift( $sectionParts ); |
52 | 53 | |
53 | 54 | if ( !isset( $setSection[$newName] ) ) { |
— | — | @@ -78,7 +79,7 @@ |
79 | 80 | $descriptor['class'] = $class; |
80 | 81 | } |
81 | 82 | |
82 | | - if ( !$class ) { |
| 83 | + if( !$class ) { |
83 | 84 | throw new MWException( "Descriptor with no class: " . print_r( $descriptor, true ) ); |
84 | 85 | } |
85 | 86 | |
— | — | @@ -103,7 +104,7 @@ |
104 | 105 | if ( $wgUser->matchEditToken( $editToken ) ) |
105 | 106 | $result = $this->trySubmit(); |
106 | 107 | |
107 | | - if ( $result === true ) |
| 108 | + if( $result === true ) |
108 | 109 | return $result; |
109 | 110 | |
110 | 111 | // Display form. |
— | — | @@ -117,7 +118,7 @@ |
118 | 119 | */ |
119 | 120 | function trySubmit() { |
120 | 121 | // Check for validation |
121 | | - foreach ( $this->mFlatFields as $fieldname => $field ) { |
| 122 | + foreach( $this->mFlatFields as $fieldname => $field ) { |
122 | 123 | if ( !empty( $field->mParams['nodata'] ) ) continue; |
123 | 124 | if ( $field->validate( $this->mFieldData[$fieldname], |
124 | 125 | $this->mFieldData ) !== true ) { |
— | — | @@ -204,7 +205,7 @@ |
205 | 206 | |
206 | 207 | $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; |
207 | 208 | |
208 | | - if ( $this->mShowReset ) { |
| 209 | + if( $this->mShowReset ) { |
209 | 210 | $html .= Xml::element( |
210 | 211 | 'input', |
211 | 212 | array( |
— | — | @@ -213,7 +214,7 @@ |
214 | 215 | ) |
215 | 216 | ) . "\n"; |
216 | 217 | } |
217 | | - |
| 218 | + |
218 | 219 | return $html; |
219 | 220 | } |
220 | 221 | |
— | — | @@ -227,7 +228,7 @@ |
228 | 229 | } else { |
229 | 230 | $errorstr = $errors; |
230 | 231 | } |
231 | | - |
| 232 | + |
232 | 233 | $errorstr = Xml::tags( 'div', array( 'class' => 'error' ), $errorstr ); |
233 | 234 | |
234 | 235 | global $wgOut; |
— | — | @@ -237,7 +238,7 @@ |
238 | 239 | static function formatErrors( $errors ) { |
239 | 240 | $errorstr = ''; |
240 | 241 | foreach ( $errors as $error ) { |
241 | | - if ( is_array( $error ) ) { |
| 242 | + if( is_array( $error ) ) { |
242 | 243 | $msg = array_shift( $error ); |
243 | 244 | } else { |
244 | 245 | $msg = $error; |
— | — | @@ -284,14 +285,14 @@ |
285 | 286 | $subsectionHtml = ''; |
286 | 287 | $hasLeftColumn = false; |
287 | 288 | |
288 | | - foreach ( $fields as $key => $value ) { |
| 289 | + foreach( $fields as $key => $value ) { |
289 | 290 | if ( is_object( $value ) ) { |
290 | 291 | $v = empty( $value->mParams['nodata'] ) |
291 | 292 | ? $this->mFieldData[$key] |
292 | 293 | : $value->getDefault(); |
293 | 294 | $tableHtml .= $value->getTableRow( $v ); |
294 | 295 | |
295 | | - if ( $value->getLabel() != ' ' ) |
| 296 | + if( $value->getLabel() != ' ' ) |
296 | 297 | $hasLeftColumn = true; |
297 | 298 | } elseif ( is_array( $value ) ) { |
298 | 299 | $section = $this->displaySection( $value ); |
— | — | @@ -301,7 +302,7 @@ |
302 | 303 | } |
303 | 304 | |
304 | 305 | $classes = array(); |
305 | | - if ( !$hasLeftColumn ) // Avoid strange spacing when no labels exist |
| 306 | + if( !$hasLeftColumn ) // Avoid strange spacing when no labels exist |
306 | 307 | $classes[] = 'mw-htmlform-nolabel'; |
307 | 308 | $classes = implode( ' ', $classes ); |
308 | 309 | |
— | — | @@ -315,7 +316,7 @@ |
316 | 317 | |
317 | 318 | $fieldData = array(); |
318 | 319 | |
319 | | - foreach ( $this->mFlatFields as $fieldname => $field ) { |
| 320 | + foreach( $this->mFlatFields as $fieldname => $field ) { |
320 | 321 | if ( !empty( $field->mParams['nodata'] ) ) continue; |
321 | 322 | if ( !empty( $field->mParams['disabled'] ) ) { |
322 | 323 | $fieldData[$fieldname] = $field->getDefault(); |
— | — | @@ -325,7 +326,7 @@ |
326 | 327 | } |
327 | 328 | |
328 | 329 | // Filter data. |
329 | | - foreach ( $fieldData as $name => &$value ) { |
| 330 | + foreach( $fieldData as $name => &$value ) { |
330 | 331 | $field = $this->mFlatFields[$name]; |
331 | 332 | $value = $field->filter( $value, $this->mFlatFields ); |
332 | 333 | } |
— | — | @@ -335,12 +336,12 @@ |
336 | 337 | |
337 | 338 | function importData( $fieldData ) { |
338 | 339 | // Filter data. |
339 | | - foreach ( $fieldData as $name => &$value ) { |
| 340 | + foreach( $fieldData as $name => &$value ) { |
340 | 341 | $field = $this->mFlatFields[$name]; |
341 | 342 | $value = $field->filter( $value, $this->mFlatFields ); |
342 | 343 | } |
343 | 344 | |
344 | | - foreach ( $this->mFlatFields as $fieldname => $field ) { |
| 345 | + foreach( $this->mFlatFields as $fieldname => $field ) { |
345 | 346 | if ( !isset( $fieldData[$fieldname] ) ) |
346 | 347 | $fieldData[$fieldname] = $field->getDefault(); |
347 | 348 | } |
— | — | @@ -369,7 +370,7 @@ |
370 | 371 | } |
371 | 372 | |
372 | 373 | function filter( $value, $alldata ) { |
373 | | - if ( isset( $this->mFilterCallback ) ) { |
| 374 | + if( isset( $this->mFilterCallback ) ) { |
374 | 375 | $value = call_user_func( $this->mFilterCallback, $value, $alldata ); |
375 | 376 | } |
376 | 377 | |
— | — | @@ -377,7 +378,7 @@ |
378 | 379 | } |
379 | 380 | |
380 | 381 | function loadDataFromRequest( $request ) { |
381 | | - if ( $request->getCheck( $this->mName ) ) { |
| 382 | + if( $request->getCheck( $this->mName ) ) { |
382 | 383 | return $request->getText( $this->mName ); |
383 | 384 | } else { |
384 | 385 | return $this->getDefault(); |
— | — | @@ -387,7 +388,7 @@ |
388 | 389 | function __construct( $params ) { |
389 | 390 | $this->mParams = $params; |
390 | 391 | |
391 | | - if ( isset( $params['label-message'] ) ) { |
| 392 | + if( isset( $params['label-message'] ) ) { |
392 | 393 | $msgInfo = $params['label-message']; |
393 | 394 | |
394 | 395 | if ( is_array( $msgInfo ) ) { |
— | — | @@ -403,8 +404,8 @@ |
404 | 405 | } |
405 | 406 | |
406 | 407 | if ( isset( $params['name'] ) ) { |
407 | | - $this->mName = 'wp' . $params['name']; |
408 | | - $this->mID = 'mw-input-' . $params['name']; |
| 408 | + $this->mName = 'wp'.$params['name']; |
| 409 | + $this->mID = 'mw-input-'.$params['name']; |
409 | 410 | } |
410 | 411 | |
411 | 412 | if ( isset( $params['default'] ) ) { |
— | — | @@ -441,7 +442,7 @@ |
442 | 443 | Xml::tags( 'label', array( 'for' => $this->mID ), $this->getLabel() ) |
443 | 444 | ); |
444 | 445 | $html .= Xml::tags( 'td', array( 'class' => 'mw-input' ), |
445 | | - $this->getInputHTML( $value ) . "\n$errors" ); |
| 446 | + $this->getInputHTML( $value ) ."\n$errors" ); |
446 | 447 | |
447 | 448 | $fieldType = get_class( $this ); |
448 | 449 | |
— | — | @@ -454,7 +455,7 @@ |
455 | 456 | |
456 | 457 | $text = wfMsgExt( $msg, 'parseinline' ); |
457 | 458 | |
458 | | - if ( !wfEmptyMsg( $msg, $text ) ) { |
| 459 | + if( !wfEmptyMsg( $msg, $text ) ) { |
459 | 460 | $row = Xml::tags( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ), |
460 | 461 | $text ); |
461 | 462 | |
— | — | @@ -482,7 +483,7 @@ |
483 | 484 | static function flattenOptions( $options ) { |
484 | 485 | $flatOpts = array(); |
485 | 486 | |
486 | | - foreach ( $options as $key => $value ) { |
| 487 | + foreach( $options as $key => $value ) { |
487 | 488 | if ( is_array( $value ) ) { |
488 | 489 | $flatOpts = array_merge( $flatOpts, self::flattenOptions( $value ) ); |
489 | 490 | } else { |
— | — | @@ -506,8 +507,8 @@ |
507 | 508 | if ( isset( $this->mParams['maxlength'] ) ) { |
508 | 509 | $attribs['maxlength'] = $this->mParams['maxlength']; |
509 | 510 | } |
510 | | - |
511 | | - if ( !empty( $this->mParams['disabled'] ) ) { |
| 511 | + |
| 512 | + if( !empty( $this->mParams['disabled'] ) ) { |
512 | 513 | $attribs['disabled'] = 'disabled'; |
513 | 514 | } |
514 | 515 | |
— | — | @@ -529,7 +530,7 @@ |
530 | 531 | function validate( $value, $alldata ) { |
531 | 532 | $p = parent::validate( $value, $alldata ); |
532 | 533 | |
533 | | - if ( $p !== true ) return $p; |
| 534 | + if( $p !== true ) return $p; |
534 | 535 | |
535 | 536 | if ( intval( $value ) != $value ) { |
536 | 537 | return wfMsgExt( 'htmlform-int-invalid', 'parse' ); |
— | — | @@ -545,7 +546,7 @@ |
546 | 547 | |
547 | 548 | if ( isset( $this->mParams['max'] ) ) { |
548 | 549 | $max = $this->mParams['max']; |
549 | | - if ( $max < $value ) |
| 550 | + if( $max < $value ) |
550 | 551 | return wfMsgExt( 'htmlform-int-toohigh', 'parse', array( $max ) ); |
551 | 552 | } |
552 | 553 | |
— | — | @@ -559,7 +560,7 @@ |
560 | 561 | $value = !$value; |
561 | 562 | |
562 | 563 | $attr = array( 'id' => $this->mID ); |
563 | | - if ( !empty( $this->mParams['disabled'] ) ) { |
| 564 | + if( !empty( $this->mParams['disabled'] ) ) { |
564 | 565 | $attr['disabled'] = 'disabled'; |
565 | 566 | } |
566 | 567 | |
— | — | @@ -578,7 +579,7 @@ |
579 | 580 | } |
580 | 581 | |
581 | 582 | // GetCheck won't work like we want for checks. |
582 | | - if ( $request->getCheck( 'wpEditToken' ) ) { |
| 583 | + if( $request->getCheck( 'wpEditToken' ) ) { |
583 | 584 | // XOR has the following truth table, which is what we want |
584 | 585 | // INVERT VALUE | OUTPUT |
585 | 586 | // true true | false |
— | — | @@ -596,7 +597,7 @@ |
597 | 598 | |
598 | 599 | function validate( $value, $alldata ) { |
599 | 600 | $p = parent::validate( $value, $alldata ); |
600 | | - if ( $p !== true ) return $p; |
| 601 | + if( $p !== true ) return $p; |
601 | 602 | |
602 | 603 | $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
603 | 604 | if ( in_array( $value, $validOptions ) ) |
— | — | @@ -613,7 +614,7 @@ |
614 | 615 | // Working around this by forcing all of them to strings. |
615 | 616 | $options = array_map( 'strval', $this->mParams['options'] ); |
616 | 617 | |
617 | | - if ( !empty( $this->mParams['disabled'] ) ) { |
| 618 | + if( !empty( $this->mParams['disabled'] ) ) { |
618 | 619 | $select->setAttribute( 'disabled', 'disabled' ); |
619 | 620 | } |
620 | 621 | |
— | — | @@ -627,7 +628,7 @@ |
628 | 629 | static $jsAdded = false; |
629 | 630 | |
630 | 631 | function __construct( $params ) { |
631 | | - if ( !in_array( 'other', $params['options'] ) ) { |
| 632 | + if( !in_array( 'other', $params['options'] ) ) { |
632 | 633 | $params['options'][wfMsg( 'htmlform-selectorother-other' )] = 'other'; |
633 | 634 | } |
634 | 635 | |
— | — | @@ -637,12 +638,9 @@ |
638 | 639 | function getInputHTML( $value ) { |
639 | 640 | $valInSelect = false; |
640 | 641 | |
641 | | - if ( $value !== false ) { |
642 | | - $valInSelect = in_array( |
643 | | - $value, |
644 | | - HTMLFormField::flattenOptions( $this->mParams['options'] ) |
645 | | - ); |
646 | | - } |
| 642 | + if( $value !== false ) |
| 643 | + $valInSelect = in_array( $value, |
| 644 | + HTMLFormField::flattenOptions( $this->mParams['options'] ) ); |
647 | 645 | |
648 | 646 | $selected = $valInSelect ? $value : 'other'; |
649 | 647 | |
— | — | @@ -652,7 +650,7 @@ |
653 | 651 | $select->setAttribute( 'class', 'mw-htmlform-select-or-other' ); |
654 | 652 | |
655 | 653 | $tbAttribs = array( 'id' => $this->mID . '-other' ); |
656 | | - if ( !empty( $this->mParams['disabled'] ) ) { |
| 654 | + if( !empty( $this->mParams['disabled'] ) ) { |
657 | 655 | $select->setAttribute( 'disabled', 'disabled' ); |
658 | 656 | $tbAttribs['disabled'] = 'disabled'; |
659 | 657 | } |
— | — | @@ -663,21 +661,19 @@ |
664 | 662 | $tbAttribs['maxlength'] = $this->mParams['maxlength']; |
665 | 663 | } |
666 | 664 | |
667 | | - $textbox = Xml::input( |
668 | | - $this->mName . '-other', |
669 | | - $this->getSize(), |
670 | | - $valInSelect ? '' : $value, |
671 | | - $tbAttribs |
672 | | - ); |
| 665 | + $textbox = Xml::input( $this->mName . '-other', |
| 666 | + $this->getSize(), |
| 667 | + $valInSelect ? '' : $value, |
| 668 | + $tbAttribs ); |
673 | 669 | |
674 | 670 | return "$select<br/>\n$textbox"; |
675 | 671 | } |
676 | 672 | |
677 | 673 | function loadDataFromRequest( $request ) { |
678 | | - if ( $request->getCheck( $this->mName ) ) { |
| 674 | + if( $request->getCheck( $this->mName ) ) { |
679 | 675 | $val = $request->getText( $this->mName ); |
680 | 676 | |
681 | | - if ( $val == 'other' ) { |
| 677 | + if( $val == 'other' ) { |
682 | 678 | $val = $request->getText( $this->mName . '-other' ); |
683 | 679 | } |
684 | 680 | |
— | — | @@ -691,9 +687,9 @@ |
692 | 688 | class HTMLMultiSelectField extends HTMLFormField { |
693 | 689 | function validate( $value, $alldata ) { |
694 | 690 | $p = parent::validate( $value, $alldata ); |
695 | | - if ( $p !== true ) return $p; |
| 691 | + if( $p !== true ) return $p; |
696 | 692 | |
697 | | - if ( !is_array( $value ) ) return false; |
| 693 | + if( !is_array( $value ) ) return false; |
698 | 694 | |
699 | 695 | // If all options are valid, array_intersect of the valid options and the provided |
700 | 696 | // options will return the provided options. |
— | — | @@ -720,24 +716,17 @@ |
721 | 717 | $attribs['disabled'] = 'disabled'; |
722 | 718 | } |
723 | 719 | |
724 | | - foreach ( $options as $label => $info ) { |
725 | | - if ( is_array( $info ) ) { |
| 720 | + foreach( $options as $label => $info ) { |
| 721 | + if( is_array( $info ) ) { |
726 | 722 | $html .= Xml::tags( 'h1', null, $label ) . "\n"; |
727 | 723 | $html .= $this->formatOptions( $info, $value ); |
728 | 724 | } else { |
729 | 725 | $thisAttribs = array( 'id' => $this->mID . "-$info", 'value' => $info ); |
| 726 | + |
| 727 | + $checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value ), |
| 728 | + $attribs + $thisAttribs ); |
| 729 | + $checkbox .= ' ' . Xml::tags( 'label', array( 'for' => $this->mID . "-$info" ), $label ); |
730 | 730 | |
731 | | - $checkbox = Xml::check( |
732 | | - $this->mName . '[]', |
733 | | - in_array( $info, $value ), |
734 | | - $attribs + $thisAttribs |
735 | | - ); |
736 | | - $checkbox .= ' ' . Xml::tags( |
737 | | - 'label', |
738 | | - array( 'for' => $this->mID . "-$info" ), |
739 | | - $label |
740 | | - ); |
741 | | - |
742 | 731 | $html .= $checkbox . '<br />'; |
743 | 732 | } |
744 | 733 | } |
— | — | @@ -747,10 +736,10 @@ |
748 | 737 | |
749 | 738 | function loadDataFromRequest( $request ) { |
750 | 739 | // won't work with getCheck |
751 | | - if ( $request->getCheck( 'wpEditToken' ) ) { |
| 740 | + if( $request->getCheck( 'wpEditToken' ) ) { |
752 | 741 | $arr = $request->getArray( $this->mName ); |
753 | 742 | |
754 | | - if ( !$arr ) |
| 743 | + if( !$arr ) |
755 | 744 | $arr = array(); |
756 | 745 | |
757 | 746 | return $arr; |
— | — | @@ -771,9 +760,9 @@ |
772 | 761 | class HTMLRadioField extends HTMLFormField { |
773 | 762 | function validate( $value, $alldata ) { |
774 | 763 | $p = parent::validate( $value, $alldata ); |
775 | | - if ( $p !== true ) return $p; |
| 764 | + if( $p !== true ) return $p; |
776 | 765 | |
777 | | - if ( !is_string( $value ) && !is_int( $value ) ) |
| 766 | + if( !is_string( $value ) && !is_int( $value ) ) |
778 | 767 | return false; |
779 | 768 | |
780 | 769 | $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
— | — | @@ -789,7 +778,7 @@ |
790 | 779 | |
791 | 780 | return $html; |
792 | 781 | } |
793 | | - |
| 782 | + |
794 | 783 | function formatOptions( $options, $value ) { |
795 | 784 | $html = ''; |
796 | 785 | |
— | — | @@ -798,8 +787,8 @@ |
799 | 788 | $attribs['disabled'] = 'disabled'; |
800 | 789 | } |
801 | 790 | |
802 | | - foreach ( $options as $label => $info ) { |
803 | | - if ( is_array( $info ) ) { |
| 791 | + foreach( $options as $label => $info ) { |
| 792 | + if( is_array( $info ) ) { |
804 | 793 | $html .= Xml::tags( 'h1', null, $label ) . "\n"; |
805 | 794 | $html .= $this->formatOptions( $info, $value ); |
806 | 795 | } else { |
Index: trunk/extensions/LiquidThreads/compat/LqtCompatArticle.php |
— | — | @@ -3,67 +3,68 @@ |
4 | 4 | |
5 | 5 | global $wgVersion; |
6 | 6 | if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
| 7 | + |
7 | 8 | // LiquidThreads compatibility wrapper around the Article object. |
8 | 9 | class Article_LQT_Compat extends Article { |
9 | | - |
| 10 | + |
10 | 11 | public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) { |
11 | 12 | global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache; |
12 | | - |
| 13 | + |
13 | 14 | if ( !$parserOptions ) { |
14 | 15 | $parserOptions = $wgOut->parserOptions(); |
15 | 16 | } |
16 | | - |
17 | | - $time = - wfTime(); |
| 17 | + |
| 18 | + $time = -wfTime(); |
18 | 19 | $parserOutput = $wgParser->parse( $text, $this->mTitle, |
19 | 20 | $parserOptions, true, true, $this->getRevIdFetched() ); |
20 | 21 | $time += wfTime(); |
21 | | - |
| 22 | + |
22 | 23 | # Timing hack |
23 | | - if ( $time > 3 ) { |
| 24 | + if( $time > 3 ) { |
24 | 25 | wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
25 | | - $this->mTitle->getPrefixedDBkey() ) ); |
| 26 | + $this->mTitle->getPrefixedDBkey())); |
26 | 27 | } |
27 | | - |
28 | | - if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != - 1 ) { |
| 28 | + |
| 29 | + if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) { |
29 | 30 | $parserCache = ParserCache::singleton(); |
30 | 31 | $parserCache->save( $parserOutput, $this, $parserOptions ); |
31 | 32 | } |
32 | 33 | // Make sure file cache is not used on uncacheable content. |
33 | 34 | // Output that has magic words in it can still use the parser cache |
34 | 35 | // (if enabled), though it will generally expire sooner. |
35 | | - if ( $parserOutput->getCacheTime() == - 1 || $parserOutput->containsOldMagic() ) { |
| 36 | + if( $parserOutput->getCacheTime() == -1 || $parserOutput->containsOldMagic() ) { |
36 | 37 | $wgUseFileCache = false; |
37 | 38 | } |
38 | 39 | return $parserOutput; |
39 | 40 | } |
40 | | - |
| 41 | + |
41 | 42 | /** Stolen from 1.16-alpha, for compatibility with 1.15 */ |
42 | 43 | /** Lightweight method to get the parser output for a page, checking the parser cache |
43 | 44 | * and so on. Doesn't consider most of the stuff that Article::view is forced to |
44 | 45 | * consider, so it's not appropriate to use there. */ |
45 | 46 | function getParserOutput( $oldid = null ) { |
46 | 47 | global $wgEnableParserCache, $wgUser, $wgOut; |
47 | | - |
| 48 | + |
48 | 49 | // Should the parser cache be used? |
49 | 50 | $useParserCache = $wgEnableParserCache && |
50 | 51 | intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && |
51 | 52 | $this->exists() && |
52 | 53 | $oldid === null; |
53 | | - |
54 | | - wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 54 | + |
| 55 | + wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
55 | 56 | if ( $wgUser->getOption( 'stubthreshold' ) ) { |
56 | 57 | wfIncrStats( 'pcache_miss_stub' ); |
57 | 58 | } |
58 | | - |
| 59 | + |
59 | 60 | $parserOutput = false; |
60 | 61 | if ( $useParserCache ) { |
61 | 62 | $parserOutput = ParserCache::singleton()->get( $this, $wgOut->parserOptions() ); |
62 | 63 | } |
63 | | - |
| 64 | + |
64 | 65 | if ( $parserOutput === false ) { |
65 | 66 | // Cache miss; parse and output it. |
66 | 67 | $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); |
67 | | - |
| 68 | + |
68 | 69 | return $this->getOutputFromWikitext( $rev->getText(), $useParserCache ); |
69 | 70 | } else { |
70 | 71 | return $parserOutput; |
— | — | @@ -71,5 +72,5 @@ |
72 | 73 | } |
73 | 74 | } |
74 | 75 | } else { |
75 | | - class Article_LQT_Compat extends Article { } |
| 76 | + class Article_LQT_Compat extends Article {} |
76 | 77 | } |
Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | $wgAutoloadClasses['LqtParserFunctions'] = $dir . 'classes/ParserFunctions.php'; |
103 | 103 | $wgAutoloadClasses['LqtDeletionController'] = $dir . 'classes/DeletionController.php'; |
104 | 104 | $wgAutoloadClasses['LqtHooks'] = $dir . 'classes/Hooks.php'; |
105 | | -$wgAutoloadClasses['ThreadRevision'] = $dir . "/classes/ThreadRevision.php"; |
| 105 | +$wgAutoloadClasses['ThreadRevision'] = $dir."/classes/ThreadRevision.php"; |
106 | 106 | |
107 | 107 | // View classes |
108 | 108 | $wgAutoloadClasses['TalkpageView'] = $dir . 'pages/TalkpageView.php'; |
Index: trunk/extensions/LiquidThreads/classes/DeletionController.php |
— | — | @@ -2,97 +2,97 @@ |
3 | 3 | |
4 | 4 | class LqtDeletionController { |
5 | 5 | static $pageids_to_revive; |
6 | | - |
| 6 | + |
7 | 7 | static function onArticleDeleteComplete( &$article, &$user, $reason, $id ) { |
8 | 8 | $title = $article->getTitle(); |
9 | | - |
10 | | - if ( $title->getNamespace() != NS_LQT_THREAD ) { |
| 9 | + |
| 10 | + if ($title->getNamespace() != NS_LQT_THREAD) { |
11 | 11 | return true; |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | $threads = Threads::where( array( 'thread_root' => $id ) ); |
15 | | - |
16 | | - if ( !count( $threads ) ) { |
17 | | - wfDebugLog( __METHOD__ . ": no threads with root $id, ignoring...\n" ); |
| 15 | + |
| 16 | + if (!count($threads)) { |
| 17 | + wfDebugLog( __METHOD__.": no threads with root $id, ignoring...\n" ); |
18 | 18 | return true; |
19 | 19 | } |
20 | | - |
21 | | - $thread = array_pop( $threads ); |
22 | | - |
| 20 | + |
| 21 | + $thread = array_pop($threads); |
| 22 | + |
23 | 23 | // Mark the thread as deleted |
24 | | - $thread->delete( $reason ); |
25 | | - |
| 24 | + $thread->delete($reason); |
| 25 | + |
26 | 26 | // Avoid orphaning subthreads, update their parentage. |
27 | 27 | wfLoadExtensionMessages( 'LiquidThreads' ); |
28 | 28 | if ( $thread->replies() && $thread->isTopmostThread() ) { |
29 | | - $reason = wfMsg( 'lqt-delete-parent-deleted', $reason ); |
30 | | - foreach ( $thread->replies() as $reply ) { |
| 29 | + $reason = wfMsg('lqt-delete-parent-deleted', $reason ); |
| 30 | + foreach( $thread->replies() as $reply ) { |
31 | 31 | $reply->root()->doDeleteArticle( $reason, false, $reply->root()->getId() ); |
32 | 32 | } |
33 | 33 | global $wgOut; |
34 | 34 | $wgOut->addWikiMsg( 'lqt-delete-replies-done' ); |
35 | 35 | } elseif ( $thread->replies() ) { |
36 | | - foreach ( $thread->replies() as $reply ) { |
| 36 | + foreach( $thread->replies() as $reply ) { |
37 | 37 | $reply->setSuperthread( $thread->superthread() ); |
38 | 38 | $reply->save( ); |
39 | 39 | } |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | return true; |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | static function onArticleRevisionUndeleted( &$title, $revision, $page_id ) { |
46 | 46 | if ( $title->getNamespace() == NS_LQT_THREAD ) { |
47 | 47 | self::$pageids_to_revive[$page_id] = $title; |
48 | 48 | } |
49 | | - |
| 49 | + |
50 | 50 | return true; |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | static function onArticleUndelete( &$udTitle, $created, $comment = '' ) { |
54 | | - if ( empty( self::$pageids_to_revive ) ) { |
| 54 | + if ( empty(self::$pageids_to_revive) ) { |
55 | 55 | return true; |
56 | 56 | } |
57 | | - |
58 | | - foreach ( self::$pageids_to_revive as $pageid => $title ) { |
59 | | - if ( $pageid == 0 ) { |
| 57 | + |
| 58 | + foreach( self::$pageids_to_revive as $pageid => $title ) { |
| 59 | + if ($pageid == 0) { |
60 | 60 | continue; |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | // Try to get comment for old versions where it isn't passed, hacky :( |
64 | | - if ( !$comment ) { |
| 64 | + if (!$comment) { |
65 | 65 | global $wgRequest; |
66 | 66 | $comment = $wgRequest->getText( 'wpComment' ); |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | // TX has not been committed yet, so we must select from the master |
70 | 70 | $dbw = wfGetDB( DB_MASTER ); |
71 | 71 | $res = $dbw->select( 'thread', '*', array( 'thread_root' => $pageid ), __METHOD__ ); |
72 | 72 | $threads = Threads::loadFromResult( $res, $dbw ); |
73 | | - |
74 | | - if ( count( $threads ) ) { |
75 | | - $thread = array_pop( $threads ); |
| 73 | + |
| 74 | + if ( count($threads) ) { |
| 75 | + $thread = array_pop($threads); |
76 | 76 | $thread->setRoot( new Article( $title ) ); |
77 | 77 | $thread->undelete( $comment ); |
78 | 78 | } else { |
79 | | - wfDebug( __METHOD__ . ":No thread found with root set to $pageid (??)\n" ); |
| 79 | + wfDebug( __METHOD__. ":No thread found with root set to $pageid (??)\n" ); |
80 | 80 | } |
81 | 81 | } |
82 | | - |
| 82 | + |
83 | 83 | return true; |
84 | 84 | } |
85 | | - |
| 85 | + |
86 | 86 | static function onArticleConfirmDelete( $article, $out, &$reason ) { |
87 | | - if ( $article->getTitle()->getNamespace() != NS_LQT_THREAD ) return true; |
88 | | - |
| 87 | + if ($article->getTitle()->getNamespace() != NS_LQT_THREAD) return true; |
| 88 | + |
89 | 89 | $thread = Threads::withRoot( $article ); |
90 | | - |
91 | | - if ( $thread->isTopmostThread() && count( $thread->replies() ) ) { |
| 90 | + |
| 91 | + if ( $thread->isTopmostThread() && count($thread->replies()) ) { |
92 | 92 | wfLoadExtensionMessages( 'LiquidThreads' ); |
93 | 93 | $out->wrapWikiMsg( '<strong>$1</strong>', |
94 | 94 | 'lqt-delete-parent-warning' ); |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | return true; |
98 | 98 | } |
99 | 99 | } |
Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -31,35 +31,35 @@ |
32 | 32 | protected $subject; |
33 | 33 | protected $authorId; |
34 | 34 | protected $authorName; |
35 | | - |
| 35 | + |
36 | 36 | protected $allDataLoaded; |
37 | | - |
| 37 | + |
38 | 38 | protected $isHistorical = false; |
39 | | - |
| 39 | + |
40 | 40 | protected $rootRevision; |
41 | 41 | |
42 | 42 | /* Flag about who has edited or replied to this thread. */ |
43 | 43 | protected $editedness; |
44 | 44 | |
45 | 45 | protected $replies; |
46 | | - |
| 46 | + |
47 | 47 | static $titleCacheById = array(); |
48 | 48 | static $replyCacheById = array(); |
49 | 49 | static $articleCacheById = array(); |
50 | | - |
| 50 | + |
51 | 51 | static $VALID_TYPES = array( Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED ); |
52 | 52 | |
53 | 53 | function isHistorical() { |
54 | 54 | return $this->isHistorical; |
55 | 55 | } |
56 | | - |
| 56 | + |
57 | 57 | static function create( $root, $article, $superthread = null, |
58 | | - $type = Threads::TYPE_NORMAL, $subject = '' ) { |
| 58 | + $type = Threads::TYPE_NORMAL, $subject = '' ) { |
59 | 59 | |
60 | | - $dbw = wfGetDB( DB_MASTER ); |
| 60 | + $dbw = wfGetDB( DB_MASTER ); |
| 61 | + |
| 62 | + $thread = new Thread(null); |
61 | 63 | |
62 | | - $thread = new Thread( null ); |
63 | | - |
64 | 64 | if ( !in_array( $type, self::$VALID_TYPES ) ) { |
65 | 65 | throw new MWException( __METHOD__ . ": invalid change type $type." ); |
66 | 66 | } |
— | — | @@ -80,50 +80,50 @@ |
81 | 81 | $thread->setArticle( $article ); |
82 | 82 | $thread->setSubject( $subject ); |
83 | 83 | $thread->setType( $type ); |
84 | | - |
| 84 | + |
85 | 85 | $thread->insert(); |
86 | | - |
| 86 | + |
87 | 87 | if ( $superthread ) { |
88 | 88 | $superthread->addReply( $thread ); |
89 | | - |
| 89 | + |
90 | 90 | $superthread->commitRevision( $change_type, $thread ); |
91 | 91 | } else { |
92 | 92 | $hthread = ThreadRevision::create( $thread, $change_type ); |
93 | 93 | } |
94 | | - |
| 94 | + |
95 | 95 | // Create talk page |
96 | 96 | Threads::createTalkpageIfNeeded( $article ); |
97 | 97 | |
98 | 98 | // Notifications |
99 | 99 | NewMessages::writeMessageStateForUpdatedThread( $thread, $change_type, $wgUser ); |
100 | | - |
101 | | - if ( $wgUser->getOption( 'lqt-watch-threads', false ) ) { |
| 100 | + |
| 101 | + if ($wgUser->getOption( 'lqt-watch-threads', false ) ) { |
102 | 102 | $thread->topmostThread()->root()->doWatch(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | return $thread; |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | function insert() { |
109 | 109 | $this->dieIfHistorical(); |
110 | | - |
| 110 | + |
111 | 111 | $dbw = wfGetDB( DB_MASTER ); |
112 | | - |
| 112 | + |
113 | 113 | $row = $this->getRow(); |
114 | 114 | $row['thread_id'] = $dbw->nextSequenceValue( 'thread_thread_id' ); |
115 | | - |
| 115 | + |
116 | 116 | $dbw->insert( 'thread', $row, __METHOD__ ); |
117 | 117 | $this->id = $dbw->insertId(); |
118 | | - |
| 118 | + |
119 | 119 | // Touch the root |
120 | | - if ( $this->root() ) { |
| 120 | + if ($this->root()) { |
121 | 121 | $this->root()->getTitle()->invalidateCache(); |
122 | 122 | } |
123 | | - |
| 123 | + |
124 | 124 | // Touch the talk page, too. |
125 | 125 | $this->article()->getTitle()->invalidateCache(); |
126 | 126 | } |
127 | | - |
| 127 | + |
128 | 128 | function setRoot( $article ) { |
129 | 129 | $this->rootId = $article->getId(); |
130 | 130 | $this->root = $article; |
— | — | @@ -136,27 +136,27 @@ |
137 | 137 | $this->modified = wfTimestampNow(); |
138 | 138 | $this->updateEditedness( $change_type ); |
139 | 139 | $this->save(); |
140 | | - |
| 140 | + |
141 | 141 | $topmost = $this->topmostThread(); |
142 | 142 | $topmost->modified = wfTimestampNow(); |
143 | 143 | $topmost->save(); |
144 | | - |
| 144 | + |
145 | 145 | ThreadRevision::create( $this, $change_type, $change_object, $reason ); |
146 | 146 | |
147 | 147 | if ( $change_type == Threads::CHANGE_EDITED_ROOT ) { |
148 | 148 | NewMessages::writeMessageStateForUpdatedThread( $this, $change_type, $wgUser ); |
149 | 149 | } |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | function updateEditedness( $change_type ) { |
153 | 153 | global $wgUser; |
154 | | - |
| 154 | + |
155 | 155 | if ( $change_type == Threads::CHANGE_REPLY_CREATED |
156 | 156 | && $this->editedness == Threads::EDITED_NEVER ) { |
157 | 157 | $this->editedness = Threads::EDITED_HAS_REPLY; |
158 | 158 | } elseif ( $change_type == Threads::CHANGE_EDITED_ROOT ) { |
159 | 159 | $originalAuthor = $this->author(); |
160 | | - |
| 160 | + |
161 | 161 | if ( ( $wgUser->getId() == 0 && $originalAuthor->getName() != $wgUser->getName() ) |
162 | 162 | || $wgUser->getId() != $originalAuthor->getId() ) { |
163 | 163 | $this->editedness = Threads::EDITED_BY_OTHERS; |
— | — | @@ -165,60 +165,60 @@ |
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
169 | | - |
| 169 | + |
170 | 170 | /** Unless you know what you're doing, you want commitRevision */ |
171 | | - function save() { |
| 171 | + function save() { |
172 | 172 | $this->dieIfHistorical(); |
173 | 173 | |
174 | 174 | $dbr = wfGetDB( DB_MASTER ); |
175 | | - |
| 175 | + |
176 | 176 | $res = $dbr->update( 'thread', |
177 | 177 | /* SET */ $this->getRow(), |
178 | 178 | /* WHERE */ array( 'thread_id' => $this->id, ), |
179 | 179 | __METHOD__ ); |
180 | | - |
| 180 | + |
181 | 181 | // Touch the root |
182 | | - if ( $this->root() ) { |
| 182 | + if ($this->root()) { |
183 | 183 | $this->root()->getTitle()->invalidateCache(); |
184 | 184 | } |
185 | | - |
| 185 | + |
186 | 186 | // Touch the talk page, too. |
187 | 187 | $this->article()->getTitle()->invalidateCache(); |
188 | 188 | } |
189 | | - |
| 189 | + |
190 | 190 | function getRow() { |
191 | 191 | $id = $this->id(); |
192 | | - |
| 192 | + |
193 | 193 | $dbw = wfGetDB( DB_MASTER ); |
194 | 194 | |
195 | | - if ( !$id ) { |
| 195 | + if (!$id) { |
196 | 196 | $id = $dbw->nextSequenceValue( 'thread_thread_id' ); |
197 | 197 | } |
198 | | - |
| 198 | + |
199 | 199 | // Reflect schema changes here. |
200 | | - |
| 200 | + |
201 | 201 | return array( |
202 | | - 'thread_id' => $id, |
203 | | - 'thread_root' => $this->rootId, |
204 | | - 'thread_parent' => $this->parentId, |
205 | | - 'thread_article_namespace' => $this->articleNamespace, |
206 | | - 'thread_article_title' => $this->articleTitle, |
207 | | - 'thread_modified' => $dbw->timestamp( $this->modified ), |
208 | | - 'thread_created' => $dbw->timestamp( $this->created ), |
209 | | - 'thread_ancestor' => $this->ancestorId, |
210 | | - 'thread_type' => $this->type, |
211 | | - 'thread_subject' => $this->subject, |
212 | | - 'thread_author_id' => $this->authorId, |
213 | | - 'thread_author_name' => $this->authorName, |
214 | | - 'thread_summary_page' => $this->summaryId, |
215 | | - 'thread_editedness' => $this->editedness, |
216 | | - ); |
| 202 | + 'thread_id' => $id, |
| 203 | + 'thread_root' => $this->rootId, |
| 204 | + 'thread_parent' => $this->parentId, |
| 205 | + 'thread_article_namespace' => $this->articleNamespace, |
| 206 | + 'thread_article_title' => $this->articleTitle, |
| 207 | + 'thread_modified' => $dbw->timestamp($this->modified), |
| 208 | + 'thread_created' => $dbw->timestamp($this->created), |
| 209 | + 'thread_ancestor' => $this->ancestorId, |
| 210 | + 'thread_type' => $this->type, |
| 211 | + 'thread_subject' => $this->subject, |
| 212 | + 'thread_author_id' => $this->authorId, |
| 213 | + 'thread_author_name' => $this->authorName, |
| 214 | + 'thread_summary_page' => $this->summaryId, |
| 215 | + 'thread_editedness' => $this->editedness, |
| 216 | + ); |
217 | 217 | } |
218 | | - |
| 218 | + |
219 | 219 | function author() { |
220 | 220 | $this->doLazyUpdates(); |
221 | | - |
222 | | - if ( $this->authorId ) { |
| 221 | + |
| 222 | + if ($this->authorId) { |
223 | 223 | return User::newFromId( $this->authorId ); |
224 | 224 | } else { |
225 | 225 | // Do NOT validate username. If the user did it, they did it. |
— | — | @@ -230,51 +230,49 @@ |
231 | 231 | $this->type = Threads::TYPE_DELETED; |
232 | 232 | $this->commitRevision( Threads::CHANGE_DELETED, $this, $reason ); |
233 | 233 | /* Mark thread as read by all users, or we get blank thingies in New Messages. */ |
234 | | - |
| 234 | + |
235 | 235 | $this->dieIfHistorical(); |
236 | | - |
| 236 | + |
237 | 237 | $dbw = wfGetDB( DB_MASTER ); |
238 | | - |
| 238 | + |
239 | 239 | $dbw->delete( 'user_message_state', array( 'ums_thread' => $this->id() ), |
240 | 240 | __METHOD__ ); |
241 | 241 | } |
242 | | - |
| 242 | + |
243 | 243 | function undelete( $reason ) { |
244 | 244 | $this->type = Threads::TYPE_NORMAL; |
245 | 245 | $this->commitRevision( Threads::CHANGE_UNDELETED, $this, $reason ); |
246 | 246 | } |
247 | 247 | |
248 | 248 | function moveToPage( $title, $reason, $leave_trace ) { |
249 | | - if ( !$this->isTopmostThread() ) |
| 249 | + if (!$this->isTopmostThread() ) |
250 | 250 | throw new MWException( "Attempt to move non-toplevel thread to another page" ); |
251 | | - |
| 251 | + |
252 | 252 | $this->dieIfHistorical(); |
253 | | - |
| 253 | + |
254 | 254 | $dbr = wfGetDB( DB_MASTER ); |
255 | 255 | |
256 | 256 | $oldTitle = $this->article()->getTitle(); |
257 | 257 | $newTitle = $title; |
258 | | - |
| 258 | + |
259 | 259 | $new_articleNamespace = $title->getNamespace(); |
260 | 260 | $new_articleTitle = $title->getDBkey(); |
261 | | - |
| 261 | + |
262 | 262 | // Update on *all* subthreads. |
263 | | - $dbr->update( |
264 | | - 'thread', |
265 | | - array( |
266 | | - 'thread_revision=thread_revision+1', |
267 | | - 'thread_article_namespace' => $new_articleNamespace, |
268 | | - 'thread_article_title' => $new_articleTitle, |
269 | | - 'thread_modified' => $dbr->timestamp( wfTimestampNow() ), |
270 | | - ), |
271 | | - array( 'thread_ancestor' => $this->id() ), |
272 | | - __METHOD__ |
273 | | - ); |
| 263 | + $dbr->update( 'thread', |
| 264 | + array( |
| 265 | + 'thread_revision=thread_revision+1', |
| 266 | + 'thread_article_namespace' => $new_articleNamespace, |
| 267 | + 'thread_article_title' => $new_articleTitle, |
| 268 | + 'thread_modified' => $dbr->timestamp( wfTimestampNow() ), |
| 269 | + ), |
| 270 | + array( 'thread_ancestor' => $this->id() ), |
| 271 | + __METHOD__ ); |
274 | 272 | |
275 | 273 | $this->articleNamespace = $new_articleNamespace; |
276 | 274 | $this->articleTitle = $new_articleTitle; |
277 | 275 | $this->commitRevision( Threads::CHANGE_MOVED_TALKPAGE, null, $reason ); |
278 | | - |
| 276 | + |
279 | 277 | # Log the move |
280 | 278 | $log = new LogPage( 'liquidthreads' ); |
281 | 279 | $log->addEntry( 'move', $this->title(), $reason, array( $oldTitle, $newTitle ) ); |
— | — | @@ -288,57 +286,59 @@ |
289 | 287 | // there. |
290 | 288 | function leaveTrace( $reason, $oldTitle, $newTitle ) { |
291 | 289 | $this->dieIfHistorical(); |
292 | | - |
| 290 | + |
293 | 291 | $dbw = wfGetDB( DB_MASTER ); |
294 | 292 | |
295 | 293 | // Create redirect text |
296 | 294 | $mwRedir = MagicWord::get( 'redirect' ); |
297 | 295 | $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $this->title()->getPrefixedText() . "]]\n"; |
298 | | - |
| 296 | + |
299 | 297 | // Make the article edit. |
300 | | - $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat( $oldTitle ) ); |
| 298 | + $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat($oldTitle) ); |
301 | 299 | $redirectArticle = new Article_LQT_Compat( $traceTitle ); |
302 | 300 | $redirectArticle->doEdit( $redirectText, $reason, EDIT_NEW ); |
303 | 301 | |
304 | 302 | // Add the trace thread to the tracking table. |
305 | | - $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat( $oldTitle ), null, |
| 303 | + $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat($oldTitle), null, |
306 | 304 | Threads::TYPE_MOVED, $this->subject() ); |
307 | 305 | } |
308 | 306 | |
| 307 | + |
| 308 | + |
309 | 309 | function __construct( $line, $unused = null ) { |
310 | 310 | /* SCHEMA changes must be reflected here. */ |
311 | | - |
312 | | - if ( is_null( $line ) ) { // For Thread::create(). |
| 311 | + |
| 312 | + if ( is_null($line) ) { // For Thread::create(). |
313 | 313 | $this->modified = wfTimestampNow(); |
314 | 314 | $this->created = wfTimestampNow(); |
315 | 315 | $this->editedness = Threads::EDITED_NEVER; |
316 | 316 | return; |
317 | 317 | } |
318 | | - |
| 318 | + |
319 | 319 | $dataLoads = array( |
320 | | - 'thread_id' => 'id', |
321 | | - 'thread_root' => 'rootId', |
322 | | - 'thread_article_namespace' => 'articleNamespace', |
323 | | - 'thread_article_title' => 'articleTitle', |
324 | | - 'thread_summary_page' => 'summaryId', |
325 | | - 'thread_ancestor' => 'ancestorId', |
326 | | - 'thread_parent' => 'parentId', |
327 | | - 'thread_modified' => 'modified', |
328 | | - 'thread_created' => 'created', |
329 | | - 'thread_type' => 'type', |
330 | | - 'thread_editedness' => 'editedness', |
331 | | - 'thread_subject' => 'subject', |
332 | | - 'thread_author_id' => 'authorId', |
333 | | - 'thread_author_name' => 'authorName', |
334 | | - ); |
335 | | - |
336 | | - foreach ( $dataLoads as $db_field => $member_field ) { |
337 | | - if ( isset( $line->$db_field ) ) { |
| 320 | + 'thread_id' => 'id', |
| 321 | + 'thread_root' => 'rootId', |
| 322 | + 'thread_article_namespace' => 'articleNamespace', |
| 323 | + 'thread_article_title' => 'articleTitle', |
| 324 | + 'thread_summary_page' => 'summaryId', |
| 325 | + 'thread_ancestor' => 'ancestorId', |
| 326 | + 'thread_parent' => 'parentId', |
| 327 | + 'thread_modified' => 'modified', |
| 328 | + 'thread_created' => 'created', |
| 329 | + 'thread_type' => 'type', |
| 330 | + 'thread_editedness' => 'editedness', |
| 331 | + 'thread_subject' => 'subject', |
| 332 | + 'thread_author_id' => 'authorId', |
| 333 | + 'thread_author_name' => 'authorName', |
| 334 | + ); |
| 335 | + |
| 336 | + foreach( $dataLoads as $db_field => $member_field ) { |
| 337 | + if ( isset($line->$db_field) ) { |
338 | 338 | $this->$member_field = $line->$db_field; |
339 | 339 | } |
340 | 340 | } |
341 | | - |
342 | | - if ( isset( $line->page_namespace ) && isset( $line->page_title ) ) { |
| 341 | + |
| 342 | + if ( isset($line->page_namespace) && isset($line->page_title) ) { |
343 | 343 | $root_title = Title::makeTitle( $line->page_namespace, $line->page_title ); |
344 | 344 | $this->root = new Article_LQT_Compat( $root_title ); |
345 | 345 | $this->root->loadPageData( $line ); |
— | — | @@ -348,223 +348,220 @@ |
349 | 349 | } else { |
350 | 350 | $root_title = Title::newFromID( $this->rootId ); |
351 | 351 | } |
352 | | - |
353 | | - if ( $root_title ) { |
| 352 | + |
| 353 | + if ($root_title) { |
354 | 354 | $this->root = new Article_LQT_Compat( $root_title ); |
355 | 355 | } |
356 | 356 | } |
357 | | - |
| 357 | + |
358 | 358 | $this->doLazyUpdates( $line ); |
359 | 359 | } |
360 | | - |
| 360 | + |
361 | 361 | // Load a list of threads in bulk, including all subthreads. |
362 | | - static function bulkLoad( $rows ) { |
| 362 | + static function bulkLoad( $rows ) { |
363 | 363 | // Preload subthreads |
364 | 364 | $thread_ids = array(); |
365 | 365 | $all_thread_rows = $rows; |
366 | 366 | $pageIds = array(); |
367 | 367 | $linkBatch = new LinkBatch(); |
368 | | - |
369 | | - if ( !is_array( self::$replyCacheById ) ) { |
| 368 | + |
| 369 | + if (!is_array(self::$replyCacheById)) { |
370 | 370 | self::$replyCacheById = array(); |
371 | 371 | } |
372 | | - |
| 372 | + |
373 | 373 | // Build a list of threads for which to pull replies, and page IDs to pull data for. |
374 | 374 | // Also, pre-initialise the reply cache. |
375 | | - foreach ( $rows as $row ) { |
| 375 | + foreach( $rows as $row ) { |
376 | 376 | $thread_ids[] = $row->thread_id; |
377 | | - |
| 377 | + |
378 | 378 | // Grab page data while we're here. |
379 | | - if ( $row->thread_root ) |
| 379 | + if ($row->thread_root) |
380 | 380 | $pageIds[] = $row->thread_root; |
381 | | - if ( $row->thread_summary_page ) |
| 381 | + if ($row->thread_summary_page) |
382 | 382 | $pageIds[] = $row->thread_summary_page; |
383 | | - |
| 383 | + |
384 | 384 | if ( !isset( self::$replyCacheById[$row->thread_id] ) ) { |
385 | 385 | self::$replyCacheById[$row->thread_id] = array(); |
386 | 386 | } |
387 | 387 | } |
388 | | - |
| 388 | + |
389 | 389 | // Pull replies to the threads provided, and as above, pull page IDs to pull data for, |
390 | 390 | // pre-initialise the reply cache, and stash the row object for later use. |
391 | | - if ( count( $thread_ids ) ) { |
| 391 | + if ( count($thread_ids) ) { |
392 | 392 | $dbr = wfGetDB( DB_SLAVE ); |
393 | 393 | $res = $dbr->select( 'thread', '*', array( 'thread_ancestor' => $thread_ids ), |
394 | 394 | __METHOD__ ); |
395 | | - |
396 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 395 | + |
| 396 | + while( $row = $dbr->fetchObject($res) ) { |
397 | 397 | // Grab page data while we're here. |
398 | | - if ( $row->thread_root ) |
| 398 | + if ($row->thread_root) |
399 | 399 | $pageIds[] = $row->thread_root; |
400 | | - if ( $row->thread_summary_page ) |
| 400 | + if ($row->thread_summary_page) |
401 | 401 | $pageIds[] = $row->thread_summary_page; |
402 | | - |
| 402 | + |
403 | 403 | $all_thread_rows[] = $row; |
404 | | - |
| 404 | + |
405 | 405 | if ( !isset( self::$replyCacheById[$row->thread_id] ) ) { |
406 | 406 | self::$replyCacheById[$row->thread_id] = array(); |
407 | 407 | } |
408 | 408 | } |
409 | 409 | } |
410 | | - |
411 | | - // Preload page data (restrictions, and preload Article object with everything from |
| 410 | + |
| 411 | + // Preload page data (restrictions, and preload Article object with everything from |
412 | 412 | // the page table. Also, precache the title and article objects for pulling later. |
413 | 413 | $articlesById = array(); |
414 | | - if ( count( $pageIds ) ) { |
| 414 | + if ( count($pageIds) ) { |
415 | 415 | // Pull restriction info. Needs to come first because otherwise it's done per |
416 | 416 | // page by loadPageData. |
417 | 417 | $restrictionRows = array_fill_keys( $pageIds, array() ); |
418 | 418 | $res = $dbr->select( 'page_restrictions', '*', array( 'pr_page' => $pageIds ), |
419 | 419 | __METHOD__ ); |
420 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 420 | + while( $row = $dbr->fetchObject( $res ) ) { |
421 | 421 | $restrictionRows[$row->pr_page][] = $row; |
422 | 422 | } |
423 | | - |
| 423 | + |
424 | 424 | $res = $dbr->select( 'page', '*', array( 'page_id' => $pageIds ), __METHOD__ ); |
425 | | - |
426 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 425 | + |
| 426 | + while( $row = $dbr->fetchObject( $res ) ) { |
427 | 427 | $t = Title::newFromRow( $row ); |
428 | | - |
| 428 | + |
429 | 429 | if ( isset( $restrictionRows[$t->getArticleId()] ) ) { |
430 | 430 | $t->loadRestrictionsFromRows( $restrictionRows[$t->getArticleId()], |
431 | 431 | $row->page_restrictions ); |
432 | 432 | } |
433 | | - |
| 433 | + |
434 | 434 | $article = new Article_LQT_Compat( $t ); |
435 | 435 | $article->loadPageData( $row ); |
436 | | - |
| 436 | + |
437 | 437 | self::$titleCacheById[$t->getArticleId()] = $t; |
438 | 438 | $articlesById[$article->getId()] = $article; |
439 | | - |
440 | | - if ( count( self::$titleCacheById ) > 10000 ) { |
| 439 | + |
| 440 | + if ( count(self::$titleCacheById) > 10000 ) { |
441 | 441 | self::$titleCacheById = array(); |
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
445 | | - |
| 445 | + |
446 | 446 | // For every thread we have a row object for, load a Thread object, add the user and |
447 | 447 | // user talk pages to a link batch, cache the relevant user id/name pair, and |
448 | 448 | // populate the reply cache. |
449 | | - foreach ( $all_thread_rows as $row ) { |
| 449 | + foreach( $all_thread_rows as $row ) { |
450 | 450 | $thread = new Thread( $row, null ); |
451 | | - |
452 | | - if ( isset( $articlesById[$thread->rootId] ) ) |
| 451 | + |
| 452 | + if ( isset($articlesById[$thread->rootId]) ) |
453 | 453 | $thread->root = $articlesById[$thread->rootId]; |
454 | | - |
| 454 | + |
455 | 455 | Threads::$cache_by_id[$row->thread_id] = $thread; |
456 | | - |
| 456 | + |
457 | 457 | // User cache data |
458 | 458 | $t = Title::makeTitleSafe( NS_USER, $row->thread_author_name ); |
459 | 459 | $linkBatch->addObj( $t ); |
460 | 460 | $t = Title::makeTitleSafe( NS_USER_TALK, $row->thread_author_name ); |
461 | 461 | $linkBatch->addObj( $t ); |
462 | | - |
| 462 | + |
463 | 463 | User::$idCacheByName[$row->thread_author_name] = $row->thread_author_id; |
464 | | - |
| 464 | + |
465 | 465 | if ( $row->thread_parent ) { |
466 | 466 | self::$replyCacheById[$row->thread_parent][$row->thread_id] = $thread; |
467 | 467 | } |
468 | 468 | } |
469 | | - |
| 469 | + |
470 | 470 | // Pull link batch data. |
471 | 471 | $linkBatch->execute(); |
472 | | - |
| 472 | + |
473 | 473 | $threads = array(); |
474 | | - |
| 474 | + |
475 | 475 | // Fill and return an array with the threads that were actually requested. |
476 | | - foreach ( $rows as $row ) { |
| 476 | + foreach( $rows as $row ) { |
477 | 477 | $threads[$row->thread_id] = Threads::$cache_by_id[$row->thread_id]; |
478 | 478 | } |
479 | | - |
| 479 | + |
480 | 480 | return $threads; |
481 | 481 | } |
482 | | - |
| 482 | + |
483 | 483 | /** |
484 | 484 | * Return the User object representing the author of the first revision |
485 | 485 | * (or null, if the database is screwed up). |
486 | 486 | */ |
487 | 487 | function loadOriginalAuthorFromRevision( ) { |
488 | 488 | $this->dieIfHistorical(); |
489 | | - |
| 489 | + |
490 | 490 | $dbr = wfGetDB( DB_SLAVE ); |
491 | | - |
| 491 | + |
492 | 492 | $article = $this->root(); |
493 | 493 | |
494 | | - $line = $dbr->selectRow( |
495 | | - 'revision', |
496 | | - 'rev_user_text', |
497 | | - array( 'rev_page' => $article->getID() ), |
498 | | - __METHOD__, |
499 | | - array( |
500 | | - 'ORDER BY' => 'rev_timestamp', |
501 | | - 'LIMIT' => '1' |
502 | | - ) |
503 | | - ); |
504 | | - |
| 494 | + $line = $dbr->selectRow( 'revision', |
| 495 | + 'rev_user_text', |
| 496 | + array( 'rev_page' => $article->getID() ), |
| 497 | + __METHOD__, |
| 498 | + array( |
| 499 | + 'ORDER BY' => 'rev_timestamp', |
| 500 | + 'LIMIT' => '1' |
| 501 | + ) ); |
505 | 502 | if ( $line ) |
506 | 503 | return User::newFromName( $line->rev_user_text, false ); |
507 | 504 | else |
508 | 505 | return null; |
509 | 506 | } |
510 | | - |
| 507 | + |
511 | 508 | // Lazy updates done whenever a thread is loaded. |
512 | 509 | // Much easier than running a long-running maintenance script. |
513 | 510 | function doLazyUpdates( ) { |
514 | 511 | if ( $this->isHistorical() ) |
515 | 512 | return; // Don't do lazy updates on stored historical threads. |
516 | | - |
| 513 | + |
517 | 514 | // This is an invocation guard to avoid infinite recursion when fixing a |
518 | 515 | // missing ancestor. |
519 | 516 | static $doingUpdates = false; |
520 | | - if ( $doingUpdates ) return; |
| 517 | + if ($doingUpdates) return; |
521 | 518 | $doingUpdates = true; |
522 | | - |
| 519 | + |
523 | 520 | // Fix missing ancestry information. |
524 | 521 | // (there was a bug where this was not saved properly) |
525 | | - if ( $this->parentId && !$this->ancestorId ) { |
| 522 | + if ($this->parentId &&!$this->ancestorId) { |
526 | 523 | $this->fixMissingAncestor(); |
527 | 524 | } |
528 | | - |
| 525 | + |
529 | 526 | $ancestor = $this->topmostThread(); |
530 | | - |
| 527 | + |
531 | 528 | $set = array(); |
532 | | - |
| 529 | + |
533 | 530 | // Fix missing subject information |
534 | 531 | // (this information only started to be added later) |
535 | 532 | if ( !$this->subject && $this->root() ) { |
536 | 533 | $detectedSubject = $this->root()->getTitle()->getText(); |
537 | 534 | $parts = self::splitIncrementFromSubject( $detectedSubject ); |
538 | | - |
| 535 | + |
539 | 536 | $this->subject = $detectedSubject = $parts[1]; |
540 | | - |
| 537 | + |
541 | 538 | // Update in the DB |
542 | 539 | $set['thread_subject'] = $detectedSubject; |
543 | 540 | } |
544 | | - |
| 541 | + |
545 | 542 | // Fix inconsistent subject information |
546 | 543 | // (in some intermediate versions this was not updated when the subject was changed) |
547 | | - if ( $this->subject() != $ancestor->subject() ) { |
| 544 | + if ($this->subject() != $ancestor->subject()) { |
548 | 545 | $set['thread_subject'] = $ancestor->subject(); |
549 | | - |
| 546 | + |
550 | 547 | $this->subject = $ancestor->subject(); |
551 | 548 | } |
552 | | - |
| 549 | + |
553 | 550 | // Fix missing authorship information |
554 | 551 | // (this information only started to be added later) |
555 | 552 | if ( !$this->authorName ) { |
556 | 553 | $author = $this->loadOriginalAuthorFromRevision(); |
557 | | - |
| 554 | + |
558 | 555 | $this->authorId = $author->getId(); |
559 | 556 | $this->authorName = $author->getName(); |
560 | | - |
| 557 | + |
561 | 558 | $set['thread_author_name'] = $this->authorName; |
562 | 559 | $set['thread_author_id'] = $this->authorId; |
563 | 560 | } |
564 | | - |
565 | | - // Check for article being in subject, not talk namespace. |
566 | | - // If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant |
| 561 | + |
| 562 | + //Check for article being in subject, not talk namespace. |
| 563 | + //If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant |
567 | 564 | // to be on the corresponding talk page, but only if the talk-page is a LQT page. |
568 | | - // (Previous versions stored the subject page, for some totally bizarre reason) |
| 565 | + //(Previous versions stored the subject page, for some totally bizarre reason) |
569 | 566 | // Old versions also sometimes store the thread page for trace threads as the |
570 | 567 | // article, not as the root. |
571 | 568 | // Trying not to exacerbate this by moving it to be the 'Thread talk' page. |
— | — | @@ -574,103 +571,99 @@ |
575 | 572 | $articleTitle->getNamespace() != NS_LQT_THREAD ) { |
576 | 573 | $newTitle = $articleTitle->getTalkPage(); |
577 | 574 | $newArticle = new Article_LQT_Compat( $newTitle ); |
578 | | - |
| 575 | + |
579 | 576 | $set['thread_article_namespace'] = $newTitle->getNamespace(); |
580 | 577 | $set['thread_article_title'] = $newTitle->getDbKey(); |
581 | | - |
| 578 | + |
582 | 579 | $this->articleNamespace = $newTitle->getNamespace(); |
583 | 580 | $this->articleTitle = $newTitle->getDbKey(); |
584 | | - |
| 581 | + |
585 | 582 | $this->article = $newArticle; |
586 | 583 | } |
587 | | - |
| 584 | + |
588 | 585 | // Check for article corruption from incomplete thread moves. |
589 | 586 | // (thread moves only updated this on immediate replies, not replies to replies etc) |
590 | | - if ( ! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) { |
| 587 | + if (! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) { |
591 | 588 | $title = $ancestor->article()->getTitle(); |
592 | 589 | $set['thread_article_namespace'] = $title->getNamespace(); |
593 | 590 | $set['thread_article_title'] = $title->getDbKey(); |
594 | | - |
| 591 | + |
595 | 592 | $this->articleNamespace = $title->getNamespace(); |
596 | 593 | $this->articleTitle = $title->getDbKey(); |
597 | | - |
| 594 | + |
598 | 595 | $this->article = $ancestor->article(); |
599 | 596 | } |
600 | | - |
601 | | - if ( count( $set ) ) { |
| 597 | + |
| 598 | + if ( count($set) ) { |
602 | 599 | $dbw = wfGetDB( DB_MASTER ); |
603 | | - |
| 600 | + |
604 | 601 | $dbw->update( 'thread', $set, array( 'thread_id' => $this->id() ), __METHOD__ ); |
605 | 602 | } |
606 | | - |
| 603 | + |
607 | 604 | // Done |
608 | 605 | $doingUpdates = false; |
609 | 606 | } |
610 | 607 | |
611 | 608 | function addReply( $thread ) { |
612 | 609 | $thread->setSuperThread( $this ); |
613 | | - |
614 | | - if ( is_array( $this->replies ) ) { |
| 610 | + |
| 611 | + if ( is_array($this->replies) ) { |
615 | 612 | $this->replies[$thread->id()] = $thread; |
616 | 613 | } else { |
617 | 614 | $this->replies(); |
618 | 615 | $this->replies[$thread->id()] = $thread; |
619 | 616 | } |
620 | 617 | } |
621 | | - |
| 618 | + |
622 | 619 | function removeReply( $thread ) { |
623 | | - if ( is_object( $thread ) ) { |
| 620 | + if ( is_object($thread) ) { |
624 | 621 | $thread = $thread->id(); |
625 | 622 | } |
626 | | - |
| 623 | + |
627 | 624 | $this->replies(); |
628 | | - |
| 625 | + |
629 | 626 | unset( $thread->replies[$thread] ); |
630 | 627 | } |
631 | | - |
| 628 | + |
632 | 629 | function replies() { |
633 | | - if ( !is_null( $this->replies ) ) { |
| 630 | + if ( !is_null($this->replies) ) { |
634 | 631 | return $this->replies; |
635 | 632 | } |
636 | | - |
| 633 | + |
637 | 634 | $this->dieIfHistorical(); |
638 | | - |
| 635 | + |
639 | 636 | // Check cache |
640 | 637 | if ( isset( self::$replyCacheById[$this->id()] ) ) { |
641 | 638 | return $this->replies = self::$replyCacheById[$this->id()]; |
642 | 639 | } |
643 | | - |
| 640 | + |
644 | 641 | $this->replies = array(); |
645 | | - |
| 642 | + |
646 | 643 | $dbr = wfGetDB( DB_SLAVE ); |
647 | | - |
648 | | - $res = $dbr->select( |
649 | | - 'thread', |
650 | | - '*', |
651 | | - array( 'thread_parent' => $this->id() ), |
652 | | - __METHOD__ |
653 | | - ); |
654 | | - |
| 644 | + |
| 645 | + $res = $dbr->select( 'thread', '*', |
| 646 | + array( 'thread_parent' => $this->id() ), __METHOD__ ); |
| 647 | + |
655 | 648 | $rows = array(); |
656 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 649 | + while ( $row = $dbr->fetchObject($res) ) { |
657 | 650 | $rows[] = $row; |
658 | 651 | } |
659 | | - |
| 652 | + |
660 | 653 | $this->replies = Thread::bulkLoad( $rows ); |
661 | | - |
| 654 | + |
662 | 655 | return $this->replies; |
663 | 656 | } |
664 | 657 | |
665 | 658 | function setSuperthread( $thread ) { |
666 | | - if ( $thread == null ) { |
| 659 | + if ($thread == null) { |
667 | 660 | $this->parentId = null; |
668 | 661 | $this->ancestorId = 0; |
669 | 662 | return; |
670 | 663 | } |
671 | | - |
| 664 | + |
672 | 665 | $this->parentId = $thread->id(); |
673 | 666 | $this->superthread = $thread; |
674 | | - |
| 667 | + |
675 | 668 | if ( $thread->isTopmostThread() ) { |
676 | 669 | $this->ancestorId = $thread->id(); |
677 | 670 | $this->ancestor = $thread; |
— | — | @@ -696,23 +689,23 @@ |
697 | 690 | function topmostThread() { |
698 | 691 | if ( $this->isTopmostThread() ) { |
699 | 692 | return $this->ancestor = $this; |
700 | | - } elseif ( $this->ancestor ) { |
| 693 | + } elseif ($this->ancestor) { |
701 | 694 | return $this->ancestor; |
702 | 695 | } else { |
703 | 696 | $this->dieIfHistorical(); |
704 | | - |
| 697 | + |
705 | 698 | $thread = Threads::withId( $this->ancestorId ); |
706 | 699 | |
707 | | - if ( !$thread ) { |
| 700 | + if (!$thread) { |
708 | 701 | $thread = $this->fixMissingAncestor(); |
709 | 702 | } |
710 | | - |
| 703 | + |
711 | 704 | $this->ancestor = $thread; |
712 | | - |
| 705 | + |
713 | 706 | return $thread; |
714 | 707 | } |
715 | 708 | } |
716 | | - |
| 709 | + |
717 | 710 | function setAncestor( $newAncestor ) { |
718 | 711 | if ( is_object( $newAncestor ) ) { |
719 | 712 | $this->ancestorId = $newAncestor->id(); |
— | — | @@ -725,23 +718,19 @@ |
726 | 719 | // Fix the corruption by repeatedly grabbing the parent until we hit the topmost thread. |
727 | 720 | function fixMissingAncestor() { |
728 | 721 | $thread = $this; |
729 | | - |
| 722 | + |
730 | 723 | $this->dieIfHistorical(); |
731 | | - |
| 724 | + |
732 | 725 | while ( !$thread->isTopmostThread() ) { |
733 | 726 | $thread = $thread->superthread(); |
734 | 727 | } |
735 | | - |
| 728 | + |
736 | 729 | $this->ancestorId = $thread->id(); |
737 | | - |
| 730 | + |
738 | 731 | $dbw = wfGetDB( DB_MASTER ); |
739 | | - $dbw->update( |
740 | | - 'thread', |
741 | | - array( 'thread_ancestor' => $thread->id() ), |
742 | | - array( 'thread_id' => $this->id() ), |
743 | | - __METHOD__ |
744 | | - ); |
745 | | - |
| 732 | + $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ), |
| 733 | + array( 'thread_id' => $this->id() ), __METHOD__ ); |
| 734 | + |
746 | 735 | return $thread; |
747 | 736 | } |
748 | 737 | |
— | — | @@ -756,14 +745,14 @@ |
757 | 746 | $this->articleTitle = $a->getTitle()->getDBkey(); |
758 | 747 | $this->touch(); |
759 | 748 | } |
760 | | - |
| 749 | + |
761 | 750 | function touch() { |
762 | 751 | // Nothing here yet |
763 | 752 | } |
764 | 753 | |
765 | 754 | function article() { |
766 | 755 | if ( $this->article ) return $this->article; |
767 | | - |
| 756 | + |
768 | 757 | if ( !is_null( $this->articleId ) ) { |
769 | 758 | $title = Title::newFromID( $this->articleId ); |
770 | 759 | if ( $title ) { |
— | — | @@ -791,19 +780,19 @@ |
792 | 781 | function root( ) { |
793 | 782 | if ( !$this->rootId ) return null; |
794 | 783 | if ( !$this->root ) { |
795 | | - if ( isset( self::$articleCacheById[$this->rootId] ) ) { |
| 784 | + if ( isset(self::$articleCacheById[$this->rootId]) ) { |
796 | 785 | $this->root = self::$articleCacheById[$this->rootId]; |
797 | 786 | return $this->root; |
798 | 787 | } |
799 | | - |
| 788 | + |
800 | 789 | if ( isset( self::$titleCacheById[$this->rootId] ) ) { |
801 | 790 | $title = self::$titleCacheById[$this->rootId]; |
802 | 791 | } else { |
803 | 792 | $title = Title::newFromID( $this->rootId ); |
804 | 793 | } |
805 | | - |
806 | | - if ( !$title ) return null; |
807 | | - |
| 794 | + |
| 795 | + if (!$title) return null; |
| 796 | + |
808 | 797 | $this->root = new Article_LQT_Compat( $title ); |
809 | 798 | } |
810 | 799 | return $this->root; |
— | — | @@ -816,19 +805,20 @@ |
817 | 806 | function summary() { |
818 | 807 | if ( !$this->summaryId ) |
819 | 808 | return null; |
820 | | - |
| 809 | + |
821 | 810 | if ( !$this->summary ) { |
822 | 811 | $title = Title::newFromID( $this->summaryId ); |
823 | | - |
824 | | - if ( !$title ) { |
825 | | - wfDebug( __METHOD__ . ": supposed summary doesn't exist" ); |
| 812 | + |
| 813 | + if (!$title) { |
| 814 | + wfDebug( __METHOD__.": supposed summary doesn't exist" ); |
826 | 815 | $this->summaryId = null; |
827 | 816 | return null; |
828 | 817 | } |
829 | | - |
| 818 | + |
830 | 819 | $this->summary = new Article_LQT_Compat( $title ); |
831 | | - } |
832 | 820 | |
| 821 | + } |
| 822 | + |
833 | 823 | return $this->summary; |
834 | 824 | } |
835 | 825 | |
— | — | @@ -858,7 +848,7 @@ |
859 | 849 | function subject() { |
860 | 850 | return $this->subject; |
861 | 851 | } |
862 | | - |
| 852 | + |
863 | 853 | function setSubject( $subject ) { |
864 | 854 | $this->subject = $subject; |
865 | 855 | } |
— | — | @@ -893,8 +883,8 @@ |
894 | 884 | function type() { |
895 | 885 | return $this->type; |
896 | 886 | } |
897 | | - |
898 | | - function setType( $t ) { |
| 887 | + |
| 888 | + function setType($t) { |
899 | 889 | $this->type = $t; |
900 | 890 | } |
901 | 891 | |
— | — | @@ -902,7 +892,7 @@ |
903 | 893 | $rev = Revision::newFromId( $this->root()->getLatest() ); |
904 | 894 | $rtitle = Title::newFromRedirect( $rev->getRawText() ); |
905 | 895 | if ( !$rtitle ) return null; |
906 | | - |
| 896 | + |
907 | 897 | $this->dieIfHistorical(); |
908 | 898 | $rthread = Threads::withRoot( new Article_LQT_Compat( $rtitle ) ); |
909 | 899 | return $rthread; |
— | — | @@ -926,102 +916,98 @@ |
927 | 917 | $result = $parent_restrictions; |
928 | 918 | return false; |
929 | 919 | } |
930 | | - } |
931 | 920 | |
| 921 | + } |
| 922 | + |
932 | 923 | function getAnchorName() { |
933 | 924 | return "lqt_thread_{$this->id()}"; |
934 | 925 | } |
935 | | - |
| 926 | + |
936 | 927 | function updateHistory() { |
937 | 928 | // $dbr = wfGetDB( DB_SLAVE ); |
938 | | -// |
939 | | -// $res = $dbr->select( |
940 | | -// 'historical_thread', |
941 | | -// '*', |
942 | | -// array( 'hthread_id' => $this->id() ), |
943 | | -// __METHOD__, |
944 | | -// array( 'ORDER BY' => 'hthread_revision ASC' ) |
945 | | -// ); |
946 | | -// |
| 929 | +// |
| 930 | +// $res = $dbr->select( 'historical_thread', '*', |
| 931 | +// array( 'hthread_id' => $this->id() ), |
| 932 | +// __METHOD__, |
| 933 | +// array( 'ORDER BY' => 'hthread_revision ASC' ) ); |
| 934 | +// |
947 | 935 | // foreach( $row as $res ) { |
948 | 936 | // $historical_thread = HistoricalThread::fromTextRepresentation( $row->hthread_content ); |
949 | | -// |
950 | | -// // Insert a revision into the database. |
951 | | -// $rev = ThreadRevision::create( |
952 | | -// $historical_thread, |
953 | | -// $historical_thread->changeType(), |
954 | | -// $historical_thread->changeObject(), |
955 | | -// $historical_thread->changeComment(), |
956 | | -// $historical_thread->changeUser(), |
957 | | -// $historical_thread->modified() |
958 | | -// ); |
| 937 | +// |
| 938 | +// // Insert a revision into the database. |
| 939 | +// $rev = ThreadRevision::create( $historical_thread, |
| 940 | +// $historical_thread->changeType(), |
| 941 | +// $historical_thread->changeObject(), |
| 942 | +// $historical_thread->changeComment(), |
| 943 | +// $historical_thread->changeUser(), |
| 944 | +// $historical_thread->modified() ); |
959 | 945 | // } |
960 | 946 | } |
961 | | - |
| 947 | + |
962 | 948 | function setAuthor( $user ) { |
963 | 949 | $this->authorId = $user->getId(); |
964 | 950 | $this->authorName = $user->getName(); |
965 | 951 | } |
966 | | - |
| 952 | + |
967 | 953 | // Load all lazy-loaded data in prep for (e.g.) serialization. |
968 | 954 | function loadAllData() { |
969 | 955 | // Make sure superthread and topmost thread are loaded. |
970 | 956 | $this->superthread(); |
971 | 957 | $this->topmostThread(); |
972 | | - |
| 958 | + |
973 | 959 | // Make sure replies, and all the data therein, is loaded. |
974 | | - foreach ( $this->replies() as $reply ) { |
| 960 | + foreach( $this->replies() as $reply ) { |
975 | 961 | $reply->loadAllData(); |
976 | 962 | } |
977 | 963 | } |
978 | | - |
| 964 | + |
979 | 965 | // On serialization, load all data because it will be different in the DB when we wake up. |
980 | 966 | function __sleep() { |
981 | | - |
| 967 | + |
982 | 968 | $this->loadAllData(); |
983 | | - |
| 969 | + |
984 | 970 | $fields = array_keys( get_object_vars( $this ) ); |
985 | | - |
| 971 | + |
986 | 972 | // Filter out article objects, there be dragons (or unserialization problems) |
987 | 973 | $fields = array_diff( $fields, array( 'root', 'article', 'summary', 'sleeping' ) ); |
988 | | - |
| 974 | + |
989 | 975 | return $fields; |
990 | 976 | } |
991 | | - |
| 977 | + |
992 | 978 | function __wakeup() { |
993 | 979 | // Mark as historical. |
994 | 980 | $this->isHistorical = true; |
995 | 981 | } |
996 | | - |
| 982 | + |
997 | 983 | // This is a safety valve that makes sure that the DB is NEVER touched by a historical |
998 | 984 | // thread (even for reading, because the data will be out of date). |
999 | 985 | function dieIfHistorical() { |
1000 | | - if ( $this->isHistorical() ) { |
| 986 | + if ($this->isHistorical()) { |
1001 | 987 | throw new MWException( "Attempted write or DB operation on historical thread" ); |
1002 | 988 | } |
1003 | 989 | } |
1004 | | - |
| 990 | + |
1005 | 991 | function rootRevision() { |
1006 | | - if ( !$this->isHistorical() || !isset( $this->topmostThread()->threadRevision ) ) { |
| 992 | + if ( !$this->isHistorical() || !isset($this->topmostThread()->threadRevision) ) { |
1007 | 993 | return null; |
1008 | 994 | } |
1009 | | - |
| 995 | + |
1010 | 996 | $dbr = wfGetDB( DB_SLAVE ); |
1011 | | - |
| 997 | + |
1012 | 998 | $revision = $this->topmostThread()->threadRevision; |
1013 | 999 | $timestamp = $dbr->timestamp( $revision->getTimestamp() ); |
1014 | | - |
| 1000 | + |
1015 | 1001 | $conds = array( |
1016 | | - 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ), |
| 1002 | + 'rev_timestamp<='.$dbr->addQuotes( $timestamp ), |
1017 | 1003 | 'page_namespace' => $this->root()->getTitle()->getNamespace(), |
1018 | 1004 | 'page_title' => $this->root()->getTitle()->getDBKey(), |
1019 | 1005 | ); |
1020 | | - |
| 1006 | + |
1021 | 1007 | $join_conds = array( 'page' => array( 'JOIN', 'rev_page=page_id' ) ); |
1022 | | - |
| 1008 | + |
1023 | 1009 | $row = $dbr->selectRow( array( 'revision', 'page' ), '*', $conds, __METHOD__, |
1024 | 1010 | array( 'ORDER BY' => 'rev_timestamp DESC' ), $join_conds ); |
1025 | | - |
| 1011 | + |
1026 | 1012 | return $row->rev_id; |
1027 | 1013 | } |
1028 | 1014 | } |
Index: trunk/extensions/LiquidThreads/classes/HistoricalThread.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) die; |
4 | 4 | |
5 | 5 | class HistoricalThread extends Thread { |
| 6 | + |
6 | 7 | /* Information about what changed in this revision. */ |
7 | 8 | protected $changeType; |
8 | 9 | protected $changeObject; |
— | — | @@ -56,12 +57,12 @@ |
57 | 58 | function isHistorical() { |
58 | 59 | return true; |
59 | 60 | } |
| 61 | + |
60 | 62 | |
61 | | - |
62 | 63 | function changeType() { |
63 | 64 | return $this->changeType; |
64 | 65 | } |
65 | | - |
| 66 | + |
66 | 67 | function changeObject() { |
67 | 68 | return $this->replyWithId( $this->changeObject ); |
68 | 69 | } |
— | — | @@ -94,7 +95,7 @@ |
95 | 96 | function changeComment() { |
96 | 97 | return $this->changeComment; |
97 | 98 | } |
98 | | - |
| 99 | + |
99 | 100 | function setChangeUser( $user ) { |
100 | 101 | $this->changeUser = $user->getId(); |
101 | 102 | $this->changeUserText = $user->getName(); |
Index: trunk/extensions/LiquidThreads/classes/Threads.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | |
5 | 5 | /** Module of factory methods. */ |
6 | 6 | class Threads { |
| 7 | + |
7 | 8 | const TYPE_NORMAL = 0; |
8 | 9 | const TYPE_MOVED = 1; |
9 | 10 | const TYPE_DELETED = 2; |
— | — | @@ -20,7 +21,7 @@ |
21 | 22 | const CHANGE_MERGED_FROM = 10; |
22 | 23 | const CHANGE_MERGED_TO = 11; |
23 | 24 | const CHANGE_SPLIT_FROM = 12; |
24 | | - |
| 25 | + |
25 | 26 | static $VALID_CHANGE_TYPES = array( self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT, |
26 | 27 | self::CHANGE_REPLY_CREATED, self::CHANGE_NEW_THREAD, self::CHANGE_DELETED, self::CHANGE_UNDELETED, |
27 | 28 | self::CHANGE_MOVED_TALKPAGE, self::CHANGE_SPLIT, self::CHANGE_EDITED_SUBJECT, |
— | — | @@ -57,26 +58,26 @@ |
58 | 59 | } |
59 | 60 | } |
60 | 61 | } |
61 | | - |
| 62 | + |
62 | 63 | static function loadFromResult( $res, $db ) { |
63 | 64 | $rows = array(); |
64 | | - |
65 | | - while ( $row = $db->fetchObject( $res ) ) { |
| 65 | + |
| 66 | + while( $row = $db->fetchObject( $res ) ) { |
66 | 67 | $rows[] = $row; |
67 | 68 | } |
68 | | - |
| 69 | + |
69 | 70 | return Thread::bulkLoad( $rows ); |
70 | 71 | } |
71 | 72 | |
72 | 73 | static function where( $where, $options = array() ) { |
73 | 74 | global $wgDBprefix; |
74 | 75 | $dbr = wfGetDB( DB_SLAVE ); |
75 | | - |
| 76 | + |
76 | 77 | $res = $dbr->select( 'thread', '*', $where, __METHOD__, $options ); |
77 | 78 | $threads = Threads::loadFromResult( $res, $dbr ); |
78 | 79 | |
79 | 80 | foreach ( $threads as $thread ) { |
80 | | - if ( $thread->root() ) { |
| 81 | + if ($thread->root()) { |
81 | 82 | self::$cache_by_root[$thread->root()->getID()] = $thread; |
82 | 83 | } |
83 | 84 | self::$cache_by_id[$thread->id()] = $thread; |
— | — | @@ -92,7 +93,7 @@ |
93 | 94 | |
94 | 95 | private static function assertSingularity( $threads, $attribute, $value ) { |
95 | 96 | if ( count( $threads ) == 0 ) { return null; } |
96 | | - if ( count( $threads ) == 1 ) { return array_pop( $threads ); } |
| 97 | + if ( count( $threads ) == 1 ) { return array_pop($threads); } |
97 | 98 | if ( count( $threads ) > 1 ) { |
98 | 99 | Threads::databaseError( "More than one thread with $attribute = $value." ); |
99 | 100 | return null; |
— | — | @@ -125,7 +126,7 @@ |
126 | 127 | return self::$cache_by_id[$id]; |
127 | 128 | } |
128 | 129 | $ts = Threads::where( array( 'thread_id' => $id ) ); |
129 | | - |
| 130 | + |
130 | 131 | return self::assertSingularity( $ts, 'thread_id', $id ); |
131 | 132 | } |
132 | 133 | |
— | — | @@ -135,78 +136,78 @@ |
136 | 137 | } |
137 | 138 | |
138 | 139 | /** |
139 | | - * Horrible, horrible! |
140 | | - * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. |
141 | | - * Returned as an array of months in the format yyyymm |
142 | | - */ |
| 140 | + * Horrible, horrible! |
| 141 | + * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. |
| 142 | + * Returned as an array of months in the format yyyymm |
| 143 | + */ |
143 | 144 | static function monthsWhereArticleHasThreads( $article ) { |
144 | 145 | // FIXME this probably performs absolutely horribly for pages with lots of threads. |
145 | | - |
| 146 | + |
146 | 147 | $threads = Threads::where( Threads::articleClause( $article ) ); |
147 | 148 | $months = array(); |
148 | | - |
| 149 | + |
149 | 150 | foreach ( $threads as $t ) { |
150 | 151 | $month = substr( $t->modified(), 0, 6 ); |
151 | | - |
| 152 | + |
152 | 153 | $months[$month] = true; |
153 | 154 | } |
154 | | - |
| 155 | + |
155 | 156 | // Some code seems to assume that it's sorted by month, make sure it's true. |
156 | 157 | ksort( $months ); |
157 | | - |
158 | | - return array_keys( $months ); |
| 158 | + |
| 159 | + return array_keys($months); |
159 | 160 | } |
160 | 161 | |
161 | 162 | static function articleClause( $article ) { |
162 | 163 | $dbr = wfGetDB( DB_SLAVE ); |
163 | | - |
| 164 | + |
164 | 165 | $arr = array( 'thread_article_title' => $article->getTitle()->getDBKey(), |
165 | 166 | 'thread_article_namespace' => $article->getTitle()->getNamespace() ); |
166 | | - |
| 167 | + |
167 | 168 | return $dbr->makeList( $arr, LIST_AND ); |
168 | 169 | } |
169 | 170 | |
170 | 171 | static function topLevelClause() { |
171 | 172 | $dbr = wfGetDB( DB_SLAVE ); |
172 | | - |
| 173 | + |
173 | 174 | $arr = array( 'thread_ancestor=thread_id', 'thread_parent' => null ); |
174 | | - |
| 175 | + |
175 | 176 | return $dbr->makeList( $arr, LIST_OR ); |
176 | 177 | } |
177 | | - |
| 178 | + |
178 | 179 | static function scratchTitle() { |
179 | 180 | $token = md5( uniqid( rand(), true ) ); |
180 | 181 | return Title::newFromText( "Thread:$token" ); |
181 | 182 | } |
182 | | - |
| 183 | + |
183 | 184 | static function newThreadTitle( $subject, $article ) { |
184 | 185 | wfLoadExtensionMessages( 'LiquidThreads' ); |
185 | 186 | $subject = $subject ? $subject : wfMsg( 'lqt_nosubject' ); |
186 | | - |
| 187 | + |
187 | 188 | $base = $article->getTitle()->getPrefixedText() . "/$subject"; |
188 | | - |
| 189 | + |
189 | 190 | return self::incrementedTitle( $base, NS_LQT_THREAD ); |
190 | 191 | } |
191 | | - |
| 192 | + |
192 | 193 | static function newSummaryTitle( $t ) { |
193 | 194 | return self::incrementedTitle( $t->title()->getText(), NS_LQT_SUMMARY ); |
194 | 195 | } |
195 | | - |
196 | | - static function newReplyTitle( $thread, $user ) { |
| 196 | + |
| 197 | + static function newReplyTitle( $thread, $user) { |
197 | 198 | $topThread = $thread->topmostThread(); |
198 | | - |
| 199 | + |
199 | 200 | $base = $topThread->title()->getText() . '/' . $user->getName(); |
200 | | - |
| 201 | + |
201 | 202 | return self::incrementedTitle( $base, NS_LQT_THREAD ); |
202 | 203 | } |
203 | | - |
| 204 | + |
204 | 205 | /** Keep trying titles starting with $basename until one is unoccupied. */ |
205 | 206 | public static function incrementedTitle( $basename, $namespace ) { |
206 | 207 | $i = 2; |
207 | | - |
| 208 | + |
208 | 209 | $replacements = array_fill_keys( array( '[', ']', '{', '}', '|' ), '_' ); |
209 | 210 | $basename = strtr( $basename, $replacements ); |
210 | | - |
| 211 | + |
211 | 212 | $t = Title::makeTitleSafe( $namespace, $basename ); |
212 | 213 | while ( !$t || $t->exists() || |
213 | 214 | in_array( $t->getPrefixedDBkey(), self::$occupied_titles ) ) { |
— | — | @@ -214,5 +215,5 @@ |
215 | 216 | $i++; |
216 | 217 | } |
217 | 218 | return $t; |
218 | | - } |
| 219 | + } |
219 | 220 | } |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -1,10 +1,11 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * @package MediaWiki |
5 | | - * @subpackage LiquidThreads |
6 | | - * @author David McCabe <davemccabe@gmail.com> |
7 | | - * @licence GPL2 |
8 | | - */ |
| 5 | +* @package MediaWiki |
| 6 | +* @subpackage LiquidThreads |
| 7 | +* @author David McCabe <davemccabe@gmail.com> |
| 8 | +* @licence GPL2 |
| 9 | +*/ |
9 | 10 | |
10 | 11 | if ( !defined( 'MEDIAWIKI' ) ) { |
11 | 12 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
— | — | @@ -24,7 +25,7 @@ |
25 | 26 | public $threadNestingLevel = 0; |
26 | 27 | |
27 | 28 | protected $sort_order = LQT_NEWEST_CHANGES; |
28 | | - |
| 29 | + |
29 | 30 | static $stylesAndScriptsDone = false; |
30 | 31 | |
31 | 32 | function __construct( &$output, &$article, &$title, &$user, &$request ) { |
— | — | @@ -41,10 +42,10 @@ |
42 | 43 | $this->headerLevel = $int; |
43 | 44 | } |
44 | 45 | |
45 | | - /** |
46 | | - * (1) linking to liquidthreads pages and |
47 | | - * (2) figuring out what page you're on and what you need to do. |
48 | | - */ |
| 46 | + /************************* |
| 47 | + * (1) linking to liquidthreads pages and |
| 48 | + * (2) figuring out what page you're on and what you need to do. |
| 49 | + *************************/ |
49 | 50 | |
50 | 51 | function methodAppliesToThread( $method, $thread ) { |
51 | 52 | return $this->request->getVal( 'lqt_method' ) == $method && |
— | — | @@ -56,65 +57,64 @@ |
57 | 58 | |
58 | 59 | static function permalinkUrl( $thread, $method = null, $operand = null, |
59 | 60 | $uquery = array() ) { |
60 | | - list ( $title, $query ) = self::permalinkData( $thread, $method, $operand ); |
61 | | - |
| 61 | + list ($title, $query) = self::permalinkData( $thread, $method, $operand ); |
| 62 | + |
62 | 63 | $query = array_merge( $query, $uquery ); |
63 | | - |
| 64 | + |
64 | 65 | $queryString = wfArrayToCGI( $query ); |
65 | | - |
| 66 | + |
66 | 67 | return $title->getFullUrl( $queryString ); |
67 | 68 | } |
68 | | - |
| 69 | + |
69 | 70 | /** Gets an array of (title, query-parameters) for a permalink **/ |
70 | 71 | static function permalinkData( $thread, $method = null, $operand = null ) { |
71 | 72 | $query = array(); |
72 | | - |
73 | | - if ( $method ) { |
| 73 | + |
| 74 | + if ($method) { |
74 | 75 | $query['lqt_method'] = $method; |
75 | 76 | } |
76 | | - if ( $operand ) { |
| 77 | + if ($operand) { |
77 | 78 | $query['lqt_operand'] = $operand; |
78 | 79 | } |
79 | | - |
| 80 | + |
80 | 81 | return array( $thread->root()->getTitle(), $query ); |
81 | 82 | } |
82 | 83 | |
83 | 84 | /* This is used for action=history so that the history tab works, which is |
84 | | - * why we break the lqt_method paradigm. |
85 | | - */ |
| 85 | + why we break the lqt_method paradigm. */ |
86 | 86 | static function permalinkUrlWithQuery( $thread, $query ) { |
87 | | - if ( !is_array( $query ) ) { |
| 87 | + if ( !is_array($query) ) { |
88 | 88 | $query = wfCGIToArray( $query ); |
89 | 89 | } |
90 | | - |
| 90 | + |
91 | 91 | return self::permalinkUrl( $thread, null, null, $query ); |
92 | 92 | } |
93 | | - |
| 93 | + |
94 | 94 | static function permalink( $thread, $text = null, $method = null, $operand = null, |
95 | 95 | $sk = null, $attribs = array(), $uquery = array() ) { |
96 | | - if ( is_null( $sk ) ) { |
| 96 | + if ( is_null($sk) ) { |
97 | 97 | global $wgUser; |
98 | 98 | $sk = $wgUser->getSkin(); |
99 | 99 | } |
100 | | - |
| 100 | + |
101 | 101 | list( $title, $query ) = self::permalinkData( $thread, $method, $operand ); |
102 | | - |
| 102 | + |
103 | 103 | $query = array_merge( $query, $uquery ); |
104 | | - |
| 104 | + |
105 | 105 | return $sk->link( $title, $text, $attribs, $query ); |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | static function diffQuery( $thread, $revision ) { |
109 | 109 | $changed_thread = $revision->getChangeObject(); |
110 | 110 | $curr_rev_id = $revision->getThreadObj()->rootRevision(); |
111 | 111 | $curr_rev = Revision::newFromId( $curr_rev_id ); |
112 | 112 | $prev_rev = $curr_rev->getPrevious(); |
113 | 113 | $oldid = $prev_rev ? $prev_rev->getId() : ""; |
114 | | - |
| 114 | + |
115 | 115 | $query = array( 'lqt_method' => 'diff', |
116 | 116 | 'diff' => $curr_rev_id, |
117 | 117 | 'oldid' => $oldid ); |
118 | | - |
| 118 | + |
119 | 119 | return $query; |
120 | 120 | } |
121 | 121 | |
— | — | @@ -122,49 +122,49 @@ |
123 | 123 | $query = self::diffQuery( $thread ); |
124 | 124 | return self::permalinkUrl( $thread->changeObject(), null, null, $query ); |
125 | 125 | } |
126 | | - |
| 126 | + |
127 | 127 | static function diffPermalink( $thread, $text, $revision ) { |
128 | 128 | $query = self::diffQuery( $thread, $revision ); |
129 | 129 | return self::permalink( $thread, $text, null, null, null, array(), $query ); |
130 | 130 | } |
131 | | - |
132 | | - static function talkpageLink( $title, $text = null , $method = null, $operand = null, |
133 | | - $includeFragment = true, $attribs = array(), |
| 131 | + |
| 132 | + static function talkpageLink( $title, $text = null , $method=null, $operand=null, |
| 133 | + $includeFragment=true, $attribs = array(), |
134 | 134 | $options = array() ) { |
135 | 135 | list( $title, $query ) = self::talkpageLinkData( $title, $method, $operand, |
136 | 136 | $includeFragment ); |
137 | | - |
| 137 | + |
138 | 138 | global $wgUser; |
139 | 139 | $sk = $wgUser->getSkin(); |
140 | | - |
| 140 | + |
141 | 141 | return $sk->link( $title, $text, $attribs, $query, $options ); |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | static function talkpageLinkData( $title, $method = null, $operand = null, |
145 | 145 | $includeFragment = true ) { |
146 | 146 | global $wgRequest; |
147 | 147 | $query = array(); |
148 | | - |
149 | | - if ( $method ) { |
| 148 | + |
| 149 | + if ($method) { |
150 | 150 | $query['lqt_method'] = $method; |
151 | 151 | } |
152 | | - |
153 | | - if ( $operand ) { |
| 152 | + |
| 153 | + if ($operand) { |
154 | 154 | $query['lqt_operand'] = $operand->id(); |
155 | 155 | } |
156 | | - |
| 156 | + |
157 | 157 | $oldid = $wgRequest->getVal( 'oldid', null ); |
158 | | - |
| 158 | + |
159 | 159 | if ( $oldid !== null ) { |
160 | 160 | // this is an immensely ugly hack to make editing old revisions work. |
161 | 161 | $query['oldid'] = $oldid; |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | // Add fragment if appropriate. |
165 | | - if ( $operand && $includeFragment ) { |
166 | | - $title->mFragment = 'lqt_thread_' . $operand->id(); |
| 165 | + if ($operand && $includeFragment) { |
| 166 | + $title->mFragment = 'lqt_thread_'.$operand->id(); |
167 | 167 | } |
168 | | - |
| 168 | + |
169 | 169 | return array( $title, $query ); |
170 | 170 | } |
171 | 171 | |
— | — | @@ -172,40 +172,40 @@ |
173 | 173 | $includeFragment = true ) { |
174 | 174 | global $wgUser; |
175 | 175 | $sk = $wgUser->getSkin(); |
176 | | - |
| 176 | + |
177 | 177 | list( $title, $query ) = |
178 | 178 | self::talkpageLinkData( $title, $method, $operand, $includeFragment ); |
179 | | - |
| 179 | + |
180 | 180 | return $title->getLinkUrl( $query ); |
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | /** |
185 | | - * Return a URL for the current page, including Title and query vars, |
| 185 | + * Return a URL for the current page, including Title and query vars, |
186 | 186 | * with the given replacements made. |
187 | | - * @param $repls array( 'name'=>new_value, ... ) |
188 | | - */ |
| 187 | + * @param $repls array( 'name'=>new_value, ... ) |
| 188 | + */ |
189 | 189 | function queryReplaceLink( $repls ) { |
190 | 190 | $query = $this->getReplacedQuery( $repls ); |
191 | | - |
| 191 | + |
192 | 192 | return $this->title->getFullURL( wfArrayToCGI( $vs ) ); |
193 | 193 | } |
194 | | - |
| 194 | + |
195 | 195 | function getReplacedQuery( $replacements ) { |
196 | 196 | $values = $this->request->getValues(); |
197 | | - |
| 197 | + |
198 | 198 | foreach ( $replacements as $k => $v ) { |
199 | 199 | $values[$k] = $v; |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | return $values; |
203 | 203 | } |
204 | 204 | |
205 | | - /** |
206 | | - * Editing methods (here be dragons) |
207 | | - * Forget dragons: This section distorts the rest of the code |
208 | | - * like a star bending spacetime around itself. |
209 | | - */ |
| 205 | + /************************************************************* |
| 206 | + * Editing methods (here be dragons) * |
| 207 | + * Forget dragons: This section distorts the rest of the code * |
| 208 | + * like a star bending spacetime around itself. * |
| 209 | + *************************************************************/ |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Return an HTML form element whose value is gotten from the request. |
— | — | @@ -246,37 +246,37 @@ |
247 | 247 | $this->output->addWikiMsg( 'lqt-summarize-intro' ); |
248 | 248 | $this->showEditingFormInGeneral( $thread, 'summarize', $thread ); |
249 | 249 | } |
250 | | - |
| 250 | + |
251 | 251 | function doInlineEditForm() { |
252 | 252 | $method = $this->request->getVal( 'lqt_method' ); |
253 | 253 | $operand = $this->request->getVal( 'lqt_operand' ); |
254 | | - |
255 | | - $thread = Threads::withId( intval( $operand ) ); |
256 | | - |
257 | | - if ( $method == 'reply' ) { |
| 254 | + |
| 255 | + $thread = Threads::withId( intval($operand) ); |
| 256 | + |
| 257 | + if ($method == 'reply') { |
258 | 258 | $this->showReplyForm( $thread ); |
259 | | - } elseif ( $method == 'talkpage_new_thread' ) { |
| 259 | + } elseif ($method == 'talkpage_new_thread') { |
260 | 260 | $this->showNewThreadForm(); |
261 | 261 | } |
262 | | - |
| 262 | + |
263 | 263 | $this->output->setArticleBodyOnly( true ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) { |
267 | 267 | /* |
268 | | - * EditPage needs an Article. If there isn't a real one, as for new posts, |
269 | | - * replies, and new summaries, we need to generate a title. Auto-generated |
270 | | - * titles are based on the subject line. If the subject line is blank, we |
271 | | - * can temporarily use a random scratch title. It's fine if the title changes |
272 | | - * throughout the edit cycle, since the article doesn't exist yet anyways. |
273 | | - */ |
| 268 | + EditPage needs an Article. If there isn't a real one, as for new posts, |
| 269 | + replies, and new summaries, we need to generate a title. Auto-generated |
| 270 | + titles are based on the subject line. If the subject line is blank, we |
| 271 | + can temporarily use a random scratch title. It's fine if the title changes |
| 272 | + throughout the edit cycle, since the article doesn't exist yet anyways. |
| 273 | + */ |
274 | 274 | |
275 | | - // Stuff that might break the save |
| 275 | + // Stuff that might break the save |
276 | 276 | $valid_subject = true; |
277 | 277 | $failed_rename = false; |
278 | | - |
| 278 | + |
279 | 279 | $subject = $this->request->getVal( 'lqt_subject_field', '' ); |
280 | | - |
| 280 | + |
281 | 281 | if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) { |
282 | 282 | $article = $edit_applies_to->summary(); |
283 | 283 | } elseif ( $edit_type == 'summarize' ) { |
— | — | @@ -287,7 +287,7 @@ |
288 | 288 | // Dodgy title |
289 | 289 | $valid_subject = false; |
290 | 290 | $t = $this->scratchTitle(); |
291 | | - } else { |
| 291 | + } else { |
292 | 292 | if ( $edit_type == 'new' ) { |
293 | 293 | $t = $this->newScratchTitle( $subject ); |
294 | 294 | } elseif ( $edit_type == 'reply' ) { |
— | — | @@ -300,16 +300,16 @@ |
301 | 301 | } |
302 | 302 | |
303 | 303 | $e = new EditPage( $article ); |
304 | | - |
305 | | - |
| 304 | + |
| 305 | + |
306 | 306 | // Find errors. |
307 | | - if ( !$valid_subject && $subject ) { |
308 | | - $e->editFormPageTop .= |
| 307 | + if (!$valid_subject && $subject) { |
| 308 | + $e->editFormPageTop .= |
309 | 309 | Xml::tags( 'div', array( 'class' => 'error' ), |
310 | 310 | wfMsgExt( 'lqt_invalid_subject', 'parse' ) ); |
311 | 311 | } |
312 | | - |
313 | | - if ( ( !$valid_subject && $subject ) || $failed_rename ) { |
| 312 | + |
| 313 | + if ( (!$valid_subject && $subject) || $failed_rename ) { |
314 | 314 | // Dirty hack to prevent saving from going ahead |
315 | 315 | global $wgRequest; |
316 | 316 | $wgRequest->setVal( 'wpPreview', true ); |
— | — | @@ -320,20 +320,20 @@ |
321 | 321 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
322 | 322 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
323 | 323 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ); |
324 | | - |
| 324 | + |
325 | 325 | // Add a one-time random string to a hidden field. Store the random string |
326 | 326 | // in memcached on submit and don't allow the edit to go ahead if it's already |
327 | 327 | // been added. |
328 | 328 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
329 | | - if ( $submitted_nonce ) { |
| 329 | + if ($submitted_nonce) { |
330 | 330 | global $wgMemc; |
331 | | - |
| 331 | + |
332 | 332 | $key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
333 | | - if ( $wgMemc->get( $key ) ) { |
| 333 | + if ( $wgMemc->get($key) ) { |
334 | 334 | $this->output->redirect( $this->article->getTitle()->getFullURL() ); |
335 | 335 | return; |
336 | 336 | } |
337 | | - |
| 337 | + |
338 | 338 | $wgMemc->set( $key, 1, 3600 ); |
339 | 339 | } |
340 | 340 | |
— | — | @@ -343,9 +343,9 @@ |
344 | 344 | $db_subject = $thread ? $thread->subjectWithoutIncrement() : ''; |
345 | 345 | $subject = $this->request->getVal( 'lqt_subject_field', $db_subject ); |
346 | 346 | $subject_label = wfMsg( 'lqt_subject' ); |
347 | | - |
| 347 | + |
348 | 348 | $attr = array( 'tabindex' => 1 ); |
349 | | - |
| 349 | + |
350 | 350 | $e->editFormTextBeforeContent .= |
351 | 351 | Xml::inputLabel( $subject_label, 'lqt_subject_field', 'lqt_subject_field', |
352 | 352 | 60, $subject, $attr ) . Xml::element( 'br' ); |
— | — | @@ -354,8 +354,9 @@ |
355 | 355 | $e->edit(); |
356 | 356 | |
357 | 357 | // Override what happens in EditPage::showEditForm, called from $e->edit(): |
358 | | - $this->output->setArticleFlag( false ); |
359 | 358 | |
| 359 | + $this->output->setArticleFlag( false ); |
| 360 | + |
360 | 361 | if ( $e->didSave ) { |
361 | 362 | $thread = self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article, |
362 | 363 | $subject, $e->summary, $thread ); |
— | — | @@ -366,24 +367,24 @@ |
367 | 368 | // so $thread is null. In that case, just allow editpage to redirect back to the talk page. |
368 | 369 | if ( $this->output->getRedirect() != '' && $thread ) { |
369 | 370 | $redirectTitle = clone $thread->article()->getTitle(); |
370 | | - $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
| 371 | + $redirectTitle->setFragment( '#'.$this->anchorName( $thread ) ); |
371 | 372 | $this->output->redirect( $this->title->getFullURL() ); |
372 | 373 | } else if ( $this->output->getRedirect() != '' && $edit_applies_to ) { |
373 | 374 | // For summaries: |
374 | 375 | $redirectTitle = clone $edit_applies_to->article()->getTitle(); |
375 | | - $redirectTitle->setFragment( '#' . $this->anchorName( $edit_applies_to ) ); |
| 376 | + $redirectTitle->setFragment( '#'.$this->anchorName( $edit_applies_to ) ); |
376 | 377 | $this->output->redirect( $redirectTitle->getFullURL() ); |
377 | 378 | } |
378 | 379 | } |
379 | | - |
380 | | - static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article, |
| 380 | + |
| 381 | + static function postEditUpdates($edit_type, $edit_applies_to, $edit_page, $article, |
381 | 382 | $subject, $edit_summary, $thread ) { |
382 | 383 | // Update metadata - create and update thread and thread revision objects as |
383 | 384 | // appropriate. |
384 | | - |
| 385 | + |
385 | 386 | if ( $edit_type == 'reply' ) { |
386 | 387 | $subject = $edit_applies_to->subject(); |
387 | | - |
| 388 | + |
388 | 389 | $thread = Threads::newThread( $edit_page, $article, $edit_applies_to, |
389 | 390 | Threads::TYPE_NORMAL, $subject ); |
390 | 391 | } elseif ( $edit_type == 'summarize' ) { |
— | — | @@ -394,25 +395,25 @@ |
395 | 396 | // Move the thread and replies if subject changed. |
396 | 397 | if ( $subject && $subject != $thread->subjectWithoutIncrement() ) { |
397 | 398 | $thread->setSubject( $subject ); |
398 | | - |
| 399 | + |
399 | 400 | // Disabled page-moving for now. |
400 | 401 | // $this->renameThread( $thread, $subject, $e->summary ); |
401 | 402 | } |
402 | | - |
| 403 | + |
403 | 404 | // Add the history entry. |
404 | 405 | $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $edit_summary ); |
405 | 406 | } else { |
406 | 407 | $thread = Threads::newThread( $edit_page, $article, null, |
407 | 408 | Threads::TYPE_NORMAL, $subject ); |
408 | 409 | } |
409 | | - |
| 410 | + |
410 | 411 | return $thread; |
411 | 412 | } |
412 | 413 | |
413 | 414 | function renameThread( $t, $s, $reason ) { |
414 | 415 | $this->simplePageMove( $t->root()->getTitle(), $s, $reason ); |
415 | 416 | // TODO here create a redirect from old page to new. |
416 | | - |
| 417 | + |
417 | 418 | foreach ( $t->subthreads() as $st ) { |
418 | 419 | $this->renameThread( $st, $s, $reason ); |
419 | 420 | } |
— | — | @@ -421,15 +422,15 @@ |
422 | 423 | function scratchTitle() { |
423 | 424 | return Threads::scratchTitle(); |
424 | 425 | } |
425 | | - |
| 426 | + |
426 | 427 | function newScratchTitle( $subject ) { |
427 | 428 | return Threads::newThreadTitle( $subject, $this->article ); |
428 | 429 | } |
429 | | - |
| 430 | + |
430 | 431 | function newSummaryTitle( $thread ) { |
431 | 432 | return Threads::newSummaryTitle( $thread ); |
432 | 433 | } |
433 | | - |
| 434 | + |
434 | 435 | function newReplyTitle( $unused, $thread ) { |
435 | 436 | return Threads::newReplyTitle( $thread, $this->user ); |
436 | 437 | } |
— | — | @@ -489,77 +490,77 @@ |
490 | 491 | 'enabled' => true ); |
491 | 492 | |
492 | 493 | if ( $this->user->isAllowed( 'delete' ) ) { |
493 | | - $delete_url = $thread->title()->getFullURL( 'action=delete' ); |
| 494 | + $delete_url = $thread->title()->getFullURL( 'action=delete'); |
494 | 495 | $deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete'; |
495 | | - |
| 496 | + |
496 | 497 | $commands['delete'] = array( 'label' => wfMsgExt( $deleteMsg, 'parseinline' ), |
497 | 498 | 'href' => $delete_url, |
498 | 499 | 'enabled' => true ); |
499 | 500 | } |
500 | | - |
| 501 | + |
501 | 502 | if ( !$thread->isTopmostThread() && $this->user->isAllowed( 'lqt-split' ) ) { |
502 | 503 | $splitUrl = SpecialPage::getTitleFor( 'SplitThread', |
503 | 504 | $thread->title()->getPrefixedText() )->getFullURL(); |
504 | 505 | $commands['split'] = array( 'label' => wfMsgExt( 'lqt-thread-split', 'parseinline' ), |
505 | 506 | 'href' => $splitUrl, 'enabled' => true ); |
506 | 507 | } |
507 | | - |
| 508 | + |
508 | 509 | if ( $this->user->isAllowed( 'lqt-merge' ) ) { |
509 | 510 | $mergeParams = $_GET; |
510 | 511 | $mergeParams['lqt_merge_from'] = $thread->id(); |
511 | | - |
512 | | - unset( $mergeParams['title'] ); |
513 | | - |
| 512 | + |
| 513 | + unset($mergeParams['title']); |
| 514 | + |
514 | 515 | $mergeUrl = $this->title->getFullURL( wfArrayToCGI( $mergeParams ) ); |
515 | 516 | $label = wfMsgExt( 'lqt-thread-merge', 'parseinline' ); |
516 | | - |
| 517 | + |
517 | 518 | $commands['merge'] = array( 'label' => $label, |
518 | 519 | 'href' => $mergeUrl, 'enabled' => true ); |
519 | 520 | } |
520 | 521 | |
521 | 522 | return $commands; |
522 | 523 | } |
523 | | - |
| 524 | + |
524 | 525 | // Commands for the bottom. |
525 | 526 | function threadMajorCommands( $thread ) { |
526 | 527 | wfLoadExtensionMessages( 'LiquidThreads' ); |
527 | | - |
528 | | - if ( $thread->isHistorical() ) { |
| 528 | + |
| 529 | + if ($thread->isHistorical() ) { |
529 | 530 | // No links for historical threads. |
530 | 531 | return array(); |
531 | 532 | } |
532 | | - |
| 533 | + |
533 | 534 | $commands = array(); |
534 | | - |
| 535 | + |
535 | 536 | if ( $this->user->isAllowed( 'lqt-merge' ) && |
536 | 537 | $this->request->getCheck( 'lqt_merge_from' ) ) { |
537 | 538 | $srcThread = Threads::withId( $this->request->getVal( 'lqt_merge_from' ) ); |
538 | 539 | $par = $srcThread->title()->getPrefixedText(); |
539 | 540 | $mergeTitle = SpecialPage::getTitleFor( 'MergeThread', $par ); |
540 | | - $mergeUrl = $mergeTitle->getFullURL( 'dest=' . $thread->id() ); |
| 541 | + $mergeUrl = $mergeTitle->getFullURL( 'dest='.$thread->id() ); |
541 | 542 | $label = wfMsgExt( 'lqt-thread-merge-to', 'parseinline' ); |
542 | | - |
| 543 | + |
543 | 544 | $commands['merge-to'] = array( 'label' => $label, 'href' => $mergeUrl, |
544 | 545 | 'enabled' => true, 'tooltip' => $label ); |
545 | 546 | } |
546 | | - |
| 547 | + |
547 | 548 | $commands['reply'] = array( 'label' => wfMsgExt( 'lqt_reply', 'parseinline' ), |
548 | 549 | 'href' => $this->talkpageUrl( $this->title, 'reply', $thread ), |
549 | 550 | 'enabled' => true, 'icon' => 'reply.png', 'showlabel' => 1, |
550 | 551 | 'tooltip' => wfMsg( 'lqt_reply' ) ); |
551 | | - |
| 552 | + |
552 | 553 | $commands['link'] = array( 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ), |
553 | 554 | 'href' => $thread->title()->getFullURL(), |
554 | 555 | 'enabled' => true, 'icon' => 'link.png', |
555 | 556 | 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' ) ); |
556 | | - |
| 557 | + |
557 | 558 | if ( $thread->root()->getTitle()->quickUserCan( 'edit' ) ) { |
558 | 559 | $commands['edit'] = array( 'label' => wfMsgExt( 'edit', 'parseinline' ), |
559 | 560 | 'href' => $this->talkpageUrl( $this->title, 'edit', $thread ), |
560 | 561 | 'enabled' => true, 'icon' => 'edit.png', |
561 | 562 | 'tooltip' => wfMsgExt( 'edit', 'parseinline' ) ); |
562 | 563 | } |
563 | | - |
| 564 | + |
564 | 565 | return $commands; |
565 | 566 | } |
566 | 567 | |
— | — | @@ -567,41 +568,33 @@ |
568 | 569 | wfLoadExtensionMessages( 'LiquidThreads' ); |
569 | 570 | $commands = array(); |
570 | 571 | |
571 | | - $commands['history'] = array( |
572 | | - 'label' => wfMsg( 'history_short' ), |
573 | | - 'href' => self::permalinkUrl( $thread, 'thread_history' ), |
574 | | - 'enabled' => true |
575 | | - ); |
| 572 | + $commands['history'] = array( 'label' => wfMsg( 'history_short' ), |
| 573 | + 'href' => self::permalinkUrl( $thread, 'thread_history' ), |
| 574 | + 'enabled' => true ); |
576 | 575 | |
577 | 576 | if ( in_array( 'move', $this->user->getRights() ) ) { |
578 | 577 | $move_href = SpecialPage::getTitleFor( 'MoveThread' )->getFullURL() |
579 | 578 | . '/' . $thread->title()->getPrefixedURL(); |
580 | | - $commands['move'] = array( |
581 | | - 'label' => wfMsg( 'move' ), |
582 | | - 'href' => $move_href, |
583 | | - 'enabled' => true |
584 | | - ); |
| 579 | + $commands['move'] = array( 'label' => wfMsg( 'move' ), |
| 580 | + 'href' => $move_href, |
| 581 | + 'enabled' => true ); |
585 | 582 | } |
586 | 583 | if ( !$this->user->isAnon() && !$thread->title()->userIsWatching() ) { |
587 | | - $commands['watch'] = array( |
588 | | - 'label' => wfMsg( 'watch' ), |
589 | | - 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ), |
590 | | - 'enabled' => true |
591 | | - ); |
| 584 | + $commands['watch'] = array( 'label' => wfMsg( 'watch' ), |
| 585 | + 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ), |
| 586 | + 'enabled' => true ); |
592 | 587 | } else if ( !$this->user->isAnon() ) { |
593 | | - $commands['unwatch'] = array( |
594 | | - 'label' => wfMsg( 'unwatch' ), |
595 | | - 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ), |
596 | | - 'enabled' => true |
597 | | - ); |
| 588 | + $commands['unwatch'] = array( 'label' => wfMsg( 'unwatch' ), |
| 589 | + 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ), |
| 590 | + 'enabled' => true ); |
598 | 591 | } |
599 | | - |
| 592 | + |
600 | 593 | $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() ); |
601 | 594 | $commands['summarize'] = array( |
602 | | - 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ), |
603 | | - 'href' => $summarizeUrl, |
604 | | - 'enabled' => true, |
605 | | - ); |
| 595 | + 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ), |
| 596 | + 'href' => $summarizeUrl, |
| 597 | + 'enabled' => true, |
| 598 | + ); |
606 | 599 | |
607 | 600 | return $commands; |
608 | 601 | } |
— | — | @@ -613,38 +606,38 @@ |
614 | 607 | static function addJSandCSS() { |
615 | 608 | // Changed this to be static so that we can call it from |
616 | 609 | // wfLqtBeforeWatchlistHook. |
617 | | - |
| 610 | + |
618 | 611 | if ( self::$stylesAndScriptsDone ) { |
619 | 612 | return; |
620 | 613 | } |
621 | | - |
| 614 | + |
622 | 615 | global $wgOut; |
623 | 616 | global $wgScriptPath, $wgStyleVersion; |
624 | 617 | global $wgEnableJS2system; |
625 | 618 | |
626 | 619 | $wgOut->addInlineScript( 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';' ); |
627 | | - |
628 | | - if ( !$wgEnableJS2system ) { |
| 620 | + |
| 621 | + if (!$wgEnableJS2system) { |
629 | 622 | $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/js2.combined.js" ); |
630 | 623 | } |
631 | | - |
| 624 | + |
632 | 625 | $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/lqt.js" ); |
633 | 626 | $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/LiquidThreads/lqt.css?{$wgStyleVersion}" ); |
634 | | - |
| 627 | + |
635 | 628 | self::$stylesAndScriptsDone = true; |
636 | 629 | } |
637 | | - |
| 630 | + |
638 | 631 | static function exportJSLocalisation() { |
639 | 632 | wfLoadExtensionMessages( 'LiquidThreads' ); |
640 | | - |
| 633 | + |
641 | 634 | $messages = array( 'lqt-quote-intro', 'lqt-quote', 'lqt-ajax-updated', |
642 | 635 | 'lqt-ajax-update-link' ); |
643 | 636 | $data = array(); |
644 | | - |
645 | | - foreach ( $messages as $msg ) { |
| 637 | + |
| 638 | + foreach( $messages as $msg ) { |
646 | 639 | $data[$msg] = wfMsgNoTrans( $msg ); |
647 | 640 | } |
648 | | - |
| 641 | + |
649 | 642 | return json_encode( $data ); |
650 | 643 | } |
651 | 644 | |
— | — | @@ -654,83 +647,65 @@ |
655 | 648 | * $post->getParserOutput. */ |
656 | 649 | function showPostBody( $post, $oldid = null ) { |
657 | 650 | global $wgOut; |
658 | | - |
| 651 | + |
659 | 652 | // Load compatibility layer for older versions |
660 | | - if ( !( $post instanceof Article_LQT_Compat ) ) { |
| 653 | + if ( !($post instanceof Article_LQT_Compat) ) { |
661 | 654 | wfWarn( "No article compatibility layer loaded, inefficiently duplicating information." ); |
662 | 655 | $post = new Article_LQT_Compat( $post->getTitle() ); |
663 | 656 | } |
664 | | - |
| 657 | + |
665 | 658 | $parserOutput = $post->getParserOutput( $oldid ); |
666 | 659 | $wgOut->addParserOutputNoText( $parserOutput ); |
667 | | - |
| 660 | + |
668 | 661 | return $parserOutput->getText(); |
669 | 662 | } |
670 | | - |
| 663 | + |
671 | 664 | function showThreadToolbar( $thread ) { |
672 | 665 | global $wgLang; |
673 | | - |
| 666 | + |
674 | 667 | $sk = $this->user->getSkin(); |
675 | 668 | $html = ''; |
676 | 669 | |
677 | 670 | $headerParts = array(); |
678 | | - |
679 | | - foreach ( $this->threadMajorCommands( $thread ) as $key => $cmd ) { |
| 671 | + |
| 672 | + foreach( $this->threadMajorCommands( $thread ) as $key => $cmd ) { |
680 | 673 | $content = $this->contentForCommand( $cmd, false /* No icon divs */ ); |
681 | | - $headerParts[] = Xml::tags( |
682 | | - 'li', |
683 | | - array( 'class' => "lqt-command lqt-command-$key" ), |
684 | | - $content |
685 | | - ); |
| 674 | + $headerParts[] = Xml::tags( 'li', |
| 675 | + array( 'class' => "lqt-command lqt-command-$key" ), |
| 676 | + $content ); |
686 | 677 | } |
687 | | - |
| 678 | + |
688 | 679 | // Drop-down menu |
689 | 680 | $commands = $this->threadCommands( $thread ); |
690 | | - $menuHTML = Xml::tags( |
691 | | - 'ul', |
692 | | - array( 'class' => 'lqt-thread-toolbar-command-list' ), |
693 | | - $this->listItemsForCommands( $commands ) |
694 | | - ); |
695 | | - |
696 | | - $triggerText = Xml::tags( |
697 | | - 'span', |
698 | | - array( 'class' => 'lqt-thread-actions-icon' ), |
699 | | - ' ' |
700 | | - ); |
701 | | - $dropDownTrigger = Xml::tags( |
702 | | - 'div', |
703 | | - array( |
704 | | - 'class' => 'lqt-thread-actions-trigger ' . |
705 | | - 'lqt-command-icon', 'style' => 'display: none;' |
706 | | - ), |
707 | | - $triggerText |
708 | | - ); |
709 | | - $headerParts[] = Xml::tags( |
710 | | - 'li', |
711 | | - array( 'class' => 'lqt-thread-toolbar-menu' ), |
712 | | - $dropDownTrigger |
713 | | - ); |
714 | | - |
| 681 | + $menuHTML = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-command-list'), |
| 682 | + $this->listItemsForCommands( $commands ) ); |
| 683 | + |
| 684 | + $triggerText = Xml::tags( 'span', array('class' => 'lqt-thread-actions-icon'), |
| 685 | + ' '); |
| 686 | + $dropDownTrigger = Xml::tags( 'div', |
| 687 | + array( 'class' => 'lqt-thread-actions-trigger '. |
| 688 | + 'lqt-command-icon', 'style' => 'display: none;'), |
| 689 | + $triggerText ); |
| 690 | + $headerParts[] = Xml::tags( 'li', |
| 691 | + array( 'class' => 'lqt-thread-toolbar-menu' ), |
| 692 | + $dropDownTrigger ); |
| 693 | + |
715 | 694 | $html .= implode( ' ', $headerParts ); |
716 | | - |
| 695 | + |
717 | 696 | $html = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-commands' ), $html ); |
718 | 697 | $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0;' ), ' ' ); |
719 | | - |
| 698 | + |
720 | 699 | // Box stuff |
721 | | - $boxElements = array( |
722 | | - 'lqt-thread-toolbar-box-tl', |
723 | | - 'lqt-thread-toolbar-box-tr', |
724 | | - 'lqt-thread-toolbar-box-br', |
725 | | - 'lqt-thread-toolbar-box-bl' |
726 | | - ); |
727 | | - foreach ( $boxElements as $class ) { |
| 700 | + $boxElements = array( 'lqt-thread-toolbar-box-tl', 'lqt-thread-toolbar-box-tr', |
| 701 | + 'lqt-thread-toolbar-box-br', 'lqt-thread-toolbar-box-bl' ); |
| 702 | + foreach( $boxElements as $class ) { |
728 | 703 | $html = Xml::openElement( 'div', array( 'class' => $class ) ) . $html . |
729 | 704 | Xml::closeElement( 'div' ); |
730 | 705 | } |
731 | | - |
| 706 | + |
732 | 707 | $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-toolbar' ), $html ) . |
733 | 708 | $menuHTML; |
734 | | - |
| 709 | + |
735 | 710 | return $html; |
736 | 711 | } |
737 | 712 | |
— | — | @@ -738,72 +713,55 @@ |
739 | 714 | $result = array(); |
740 | 715 | foreach ( $commands as $key => $command ) { |
741 | 716 | $thisCommand = $this->contentForCommand( $command ); |
742 | | - |
743 | | - $thisCommand = Xml::tags( |
744 | | - 'li', |
745 | | - array( 'class' => 'lqt-command lqt-command-' . $key ), |
746 | | - $thisCommand |
747 | | - ); |
748 | | - |
| 717 | + |
| 718 | + $thisCommand = Xml::tags( 'li', |
| 719 | + array( 'class' => 'lqt-command lqt-command-'.$key ), |
| 720 | + $thisCommand ); |
| 721 | + |
749 | 722 | $result[] = $thisCommand; |
750 | 723 | } |
751 | 724 | return join( ' ', $result ); |
752 | 725 | } |
753 | | - |
| 726 | + |
754 | 727 | function contentForCommand( $command, $icon_divs = true ) { |
755 | 728 | $label = $command['label']; |
756 | 729 | $href = $command['href']; |
757 | 730 | $enabled = $command['enabled']; |
758 | | - $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : ''; |
759 | | - |
| 731 | + $tooltip = isset($command['tooltip']) ? $command['tooltip'] : ''; |
| 732 | + |
760 | 733 | if ( isset( $command['icon'] ) ) { |
761 | 734 | global $wgScriptPath; |
762 | | - $icon = Xml::tags( |
763 | | - 'div', |
764 | | - array( |
765 | | - 'title' => $label, |
766 | | - 'class' => 'lqt-command-icon' |
767 | | - ), |
768 | | - ' ' |
769 | | - ); |
770 | | - if ( $icon_divs ) { |
771 | | - if ( !empty( $command['showlabel'] ) ) { |
772 | | - $label = $icon . ' ' . $label; |
| 735 | + $icon = Xml::tags( 'div', array( 'title' => $label, |
| 736 | + 'class' => 'lqt-command-icon' ), ' ' ); |
| 737 | + if ($icon_divs) { |
| 738 | + if ( !empty($command['showlabel']) ) { |
| 739 | + $label = $icon.' '.$label; |
773 | 740 | } else { |
774 | 741 | $label = $icon; |
775 | 742 | } |
776 | 743 | } else { |
777 | | - if ( empty( $command['showlabel'] ) ) { |
| 744 | + if ( empty($command['showlabel']) ) { |
778 | 745 | $label = ''; |
779 | 746 | } |
780 | 747 | } |
781 | 748 | } |
782 | | - |
| 749 | + |
783 | 750 | $thisCommand = ''; |
784 | | - |
| 751 | + |
785 | 752 | if ( $enabled ) { |
786 | | - $thisCommand = Xml::tags( |
787 | | - 'a', |
788 | | - array( 'href' => $href, 'title' => $tooltip ), |
789 | | - $label |
790 | | - ); |
| 753 | + $thisCommand = Xml::tags( 'a', array( 'href' => $href, 'title' => $tooltip ), |
| 754 | + $label ); |
791 | 755 | } else { |
792 | | - $thisCommand = Xml::tags( |
793 | | - 'span', |
794 | | - array( |
795 | | - 'class' => 'lqt_command_disabled', |
796 | | - 'title' => $tooltip |
797 | | - ), |
798 | | - $label |
799 | | - ); |
| 756 | + $thisCommand = Xml::tags( 'span', array( 'class' => 'lqt_command_disabled', |
| 757 | + 'title' => $tooltip), $label ); |
800 | 758 | } |
801 | | - |
| 759 | + |
802 | 760 | return $thisCommand; |
803 | 761 | } |
804 | 762 | |
805 | 763 | /** Shows a normal (i.e. not deleted or moved) thread body */ |
806 | 764 | function showThreadBody( $thread ) { |
807 | | - |
| 765 | + |
808 | 766 | // Remove 'editsection', it won't work. |
809 | 767 | $popts = $this->output->parserOptions(); |
810 | 768 | $previous_editsection = $popts->getEditSection(); |
— | — | @@ -811,7 +769,7 @@ |
812 | 770 | $this->output->parserOptions( $popts ); |
813 | 771 | |
814 | 772 | $post = $thread->root(); |
815 | | - |
| 773 | + |
816 | 774 | $divClass = $this->postDivClass( $thread ); |
817 | 775 | $html = ''; |
818 | 776 | |
— | — | @@ -831,7 +789,7 @@ |
832 | 790 | $html = Xml::openElement( 'div', array( 'class' => $divClass ) ); |
833 | 791 | $this->output->addHTML( $html ); |
834 | 792 | $html = ''; |
835 | | - |
| 793 | + |
836 | 794 | // No way am I refactoring EditForm to send its output as HTML. |
837 | 795 | // so I'm just flushing the HTML and displaying it as-is. |
838 | 796 | $this->showPostEditingForm( $thread ); |
— | — | @@ -842,8 +800,8 @@ |
843 | 801 | $html .= $this->showPostBody( $post, $oldid ); |
844 | 802 | $html .= Xml::closeElement( 'div' ); |
845 | 803 | $html .= $this->threadSignature( $thread ); |
846 | | - } |
847 | | - |
| 804 | + } |
| 805 | + |
848 | 806 | // If we're replying to this thread, show the reply form after it. |
849 | 807 | if ( $this->methodAppliesToThread( 'reply', $thread ) ) { |
850 | 808 | // As with above, flush HTML to avoid refactoring EditPage. |
— | — | @@ -851,69 +809,60 @@ |
852 | 810 | $this->showReplyForm( $thread ); |
853 | 811 | $html = ''; |
854 | 812 | } else { |
855 | | - $html .= Xml::tags( |
856 | | - 'div', |
857 | | - array( |
858 | | - 'class' => 'lqt-reply-form lqt-edit-form', |
859 | | - 'style' => 'display: none;' |
860 | | - ), |
861 | | - '' |
862 | | - ); |
| 813 | + $html .= Xml::tags( 'div', |
| 814 | + array( 'class' => 'lqt-reply-form lqt-edit-form', |
| 815 | + 'style' => 'display: none;' ), |
| 816 | + '' ); |
863 | 817 | } |
864 | | - |
| 818 | + |
865 | 819 | $this->output->addHTML( $html ); |
866 | 820 | |
867 | 821 | $popts->setEditSection( $previous_editsection ); |
868 | 822 | $this->output->parserOptions( $popts ); |
869 | 823 | } |
870 | | - |
| 824 | + |
871 | 825 | function threadSignature( $thread ) { |
872 | 826 | global $wgUser; |
873 | 827 | $sk = $wgUser->getSkin(); |
874 | | - |
| 828 | + |
875 | 829 | $author = $thread->author(); |
876 | 830 | $signature = $sk->userLink( $author->getId(), $author->getName() ); |
877 | | - $signature = '— ' . Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ), |
| 831 | + $signature = '— '. Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ), |
878 | 832 | $signature ); |
879 | 833 | $signature .= $sk->userToolLinks( $author->getId(), $author->getName() ); |
880 | | - |
| 834 | + |
881 | 835 | $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ), |
882 | 836 | $signature ); |
883 | | - |
| 837 | + |
884 | 838 | return $signature; |
885 | 839 | } |
886 | | - |
| 840 | + |
887 | 841 | function threadInfoPanel( $thread ) { |
888 | 842 | global $wgUser, $wgLang; |
889 | | - |
| 843 | + |
890 | 844 | $sk = $wgUser->getSkin(); |
891 | | - |
| 845 | + |
892 | 846 | $infoElements = array(); |
893 | | - |
| 847 | + |
894 | 848 | $timestamp = $wgLang->timeanddate( $thread->created(), true ); |
895 | 849 | $infoElements[] = Xml::element( 'div', array( 'class' => 'lqt-thread-toolbar-timestamp' ), |
896 | 850 | $timestamp ); |
897 | | - |
| 851 | + |
898 | 852 | // Check for edited flag. |
899 | | - $editedFlag = $thread->editedness(); |
| 853 | + $editedFlag = $thread->editedness(); |
900 | 854 | $ebLookup = array( Threads::EDITED_BY_AUTHOR => 'author', |
901 | 855 | Threads::EDITED_BY_OTHERS => 'others' ); |
902 | 856 | if ( isset( $ebLookup[$editedFlag] ) ) { |
903 | 857 | |
904 | 858 | $editedBy = $ebLookup[$editedFlag]; |
905 | | - $editedNotice = wfMsgExt( 'lqt-thread-edited-' . $editedBy, 'parseinline' ); |
906 | | - $infoElements[] = Xml::element( |
907 | | - 'div', |
908 | | - array( 'class' => 'lqt-thread-toolbar-edited-' . $editedBy ), |
909 | | - $editedNotice |
910 | | - ); |
| 859 | + $editedNotice = wfMsgExt( 'lqt-thread-edited-'.$editedBy, 'parseinline' ); |
| 860 | + $infoElements[] = Xml::element( 'div', array( 'class' => |
| 861 | + 'lqt-thread-toolbar-edited-'.$editedBy ), |
| 862 | + $editedNotice ); |
911 | 863 | } |
912 | | - |
913 | | - return Xml::tags( |
914 | | - 'div', |
915 | | - array( 'class' => 'lqt-thread-info-panel' ), |
916 | | - implode( "\n", $infoElements ) |
917 | | - ); |
| 864 | + |
| 865 | + return Xml::tags( 'div', array( 'class' => 'lqt-thread-info-panel' ), |
| 866 | + implode( "\n", $infoElements ) ); |
918 | 867 | } |
919 | 868 | |
920 | 869 | /** Shows the headING for a thread (as opposed to the headeER for a post within |
— | — | @@ -924,57 +873,53 @@ |
925 | 874 | $commands_html = ""; |
926 | 875 | } else { |
927 | 876 | $lis = $this->listItemsForCommands( $this->topLevelThreadCommands( $thread ) ); |
928 | | - $commands_html = Xml::tags( |
929 | | - 'ul', |
930 | | - array( 'class' => 'lqt_threadlevel_commands' ), |
931 | | - $lis |
932 | | - ); |
| 877 | + $commands_html = Xml::tags( 'ul', |
| 878 | + array( 'class' => 'lqt_threadlevel_commands' ), |
| 879 | + $lis ); |
933 | 880 | } |
| 881 | + |
| 882 | + $id = 'lqt-header-'.$thread->id(); |
934 | 883 | |
935 | | - $id = 'lqt-header-' . $thread->id(); |
936 | | - |
937 | 884 | $html = $this->output->parseInline( $thread->subjectWithoutIncrement() ); |
938 | 885 | $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html ); |
939 | | - $html = Xml::tags( |
940 | | - 'h' . $this->headerLevel, |
941 | | - array( 'class' => 'lqt_header', 'id' => $id ), |
942 | | - $html |
943 | | - ) . $commands_html; |
944 | | - |
| 886 | + $html = Xml::tags( 'h'.$this->headerLevel, |
| 887 | + array( 'class' => 'lqt_header', 'id' => $id), |
| 888 | + $html ) . $commands_html; |
| 889 | + |
945 | 890 | return $html; |
946 | 891 | } |
947 | | - |
| 892 | + |
948 | 893 | return ''; |
949 | 894 | } |
950 | 895 | |
951 | 896 | function postDivClass( $thread ) { |
952 | | - $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel; |
953 | | - $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even'; |
| 897 | + $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel; |
| 898 | + $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even'; |
954 | 899 | $alternatingClass = "lqt-thread-$alternatingType"; |
955 | | - |
| 900 | + |
956 | 901 | return "lqt_post $levelClass $alternatingClass"; |
957 | 902 | } |
958 | 903 | |
959 | 904 | static function anchorName( $thread ) { |
960 | 905 | return $thread->getAnchorName(); |
961 | 906 | } |
962 | | - |
| 907 | + |
963 | 908 | // Display a moved thread |
964 | 909 | function showMovedThread( $thread ) { |
965 | 910 | global $wgLang; |
966 | | - |
| 911 | + |
967 | 912 | $sk = $this->user->getSkin(); |
968 | | - |
| 913 | + |
969 | 914 | // Grab target thread |
970 | 915 | $article = new Article( $thread->title() ); |
971 | 916 | $target = Title::newFromRedirect( $article->getContent() ); |
972 | 917 | $t_thread = Threads::withRoot( new Article( $target ) ); |
973 | | - |
| 918 | + |
974 | 919 | // Grab data about the new post. |
975 | 920 | $author = $thread->author(); |
976 | 921 | $sig = $sk->userLink( $author->getID(), $author->getName() ) . |
977 | 922 | $sk->userToolLinks( $author->getID(), $author->getName() ); |
978 | | - |
| 923 | + |
979 | 924 | $html = |
980 | 925 | wfMsgExt( 'lqt_move_placeholder', array( 'parseinline', 'replaceafter' ), |
981 | 926 | $sk->link( $target ), |
— | — | @@ -982,10 +927,10 @@ |
983 | 928 | $wgLang->date( $thread->modified() ), |
984 | 929 | $wgLang->time( $thread->modified() ) |
985 | 930 | ); |
986 | | - |
| 931 | + |
987 | 932 | $this->output->addHTML( $html ); |
988 | 933 | } |
989 | | - |
| 934 | + |
990 | 935 | /** Shows a deleted thread. Returns true to show the thread body */ |
991 | 936 | function showDeletedThread( $thread ) { |
992 | 937 | $sk = $this->user->getSkin(); |
— | — | @@ -1001,233 +946,216 @@ |
1002 | 947 | return false; |
1003 | 948 | } |
1004 | 949 | } |
1005 | | - |
| 950 | + |
1006 | 951 | // Shows a single thread, rather than a thread tree. |
1007 | 952 | function showSingleThread( $thread ) { |
1008 | 953 | wfLoadExtensionMessages( 'LiquidThreads' ); |
1009 | | - |
| 954 | + |
1010 | 955 | $html = ''; |
1011 | | - |
| 956 | + |
1012 | 957 | // If it's a 'moved' thread, show the placeholder |
1013 | 958 | if ( $thread->type() == Threads::TYPE_MOVED ) { |
1014 | 959 | $this->showMovedThread( $thread ); |
1015 | 960 | return; |
1016 | 961 | } elseif ( $thread->type() == Threads::TYPE_DELETED ) { |
1017 | 962 | $res = $this->showDeletedThread( $thread ); |
1018 | | - |
1019 | | - if ( !$res ) return; |
| 963 | + |
| 964 | + if (!$res) return; |
1020 | 965 | } |
1021 | | - |
| 966 | + |
1022 | 967 | $this->output->addHTML( $this->threadInfoPanel( $thread ) ); |
1023 | | - |
| 968 | + |
1024 | 969 | if ( $thread->summary() ) { |
1025 | 970 | $html .= $this->getSummary( $thread ); |
1026 | 971 | } |
1027 | | - |
| 972 | + |
1028 | 973 | // Unfortunately, I can't rewrite showRootPost() to pass back HTML |
1029 | 974 | // as it would involve rewriting EditPage, which I do NOT intend to do. |
1030 | 975 | |
1031 | 976 | $this->output->addHTML( $html ); |
1032 | | - |
| 977 | + |
1033 | 978 | $this->showThreadBody( $thread ); |
1034 | | - |
| 979 | + |
1035 | 980 | } |
1036 | 981 | |
1037 | 982 | function showThread( $thread, $levelNum = 1, $totalInLevel = 1, $options = array() ) { |
1038 | 983 | global $wgLang; |
1039 | | - |
| 984 | + |
1040 | 985 | // Safeguard |
1041 | 986 | if ( $thread->type() == Threads::TYPE_DELETED |
1042 | | - && ! ( $this->request->getBool( 'lqt_show_deleted_threads' ) |
| 987 | + && ! ($this->request->getBool( 'lqt_show_deleted_threads' ) |
1043 | 988 | && $this->user->isAllowed( 'deletedhistory' ) ) ) { |
1044 | 989 | return; |
1045 | 990 | } |
1046 | | - |
| 991 | + |
1047 | 992 | $this->threadNestingLevel++; |
1048 | | - |
| 993 | + |
1049 | 994 | // Figure out which threads *need* to be shown because they're involved in an |
1050 | 995 | // operation |
1051 | 996 | static $mustShowThreads = null; // Array of thread IDs |
1052 | | - if ( is_null( $mustShowThreads ) ) { |
| 997 | + if ( is_null($mustShowThreads) ) { |
1053 | 998 | $mustShowThreads = array(); |
1054 | 999 | if ( $this->request->getVal( 'lqt_operand' ) ) { |
1055 | 1000 | $walk_thread = Threads::withId( $this->request->getVal( 'lqt_operand' ) ); |
1056 | | - |
| 1001 | + |
1057 | 1002 | do { |
1058 | 1003 | $mustShowThreads[$walk_thread->id()] = $walk_thread; |
1059 | 1004 | $walk_thread = $walk_thread->superthread(); |
1060 | 1005 | } while ( $walk_thread ); |
1061 | 1006 | } |
1062 | 1007 | } |
1063 | | - |
| 1008 | + |
1064 | 1009 | $sk = $this->user->getSkin(); |
1065 | | - |
| 1010 | + |
1066 | 1011 | $html = ''; |
1067 | 1012 | |
1068 | | - $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' ); |
| 1013 | + $html .= Xml::element( 'a', array( 'name' => $this->anchorName($thread) ), ' ' ); |
1069 | 1014 | |
1070 | 1015 | $html .= $this->showThreadHeading( $thread ); |
1071 | | - |
| 1016 | + |
1072 | 1017 | $class = $this->threadDivClass( $thread ); |
1073 | | - if ( $levelNum == 1 ) { |
| 1018 | + if ($levelNum == 1) { |
1074 | 1019 | $class .= ' lqt-thread-first'; |
1075 | | - } elseif ( $levelNum == $totalInLevel ) { |
| 1020 | + } elseif ($levelNum == $totalInLevel) { |
1076 | 1021 | $class .= ' lqt-thread-last'; |
1077 | 1022 | } |
| 1023 | + |
| 1024 | + $html .= Xml::openElement( 'div', array( 'class' => $class, |
| 1025 | + 'id' => 'lqt_thread_id_'. $thread->id() ) ); |
1078 | 1026 | |
1079 | | - $html .= Xml::openElement( |
1080 | | - 'div', |
1081 | | - array( |
1082 | | - 'class' => $class, |
1083 | | - 'id' => 'lqt_thread_id_' . $thread->id() |
1084 | | - ) |
1085 | | - ); |
1086 | | - |
1087 | 1027 | // Modified time for topmost threads... |
1088 | 1028 | if ( $thread->isTopmostThread() ) { |
1089 | | - $html .= Xml::hidden('lqt-thre |
1090 | | - ad-modified-' . $thread->id(), |
1091 | | - wfTimestamp( TS_MW, $thread->modified() ), |
1092 | | - array( |
1093 | | - 'id' => 'lqt-thread-modified-' . $thread->id(), |
1094 | | - 'class' => 'lqt-thread-modified' |
1095 | | - ) |
1096 | | - ); |
1097 | | - } |
| 1029 | + $html .= Xml::hidden( 'lqt-thread-modified-'.$thread->id(), |
| 1030 | + wfTimestamp( TS_MW, $thread->modified() ), |
| 1031 | + array( 'id' => 'lqt-thread-modified-'.$thread->id(), |
| 1032 | + 'class' => 'lqt-thread-modified' ) ); |
| 1033 | + } |
1098 | 1034 | |
1099 | 1035 | // Flush output to display thread |
1100 | 1036 | $this->output->addHTML( $html ); |
1101 | | - $this->output->addHTML( Xml::openElement( |
1102 | | - 'div', |
1103 | | - array( 'class' => 'lqt-post-wrapper' ) |
1104 | | - ) ); |
| 1037 | + $this->output->addHTML( Xml::openElement( 'div', |
| 1038 | + array( 'class' => 'lqt-post-wrapper' ) ) ); |
1105 | 1039 | $this->showSingleThread( $thread ); |
1106 | 1040 | $this->output->addHTML( Xml::closeElement( 'div' ) ); |
1107 | 1041 | |
1108 | 1042 | // Check depth and count |
1109 | | - if ( isset( $options['maxDepth'] ) ) { |
| 1043 | + if ( isset($options['maxDepth']) ) { |
1110 | 1044 | $maxDepth = $options['maxDepth']; |
1111 | 1045 | } else { |
1112 | 1046 | $maxDepth = $this->user->getOption( 'lqtdisplaydepth' ); |
1113 | 1047 | } |
1114 | | - |
1115 | | - if ( isset( $options['maxCount'] ) ) { |
| 1048 | + |
| 1049 | + if ( isset($options['maxCount']) ) { |
1116 | 1050 | $maxCount = $options['maxCount']; |
1117 | 1051 | } else { |
1118 | 1052 | $maxCount = $this->user->getOption( 'lqtdisplaycount' ); |
1119 | 1053 | } |
1120 | | - |
| 1054 | + |
1121 | 1055 | if ( isset( $options['startAt'] ) ) { |
1122 | 1056 | $startAt = $options['startAt']; |
1123 | 1057 | } else { |
1124 | 1058 | $startAt = 0; |
1125 | 1059 | } |
1126 | | - |
| 1060 | + |
1127 | 1061 | $cascadeOptions = $options; |
1128 | | - unset( $cascadeOptions['startAt'] ); |
1129 | | - |
1130 | | - $showThreads = ( $maxDepth == - 1 ) || ( $this->threadNestingLevel <= $maxDepth ); |
1131 | | - |
| 1062 | + unset($cascadeOptions['startAt']); |
| 1063 | + |
| 1064 | + $showThreads = ($maxDepth == -1) || ( $this->threadNestingLevel <= $maxDepth ); |
| 1065 | + |
1132 | 1066 | // Show subthreads if one of the subthreads is on the must-show list |
1133 | 1067 | $showThreads = $showThreads || |
1134 | | - count( array_intersect( array_keys( $mustShowThreads ), array_keys( $thread->replies() ) ) ); |
| 1068 | + count( array_intersect( array_keys($mustShowThreads), array_keys( $thread->replies() ) ) ); |
1135 | 1069 | if ( $thread->hasSubthreads() && $showThreads ) { |
1136 | | - $repliesClass = 'lqt-thread-replies lqt-thread-replies-' . $this->threadNestingLevel; |
| 1070 | + $repliesClass = 'lqt-thread-replies lqt-thread-replies-'.$this->threadNestingLevel; |
1137 | 1071 | $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) ); |
1138 | 1072 | $this->output->addHTML( $div ); |
1139 | | - |
| 1073 | + |
1140 | 1074 | $subthreadCount = count( $thread->subthreads() ); |
1141 | 1075 | $i = 0; |
1142 | 1076 | $showCount = 0; |
1143 | 1077 | $showThreads = true; |
1144 | | - |
| 1078 | + |
1145 | 1079 | foreach ( $thread->subthreads() as $st ) { |
1146 | 1080 | ++$i; |
1147 | | - |
| 1081 | + |
1148 | 1082 | // Only show undeleted threads that are above our 'startAt' index. |
1149 | 1083 | $shown = false; |
1150 | | - if ( $st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads ) { |
1151 | | - if ( $showCount > $maxCount && $maxCount > 0 ) { |
| 1084 | + if ($st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads) { |
| 1085 | + if ($showCount > $maxCount && $maxCount > 0) { |
1152 | 1086 | // We've shown too many threads. |
1153 | 1087 | $linkText = wfMsgExt( 'lqt-thread-show-more', 'parseinline' ); |
1154 | 1088 | $linkTitle = clone $thread->topmostThread()->title(); |
1155 | | - $linkTitle->setFragment( '#' . $st->getAnchorName() ); |
1156 | | - |
1157 | | - $link = $sk->link( |
1158 | | - $linkTitle, |
1159 | | - $linkText, |
1160 | | - array( 'class' => 'lqt-show-more-posts' ) |
1161 | | - ); |
1162 | | - $link .= Xml::hidden( |
1163 | | - 'lqt-thread-start-at', |
1164 | | - $i, |
1165 | | - array( 'class' => 'lqt-thread-start-at' ) |
1166 | | - ); |
1167 | | - |
| 1089 | + $linkTitle->setFragment( '#'.$st->getAnchorName() ); |
| 1090 | + |
| 1091 | + $link = $sk->link( $linkTitle, $linkText, |
| 1092 | + array( 'class' => 'lqt-show-more-posts' ) ); |
| 1093 | + $link .= Xml::hidden( 'lqt-thread-start-at', $i, |
| 1094 | + array( 'class' => 'lqt-thread-start-at' ) ); |
| 1095 | + |
1168 | 1096 | $this->output->addHTML( $link ); |
1169 | 1097 | $showThreads = false; |
1170 | 1098 | continue; |
1171 | 1099 | } |
1172 | | - |
| 1100 | + |
1173 | 1101 | ++$showCount; |
1174 | | - if ( $showCount == 1 ) { |
| 1102 | + if ($showCount == 1 ) { |
1175 | 1103 | $this->output->addHTML( |
1176 | 1104 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1177 | 1105 | } |
1178 | | - |
| 1106 | + |
1179 | 1107 | $this->showThread( $st, $i, $subthreadCount, $cascadeOptions ); |
1180 | 1108 | $shown = true; |
1181 | 1109 | } |
1182 | | - |
1183 | | - if ( $st->type() != Threads::TYPE_DELETED && !$shown && |
| 1110 | + |
| 1111 | + if ($st->type() != Threads::TYPE_DELETED && !$shown && |
1184 | 1112 | array_key_exists( $st->id(), $mustShowThreads ) ) { |
1185 | | - |
| 1113 | + |
1186 | 1114 | $this->showThread( $st, $i, $subthreadCount, $cascadeOptions ); |
1187 | 1115 | } |
1188 | 1116 | } |
1189 | | - |
| 1117 | + |
1190 | 1118 | $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
1191 | 1119 | Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
1192 | | - |
| 1120 | + |
1193 | 1121 | $this->output->addHTML( $finishDiv . Xml::CloseElement( 'div' ) ); |
1194 | 1122 | } elseif ( $thread->hasSubthreads() && !$showThreads ) { |
1195 | 1123 | // Add a "show subthreads" link. |
1196 | | - $replies = count( $thread->replies() ); |
1197 | | - $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum( $replies ) ); |
| 1124 | + $replies = count($thread->replies()); |
| 1125 | + $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum($replies) ); |
1198 | 1126 | $linkTitle = clone $thread->topmostThread()->title(); |
1199 | | - $linkTitle->setFragment( '#' . $thread->getAnchorName() ); |
1200 | | - |
| 1127 | + $linkTitle->setFragment( '#'.$thread->getAnchorName() ); |
| 1128 | + |
1201 | 1129 | $link = $sk->link( $linkTitle, $linkText, array( 'class' => 'lqt-show-replies' ) ); |
1202 | | - |
| 1130 | + |
1203 | 1131 | $this->output->addHTML( Xml::tags( 'div', array( 'class' => 'lqt-thread-replies' ), $link ) ); |
1204 | | - |
1205 | | - if ( $levelNum < $totalInLevel ) { |
| 1132 | + |
| 1133 | + if ($levelNum < $totalInLevel) { |
1206 | 1134 | $this->output->addHTML( |
1207 | 1135 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1208 | 1136 | } |
1209 | | - } elseif ( $levelNum < $totalInLevel ) { |
| 1137 | + } elseif ($levelNum < $totalInLevel) { |
1210 | 1138 | $this->output->addHTML( |
1211 | 1139 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1212 | 1140 | } |
1213 | 1141 | |
1214 | | - if ( $this->threadNestingLevel == 1 ) { |
| 1142 | + if ($this->threadNestingLevel == 1) { |
1215 | 1143 | $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
1216 | 1144 | Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
1217 | | - |
| 1145 | + |
1218 | 1146 | $this->output->addHTML( $finishDiv ); |
1219 | 1147 | } |
1220 | 1148 | |
1221 | 1149 | $this->output->addHTML( Xml::closeElement( 'div' ) ); |
1222 | | - |
| 1150 | + |
1223 | 1151 | $this->threadNestingLevel--; |
1224 | 1152 | } |
1225 | | - |
| 1153 | + |
1226 | 1154 | function threadDivClass( $thread ) { |
1227 | | - $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel; |
1228 | | - $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even'; |
| 1155 | + $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel; |
| 1156 | + $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even'; |
1229 | 1157 | $alternatingClass = "lqt-thread-$alternatingType"; |
1230 | 1158 | $topmostClass = $thread->isTopmostThread() ? ' lqt-thread-topmost' : ''; |
1231 | | - |
| 1159 | + |
1232 | 1160 | return "lqt_thread $levelClass $alternatingClass$topmostClass"; |
1233 | 1161 | } |
1234 | 1162 | |
— | — | @@ -1237,42 +1165,32 @@ |
1238 | 1166 | wfLoadExtensionMessages( 'LiquidThreads' ); |
1239 | 1167 | global $wgUser; |
1240 | 1168 | $sk = $wgUser->getSkin(); |
1241 | | - |
| 1169 | + |
1242 | 1170 | $label = wfMsgExt( 'lqt_summary_label', 'parseinline' ); |
1243 | 1171 | $edit_text = wfMsgExt( 'edit', 'parseinline' ); |
1244 | 1172 | $link_text = wfMsg( 'lqt_permalink', 'parseinline' ); |
1245 | | - |
| 1173 | + |
1246 | 1174 | $html = ''; |
1247 | | - |
| 1175 | + |
1248 | 1176 | $html .= Xml::tags( 'span', |
1249 | 1177 | array( 'class' => 'lqt_thread_permalink_summary_title' ), |
1250 | 1178 | $label ); |
1251 | | - |
| 1179 | + |
1252 | 1180 | $link = $sk->link( $t->summary()->getTitle(), $link_text ); |
1253 | 1181 | $edit_link = self::permalink( $t, $edit_text, 'summarize', $t->id() ); |
1254 | 1182 | $links = "[$link]\n[$edit_link]"; |
1255 | | - $html .= Xml::tags( |
1256 | | - 'span', |
1257 | | - array( 'class' => 'lqt_thread_permalink_summary_edit' ), |
1258 | | - $links |
1259 | | - ); |
1260 | | - |
| 1183 | + $html .= Xml::tags( 'span', array( 'class' => 'lqt_thread_permalink_summary_edit' ), |
| 1184 | + $links ); |
| 1185 | + |
1261 | 1186 | $summary_body = $this->showPostBody( $t->summary() ); |
1262 | | - $html .= Xml::tags( |
1263 | | - 'div', |
1264 | | - array( 'class' => 'lqt_thread_permalink_summary_body' ), |
1265 | | - $summary_body |
1266 | | - ); |
1267 | | - |
1268 | | - $html = Xml::tags( |
1269 | | - 'div', |
1270 | | - array( 'class' => 'lqt_thread_permalink_summary' ), |
1271 | | - $html |
1272 | | - ); |
1273 | | - |
| 1187 | + $html .= Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary_body' ), |
| 1188 | + $summary_body ); |
| 1189 | + |
| 1190 | + $html = Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary' ), $html ); |
| 1191 | + |
1274 | 1192 | return $html; |
1275 | 1193 | } |
1276 | | - |
| 1194 | + |
1277 | 1195 | function showSummary( $t ) { |
1278 | 1196 | $this->output->addHTML( $this->getSummary( $t ) ); |
1279 | 1197 | } |
Index: trunk/extensions/LiquidThreads/classes/Dispatch.php |
— | — | @@ -13,42 +13,41 @@ |
14 | 14 | 'ThreadProtectionFormView' => 'ThreadProtectionFormView', |
15 | 15 | 'ThreadWatchView' => 'ThreadWatchView', |
16 | 16 | 'SummaryPageView' => 'SummaryPageView' |
17 | | - ); |
18 | | - |
| 17 | + ); |
| 18 | + |
19 | 19 | /** static cache of per-page LiquidThreads activation setting */ |
20 | 20 | static $userLQTActivated; |
21 | 21 | |
22 | 22 | static function talkpageMain( &$output, &$article, &$title, &$user, &$request ) { |
23 | 23 | // We are given a talkpage article and title. Fire up a TalkpageView |
24 | | - |
| 24 | + |
25 | 25 | if ( $title->getNamespace() == NS_LQT_THREAD + 1 /* talk page */ ) { |
26 | 26 | // Threads don't have talk pages; redirect to the thread page. |
27 | 27 | $output->redirect( $title->getSubjectPage()->getFullUrl() ); |
28 | 28 | return false; |
29 | 29 | } |
30 | | - |
| 30 | + |
31 | 31 | // If we came here from a red-link, redirect to the thread page. |
32 | 32 | $redlink = $request->getCheck( 'redlink' ) && |
33 | 33 | $request->getText( 'action' ) == 'edit'; |
34 | | - if ( $redlink ) { |
| 34 | + if( $redlink ) { |
35 | 35 | $output->redirect( $title->getFullURL() ); |
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | 39 | /* Certain actions apply to the "header", which is stored in the actual talkpage |
40 | | - * in the database. Drop everything and behave like a normal page if those |
41 | | - * actions come up, to avoid hacking the various history, editing, etc. code. |
42 | | - */ |
| 40 | + in the database. Drop everything and behave like a normal page if those |
| 41 | + actions come up, to avoid hacking the various history, editing, etc. code. */ |
43 | 42 | $action = $request->getVal( 'action' ); |
44 | 43 | $header_actions = array( 'history', 'edit', 'submit', 'delete' ); |
45 | 44 | global $wgRequest; |
46 | | - if ( $action == 'edit' && $request->getVal( 'section' ) == 'new' ) { |
| 45 | + if ($action == 'edit' && $request->getVal('section') == 'new') { |
47 | 46 | // Hijack section=new for "new thread". |
48 | 47 | $request->setVal( 'lqt_method', 'talkpage_new_thread' ); |
49 | 48 | $request->setVal( 'section', '' ); |
50 | | - |
| 49 | + |
51 | 50 | $viewname = self::$views['TalkpageView']; |
52 | | - |
| 51 | + |
53 | 52 | } elseif ( $request->getVal( 'lqt_method', null ) === null && |
54 | 53 | ( in_array( $action, $header_actions ) || |
55 | 54 | $request->getVal( 'diff', null ) !== null ) ) { |
— | — | @@ -65,6 +64,7 @@ |
66 | 65 | } |
67 | 66 | |
68 | 67 | static function threadPermalinkMain( &$output, &$article, &$title, &$user, &$request ) { |
| 68 | + |
69 | 69 | $action = $request->getVal( 'action' ); |
70 | 70 | $lqt_method = $request->getVal( 'lqt_method' ); |
71 | 71 | |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | } else { |
90 | 90 | $viewname = self::$views['ThreadPermalinkView']; |
91 | 91 | } |
92 | | - |
| 92 | + |
93 | 93 | $view = new $viewname( $output, $article, $title, $user, $request ); |
94 | 94 | return $view->show(); |
95 | 95 | } |
— | — | @@ -98,28 +98,29 @@ |
99 | 99 | $view = new $viewname( $output, $article, $title, $user, $request ); |
100 | 100 | return $view->show(); |
101 | 101 | } |
102 | | - |
| 102 | + |
103 | 103 | static function isLqtPage( $title ) { |
104 | 104 | global $wgLqtPages, $wgLqtTalkPages; |
105 | | - $isTalkPage = ( $title->isTalkPage() && $wgLqtTalkPages ) || |
| 105 | + $isTalkPage = ($title->isTalkPage() && $wgLqtTalkPages) || |
106 | 106 | in_array( $title->getPrefixedText(), $wgLqtPages ) || |
107 | 107 | self::hasUserEnabledLQT( $title->getArticleId() ); |
108 | | - |
| 108 | + |
109 | 109 | return $isTalkPage; |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | static function hasUserEnabledLQT( $article ) { |
113 | | - if ( is_object( $article ) ) { |
| 113 | + |
| 114 | + if (is_object($article)) { |
114 | 115 | $article = $article->getId(); |
115 | 116 | } |
116 | | - |
| 117 | + |
117 | 118 | // Instance cache |
118 | 119 | if ( isset( self::$userLQTActivated[$article] ) ) { |
119 | 120 | $cacheVal = self::$userLQTActivated[$article]; |
120 | 121 | |
121 | 122 | return $cacheVal; |
122 | 123 | } |
123 | | - |
| 124 | + |
124 | 125 | // Memcached: It isn't clear that this is needed yet, but since I already wrote the |
125 | 126 | // code, I might as well leave it commented out instead of deleting it. |
126 | 127 | // Main reason I've left this commented out is because it isn't obvious how to |
— | — | @@ -134,21 +135,15 @@ |
135 | 136 | // return $wgLqtThreadArchiveStartDays; |
136 | 137 | // } |
137 | 138 | // } |
138 | | - |
| 139 | + |
139 | 140 | // Load from the database. |
140 | 141 | $dbr = wfGetDB( DB_SLAVE ); |
141 | | - |
142 | | - $dbVal = $dbr->selectField( |
143 | | - 'page_props', |
144 | | - 'pp_value', |
145 | | - array( |
146 | | - 'pp_propname' => 'use-liquid-threads', |
147 | | - 'pp_page' => $article |
148 | | - ), |
149 | | - __METHOD__ |
150 | | - ); |
151 | | - |
152 | | - if ( $dbVal ) { |
| 142 | + |
| 143 | + $dbVal = $dbr->selectField( 'page_props', 'pp_value', |
| 144 | + array( 'pp_propname' => 'use-liquid-threads', |
| 145 | + 'pp_page' => $article ), __METHOD__ ); |
| 146 | + |
| 147 | + if ($dbVal) { |
153 | 148 | self::$userLQTActivated[$article] = true; |
154 | 149 | # $wgMemc->set( $key, $dbVal, 1800 ); |
155 | 150 | return true; |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -5,12 +5,10 @@ |
6 | 6 | // Shortcut for non-LQT pages. |
7 | 7 | if ( !LqtDispatch::isLqtPage( $ot ) ) |
8 | 8 | return true; |
9 | | - |
| 9 | + |
10 | 10 | // Move the threads on that page to the new page. |
11 | | - $threads = Threads::where( array( |
12 | | - Threads::articleClause( new Article( $ot ) ), |
13 | | - Threads::topLevelClause() ) |
14 | | - ); |
| 11 | + $threads = Threads::where( array( Threads::articleClause( new Article( $ot ) ), |
| 12 | + Threads::topLevelClause() ) ); |
15 | 13 | |
16 | 14 | foreach ( $threads as $t ) { |
17 | 15 | $t->moveToPage( $nt, false ); |
— | — | @@ -22,7 +20,7 @@ |
23 | 21 | static function customizeOldChangesList( &$changeslist, &$s, $rc ) { |
24 | 22 | if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) |
25 | 23 | return true; |
26 | | - |
| 24 | + |
27 | 25 | $thread = Threads::withRoot( new Article( $rc->getTitle() ) ); |
28 | 26 | if ( !$thread ) return true; |
29 | 27 | |
— | — | @@ -31,7 +29,7 @@ |
32 | 30 | |
33 | 31 | if ( $rc->mAttribs['rc_new'] ) { |
34 | 32 | global $wgOut; |
35 | | - |
| 33 | + |
36 | 34 | $sig = ""; |
37 | 35 | $changeslist->insertUserRelatedLinks( $sig, $rc ); |
38 | 36 | |
— | — | @@ -45,7 +43,7 @@ |
46 | 44 | $link = $sk->link( $thread->title(), wfMsg( 'lqt_rc_ellipsis' ), |
47 | 45 | array( 'class' => 'lqt_rc_ellipsis' ), array(), array( 'known' ) ); |
48 | 46 | } |
49 | | - |
| 47 | + |
50 | 48 | $quote = $wgOut->parseInline( $quote ) . $link; |
51 | 49 | |
52 | 50 | if ( $thread->isTopmostThread() ) { |
— | — | @@ -53,10 +51,10 @@ |
54 | 52 | } else { |
55 | 53 | $message_name = 'lqt_rc_new_reply'; |
56 | 54 | } |
57 | | - |
| 55 | + |
58 | 56 | $tmp_title = $thread->article()->getTitle(); |
59 | 57 | $tmp_title->setFragment( '#' . LqtView::anchorName( $thread ) ); |
60 | | - |
| 58 | + |
61 | 59 | // Make sure it points to the right page. The Pager seems to use the DB |
62 | 60 | // representation of a timestamp for its offset field, odd. |
63 | 61 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -64,7 +62,7 @@ |
65 | 63 | $offset = $dbr->timestamp( $offset ); |
66 | 64 | |
67 | 65 | $thread_link = $changeslist->skin->link( $tmp_title, |
68 | | - htmlspecialchars( $thread->subjectWithoutIncrement() ), |
| 66 | + htmlspecialchars($thread->subjectWithoutIncrement()), |
69 | 67 | array(), array( 'offset' => $offset ), array( 'known' ) ); |
70 | 68 | |
71 | 69 | $talkpage_link = $changeslist->skin->link( |
— | — | @@ -74,19 +72,19 @@ |
75 | 73 | |
76 | 74 | $s = wfMsg( $message_name, $thread_link, $talkpage_link, $sig ) |
77 | 75 | . Xml::tags( 'blockquote', array( 'class' => 'lqt_rc_blockquote' ), $quote ); |
78 | | - |
| 76 | + |
79 | 77 | $classes = array(); |
80 | 78 | $changeslist->insertTags( $s, $rc, $classes ); |
81 | 79 | $changeslist->insertExtra( $s, $rc, $classes ); |
82 | 80 | } else { |
83 | 81 | // Add whether it was original author. |
84 | 82 | if ( $thread->author()->getName() != $rc->mAttribs['rc_user_text'] ) { |
85 | | - $appendix = Xml::tags( |
86 | | - 'span', |
87 | | - array( 'class' => 'lqt_rc_author_notice ' . 'lqt_rc_author_notice_others' ), |
88 | | - wfMsgExt( 'lqt_rc_author_others', 'parseinline' ) |
89 | | - ); |
90 | | - |
| 83 | + $appendix = Xml::tags( 'span', |
| 84 | + array( 'class' => 'lqt_rc_author_notice ' . |
| 85 | + 'lqt_rc_author_notice_others' ), |
| 86 | + wfMsgExt( 'lqt_rc_author_others', 'parseinline' ) |
| 87 | + ); |
| 88 | + |
91 | 89 | $s .= ' ' . $appendix; |
92 | 90 | } |
93 | 91 | } |
— | — | @@ -104,10 +102,8 @@ |
105 | 103 | && ! $watchlist_t->equals( $wgTitle ) |
106 | 104 | && ! $usertalk_t->equals( $wgTitle ) |
107 | 105 | ) { |
108 | | - $s = wfMsgExt( |
109 | | - 'lqt_youhavenewmessages', array( 'parseinline' ), |
110 | | - $newmsg_t->getFullURL() |
111 | | - ); |
| 106 | + $s = wfMsgExt( 'lqt_youhavenewmessages', array( 'parseinline' ), |
| 107 | + $newmsg_t->getFullURL() ); |
112 | 108 | $tpl->set( "newtalk", $s ); |
113 | 109 | $wgOut->setSquidMaxage( 0 ); |
114 | 110 | } else { |
— | — | @@ -116,64 +112,62 @@ |
117 | 113 | |
118 | 114 | return true; |
119 | 115 | } |
120 | | - |
| 116 | + |
121 | 117 | static function beforeWatchlist( &$conds, &$tables, &$join_conds, &$fields ) { |
122 | 118 | global $wgOut, $wgUser; |
123 | | - |
| 119 | + |
124 | 120 | $db = wfGetDB( DB_SLAVE ); |
125 | | - |
| 121 | + |
126 | 122 | if ( !in_array( 'page', $tables ) ) { |
127 | 123 | $tables[] = 'page'; |
128 | 124 | // Yes, this is the correct field to join to. Weird naming. |
129 | 125 | $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' ); |
130 | 126 | } |
131 | | - $conds[] = "page_namespace != " . $db->addQuotes( NS_LQT_THREAD ); |
132 | | - |
| 127 | + $conds[] = "page_namespace != " . $db->addQuotes(NS_LQT_THREAD); |
| 128 | + |
133 | 129 | $talkpage_messages = NewMessages::newUserMessages( $wgUser ); |
134 | 130 | $tn = count( $talkpage_messages ); |
135 | | - |
| 131 | + |
136 | 132 | $watch_messages = NewMessages::watchedThreadsForUser( $wgUser ); |
137 | 133 | $wn = count( $watch_messages ); |
138 | | - |
| 134 | + |
139 | 135 | if ( $tn == 0 && $wn == 0 ) |
140 | 136 | return true; |
141 | | - |
| 137 | + |
142 | 138 | LqtView::addJSandCSS(); |
143 | 139 | wfLoadExtensionMessages( 'LiquidThreads' ); |
144 | 140 | $messages_title = SpecialPage::getTitleFor( 'NewMessages' ); |
145 | 141 | $new_messages = wfMsgExt( 'lqt-new-messages', 'parseinline' ); |
146 | | - |
| 142 | + |
147 | 143 | $sk = $wgUser->getSkin(); |
148 | | - $link = $sk->link( |
149 | | - $messages_title, |
150 | | - $new_messages, |
151 | | - array( 'class' => 'lqt_watchlist_messages_notice' ) |
152 | | - ); |
| 144 | + $link = $sk->link( $messages_title, $new_messages, |
| 145 | + array( 'class' => 'lqt_watchlist_messages_notice' ) ); |
153 | 146 | $wgOut->addHTML( $link ); |
154 | | - |
| 147 | + |
155 | 148 | return true; |
156 | 149 | } |
157 | | - |
| 150 | + |
158 | 151 | static function getPreferences( $user, &$preferences ) { |
159 | 152 | global $wgEnableEmail; |
160 | 153 | wfLoadExtensionMessages( 'LiquidThreads' ); |
161 | | - |
162 | | - if ( $wgEnableEmail ) { |
163 | | - $preferences['lqtnotifytalk'] = array( |
164 | | - 'type' => 'toggle', |
165 | | - 'label-message' => 'lqt-preference-notify-talk', |
166 | | - 'section' => 'personal/email' |
167 | | - ); |
| 154 | + |
| 155 | + if ($wgEnableEmail) { |
| 156 | + $preferences['lqtnotifytalk'] = |
| 157 | + array( |
| 158 | + 'type' => 'toggle', |
| 159 | + 'label-message' => 'lqt-preference-notify-talk', |
| 160 | + 'section' => 'personal/email' |
| 161 | + ); |
168 | 162 | } |
169 | | - |
170 | | - |
| 163 | + |
| 164 | + |
171 | 165 | $preferences['lqt-watch-threads'] = |
172 | 166 | array( |
173 | 167 | 'type' => 'toggle', |
174 | 168 | 'label-message' => 'lqt-preference-watch-threads', |
175 | 169 | 'section' => 'watchlist/advancedwatchlist', |
176 | 170 | ); |
177 | | - |
| 171 | + |
178 | 172 | // Display depth and count |
179 | 173 | $preferences['lqtdisplaydepth'] = |
180 | 174 | array( |
— | — | @@ -181,7 +175,7 @@ |
182 | 176 | 'label-message' => 'lqt-preference-display-depth', |
183 | 177 | 'section' => 'lqt', |
184 | 178 | ); |
185 | | - |
| 179 | + |
186 | 180 | // Display depth and count |
187 | 181 | $preferences['lqtdisplaycount'] = |
188 | 182 | array( |
— | — | @@ -189,40 +183,36 @@ |
190 | 184 | 'label-message' => 'lqt-preference-display-count', |
191 | 185 | 'section' => 'lqt', |
192 | 186 | ); |
193 | | - |
| 187 | + |
194 | 188 | return true; |
195 | 189 | } |
196 | | - |
| 190 | + |
197 | 191 | static function updateNewtalkOnEdit( $article ) { |
198 | 192 | $title = $article->getTitle(); |
199 | | - |
| 193 | + |
200 | 194 | if ( LqtDispatch::isLqtPage( $title ) ) { |
201 | 195 | // They're only editing the header, don't update newtalk. |
202 | 196 | return false; |
203 | 197 | } |
204 | | - |
| 198 | + |
205 | 199 | return true; |
206 | 200 | } |
207 | | - |
| 201 | + |
208 | 202 | static function dumpThreadData( $writer, &$out, $row, $title ) { |
209 | | - $editedStati = array( |
210 | | - Threads::EDITED_NEVER => 'never', |
211 | | - Threads::EDITED_HAS_REPLY => 'has-reply', |
212 | | - Threads::EDITED_BY_AUTHOR => 'by-author', |
213 | | - Threads::EDITED_BY_OTHERS => 'by-others' |
214 | | - ); |
215 | | - $threadTypes = array( |
216 | | - Threads::TYPE_NORMAL => 'normal', |
217 | | - Threads::TYPE_MOVED => 'moved', |
218 | | - Threads::TYPE_DELETED => 'deleted' |
219 | | - ); |
| 203 | + $editedStati = array( Threads::EDITED_NEVER => 'never', |
| 204 | + Threads::EDITED_HAS_REPLY => 'has-reply', |
| 205 | + Threads::EDITED_BY_AUTHOR => 'by-author', |
| 206 | + Threads::EDITED_BY_OTHERS => 'by-others' ); |
| 207 | + $threadTypes = array( Threads::TYPE_NORMAL => 'normal', |
| 208 | + Threads::TYPE_MOVED => 'moved', |
| 209 | + Threads::TYPE_DELETED => 'deleted' ); |
220 | 210 | // Is it a thread |
221 | 211 | if ( $row->thread_id ) { |
222 | 212 | $thread = new Thread( $row ); |
223 | 213 | $threadInfo = "\n"; |
224 | 214 | $attribs = array(); |
225 | 215 | $attribs['ThreadSubject'] = $thread->subject(); |
226 | | - if ( $thread->hasSuperThread() ) { |
| 216 | + if ($thread->hasSuperThread()) { |
227 | 217 | $attribs['ThreadParent'] = $thread->superThread()->id(); |
228 | 218 | } |
229 | 219 | $attribs['ThreadAncestor'] = $thread->topmostThread()->id(); |
— | — | @@ -234,39 +224,39 @@ |
235 | 225 | $attribs['ThreadAuthor'] = $thread->author()->getName(); |
236 | 226 | $attribs['ThreadEditStatus'] = $editedStati[$thread->editedness()]; |
237 | 227 | $attribs['ThreadType'] = $threadTypes[$thread->type()]; |
238 | | - |
239 | | - foreach ( $attribs as $key => $value ) { |
240 | | - $threadInfo .= "\t" . Xml::element( $key, null, $value ) . "\n"; |
| 228 | + |
| 229 | + foreach( $attribs as $key => $value ) { |
| 230 | + $threadInfo .= "\t".Xml::element( $key, null, $value ) . "\n"; |
241 | 231 | } |
242 | | - |
| 232 | + |
243 | 233 | $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n"; |
244 | 234 | } |
245 | | - |
| 235 | + |
246 | 236 | return true; |
247 | 237 | } |
248 | | - |
| 238 | + |
249 | 239 | static function modifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) { |
250 | 240 | $tables[] = 'thread'; |
251 | | - |
| 241 | + |
252 | 242 | $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) ); |
253 | | - |
| 243 | + |
254 | 244 | return true; |
255 | 245 | } |
256 | | - |
| 246 | + |
257 | 247 | static function customiseSearchResultTitle( &$title, &$text, $result, $terms, $page ) { |
258 | 248 | if ( $title->getNamespace() != NS_LQT_THREAD ) { |
259 | 249 | return true; |
260 | 250 | } |
261 | | - |
262 | | - $thread = Threads::withRoot( new Article( $title ) ); |
| 251 | + |
| 252 | + $thread = Threads::withRoot( new Article($title) ); |
263 | 253 | $text = $thread->subject(); |
264 | | - |
| 254 | + |
265 | 255 | $title = clone $thread->topmostThread()->title(); |
266 | | - $title->setFragment( '#' . $thread->getAnchorName() ); |
267 | | - |
| 256 | + $title->setFragment( '#'.$thread->getAnchorName() ); |
| 257 | + |
268 | 258 | return true; |
269 | 259 | } |
270 | | - |
| 260 | + |
271 | 261 | static function onUserRename( $renameUserSQL ) { |
272 | 262 | // Always use the job queue, talk page edits will take forever |
273 | 263 | $renameUserSQL->tablesJob['thread'] = |
— | — | @@ -275,55 +265,57 @@ |
276 | 266 | array( 'th_user_text', 'th_user', 'th_timestamp' ); |
277 | 267 | return true; |
278 | 268 | } |
279 | | - |
| 269 | + |
280 | 270 | static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) { |
281 | 271 | $article = $editPage->getArticle(); |
282 | 272 | $title = $article->getTitle(); |
283 | | - |
| 273 | + |
284 | 274 | if ( !$article->exists() && $title->getNamespace() == NS_LQT_THREAD ) { |
285 | 275 | unset( $checkboxes['minor'] ); |
286 | 276 | } |
287 | | - |
| 277 | + |
288 | 278 | return true; |
289 | 279 | } |
290 | | - |
| 280 | + |
291 | 281 | static function customiseSearchProfiles( &$profiles ) { |
292 | 282 | wfLoadExtensionMessages( 'LiquidThreads' ); |
293 | | - |
| 283 | + |
294 | 284 | $namespaces = array( NS_LQT_THREAD, NS_LQT_SUMMARY ); |
295 | | - |
| 285 | + |
296 | 286 | // Add odd namespaces |
297 | | - foreach ( SearchEngine::searchableNamespaces() as $ns => $nsName ) { |
298 | | - if ( $ns % 2 == 1 ) { |
| 287 | + foreach( SearchEngine::searchableNamespaces() as $ns => $nsName ) { |
| 288 | + if ($ns % 2 == 1) { |
299 | 289 | $namespaces[] = $ns; |
300 | 290 | } |
301 | 291 | } |
302 | | - |
| 292 | + |
303 | 293 | $insert = array( |
304 | | - 'threads' => array( |
305 | | - 'message' => 'searchprofile-threads', |
306 | | - 'tooltip' => 'searchprofile-threads-tooltip', |
307 | | - 'namespaces' => $namespaces, |
308 | | - 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ), |
309 | | - ), |
| 294 | + 'threads' => |
| 295 | + array( |
| 296 | + 'message' => 'searchprofile-threads', |
| 297 | + 'tooltip' => 'searchprofile-threads-tooltip', |
| 298 | + 'namespaces' => $namespaces, |
| 299 | + 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ), |
| 300 | + ), |
310 | 301 | ); |
311 | | - |
| 302 | + |
312 | 303 | $profiles = wfArrayInsertAfter( $profiles, $insert, 'help' ); |
313 | | - |
| 304 | + |
314 | 305 | return true; |
315 | 306 | } |
316 | | - |
| 307 | + |
317 | 308 | public static function onLoadExtensionSchemaUpdates() { |
318 | 309 | global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields, |
319 | 310 | $wgExtPGAlteredFields, $wgExtNewIndexes, $wgDBtype; |
320 | 311 | |
321 | 312 | $dir = realpath( dirname( __FILE__ ) . '/..' ); |
322 | | - |
| 313 | + |
323 | 314 | // DB updates |
324 | 315 | $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" ); |
325 | 316 | $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" ); |
326 | 317 | $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" ); |
327 | | - |
| 318 | + |
| 319 | + |
328 | 320 | $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" ); |
329 | 321 | $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" ); |
330 | 322 | $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" ); |
— | — | @@ -334,9 +326,9 @@ |
335 | 327 | $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" ); |
336 | 328 | $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" ); |
337 | 329 | $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" ); |
338 | | - |
| 330 | + |
339 | 331 | $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' ); |
340 | | - |
| 332 | + |
341 | 333 | return true; |
342 | 334 | } |
343 | 335 | } |
Index: trunk/extensions/LiquidThreads/classes/NewMessagesController.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) die; |
4 | 4 | |
5 | 5 | class NewMessages { |
| 6 | + |
6 | 7 | static function markThreadAsUnreadByUser( $thread, $user ) { |
7 | 8 | self::writeUserMessageState( $thread, $user, null ); |
8 | 9 | } |
— | — | @@ -28,17 +29,10 @@ |
29 | 30 | } |
30 | 31 | |
31 | 32 | $dbw = wfGetDB( DB_MASTER ); |
32 | | - |
33 | | - $dbw->replace( |
34 | | - 'user_message_state', |
35 | | - array( array( 'ums_user', 'ums_thread' ) ), |
36 | | - array( |
37 | | - 'ums_user' => $user_id, |
38 | | - 'ums_thread' => $thread_id, |
39 | | - 'ums_read_timestamp' => $timestamp |
40 | | - ), |
41 | | - __METHOD__ |
42 | | - ); |
| 33 | + |
| 34 | + $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), |
| 35 | + array( 'ums_user' => $user_id, 'ums_thread' => $thread_id, |
| 36 | + 'ums_read_timestamp' => $timestamp ), __METHOD__ ); |
43 | 37 | } |
44 | 38 | |
45 | 39 | /** |
— | — | @@ -47,7 +41,7 @@ |
48 | 42 | */ |
49 | 43 | static function writeMessageStateForUpdatedThread( $t, $type, $changeUser ) { |
50 | 44 | global $wgUser; |
51 | | - |
| 45 | + |
52 | 46 | wfDebugLog( 'LiquidThreads', 'Doing notifications' ); |
53 | 47 | |
54 | 48 | $dbw =& wfGetDB( DB_MASTER ); |
— | — | @@ -56,50 +50,40 @@ |
57 | 51 | $root_t = $t->topmostThread()->root()->getTitle(); |
58 | 52 | |
59 | 53 | // Select any applicable watchlist entries for the thread. |
60 | | - $talkpageWhere = array( |
61 | | - 'wl_namespace' => $tpTitle->getNamespace(), |
62 | | - 'wl_title' => $tpTitle->getDBkey() |
63 | | - ); |
64 | | - $rootWhere = array( |
65 | | - 'wl_namespace' => $root_t->getNamespace(), |
66 | | - 'wl_title' => $root_t->getDBkey() |
67 | | - ); |
68 | | - |
| 54 | + $talkpageWhere = array( 'wl_namespace' => $tpTitle->getNamespace(), |
| 55 | + 'wl_title' => $tpTitle->getDBkey() ); |
| 56 | + $rootWhere = array( 'wl_namespace' => $root_t->getNamespace(), |
| 57 | + 'wl_title' => $root_t->getDBkey() ); |
| 58 | + |
69 | 59 | $talkpageWhere = $dbw->makeList( $talkpageWhere, LIST_AND ); |
70 | 60 | $rootWhere = $dbw->makeList( $rootWhere, LIST_AND ); |
71 | | - |
| 61 | + |
72 | 62 | $where_clause = $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR ); |
73 | | - |
| 63 | + |
74 | 64 | // <= 1.15 compatibility, it kinda sucks having to do all this up here. |
75 | 65 | $tables = array( 'watchlist', 'user_message_state' ); |
76 | | - $joins = array( |
77 | | - 'user_message_state' => array( |
78 | | - 'left join', |
79 | | - array( |
80 | | - 'ums_user=wl_user', |
81 | | - 'ums_thread' => $t->id() |
82 | | - ) |
83 | | - ) |
84 | | - ); |
| 66 | + $joins = array( 'user_message_state' => |
| 67 | + array( 'left join', |
| 68 | + array( 'ums_user=wl_user', 'ums_thread' => $t->id() ) ) ); |
85 | 69 | $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' ); |
86 | | - |
| 70 | + |
87 | 71 | $oldPrefCompat = false; |
88 | 72 | global $wgVersion; |
89 | 73 | if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
90 | 74 | $oldPrefCompat = true; |
91 | | - |
| 75 | + |
92 | 76 | $tables[] = 'user'; |
93 | 77 | $joins['user'] = array( 'left join', 'user_id=wl_user' ); |
94 | 78 | $fields[] = 'user_options'; |
95 | 79 | } else { |
96 | 80 | $tables[] = 'user_properties'; |
97 | | - $joins['user_properties'] = array( |
98 | | - 'left join', |
| 81 | + $joins['user_properties'] = |
99 | 82 | array( |
100 | | - 'up_user=wl_user', |
101 | | - 'up_property' => 'lqtnotifytalk' |
102 | | - ) |
103 | | - ); |
| 83 | + 'left join', |
| 84 | + array( 'up_user=wl_user', |
| 85 | + 'up_property' => 'lqtnotifytalk', |
| 86 | + ) |
| 87 | + ); |
104 | 88 | $fields[] = 'up_value'; |
105 | 89 | } |
106 | 90 | |
— | — | @@ -107,83 +91,78 @@ |
108 | 92 | // user_message_state row exists for them, and whether or not to send an email |
109 | 93 | // notification. |
110 | 94 | $dbr = wfGetDB( DB_SLAVE ); |
111 | | - $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins ); |
112 | | - |
| 95 | + $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins); |
| 96 | + |
113 | 97 | $insert_rows = array(); |
114 | 98 | $update_tuples = array(); |
115 | 99 | $notify_users = array(); |
116 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 100 | + while( $row = $dbr->fetchObject( $res ) ) { |
117 | 101 | // Don't notify yourself |
118 | 102 | if ( $changeUser->getId() == $row->wl_user ) |
119 | 103 | continue; |
120 | | - |
| 104 | + |
121 | 105 | if ( $row->ums_user && !$row->ums_read_timestamp ) { |
122 | 106 | // It's already positive. |
123 | 107 | } else { |
124 | | - $insert_rows[] = array( |
125 | | - 'ums_user' => $row->wl_user, |
126 | | - 'ums_thread' => $t->id(), |
127 | | - 'ums_read_timestamp' => null, |
128 | | - ); |
129 | | - |
| 108 | + $insert_rows[] = |
| 109 | + array( |
| 110 | + 'ums_user' => $row->wl_user, |
| 111 | + 'ums_thread' => $t->id(), |
| 112 | + 'ums_read_timestamp' => null, |
| 113 | + ); |
| 114 | + |
130 | 115 | // Set newtalk |
131 | 116 | $u = User::newFromId( $row->wl_user ); |
132 | 117 | $u->setNewtalk( true ); |
133 | 118 | } |
134 | | - |
| 119 | + |
135 | 120 | $wantsTalkNotification = false; |
136 | | - |
| 121 | + |
137 | 122 | if ( $oldPrefCompat ) { |
138 | 123 | $decodedOptions = self::decodeUserOptions( $row->user_options ); |
139 | | - |
140 | | - $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) && |
| 124 | + |
| 125 | + $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) && |
141 | 126 | User::getDefaultOption( 'lqtnotifytalk' ) ) || $row->up_value; |
142 | 127 | } else { |
143 | 128 | $wantsTalkNotification = |
144 | | - ( is_null( $row->up_value ) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
| 129 | + (is_null($row->up_value) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
145 | 130 | || $row->up_value; |
146 | 131 | } |
147 | | - |
| 132 | + |
148 | 133 | if ( $wantsTalkNotification ) { |
149 | 134 | $notify_users[] = $row->wl_user; |
150 | 135 | } |
151 | 136 | } |
152 | | - |
| 137 | + |
153 | 138 | // Add user talk notification |
154 | 139 | if ( $t->article()->getTitle()->getNamespace() == NS_USER_TALK ) { |
155 | 140 | $name = $t->article()->getTitle()->getText(); |
156 | | - |
| 141 | + |
157 | 142 | $user = User::newFromName( $name ); |
158 | 143 | if ( $user ) { |
159 | 144 | $user->setNewtalk( true ); |
160 | | - |
161 | | - $insert_rows[] = array( |
162 | | - 'ums_user' => $user->getId(), |
163 | | - 'ums_thread' => $t->id(), |
164 | | - 'ums_read_timestamp' => null |
165 | | - ); |
166 | | - |
| 145 | + |
| 146 | + $insert_rows[] = array( 'ums_user' => $user->getId(), |
| 147 | + 'ums_thread' => $t->id(), |
| 148 | + 'ums_read_timestamp' => null ); |
| 149 | + |
167 | 150 | if ( $user->getOption( 'enotifusertalkpages' ) ) { |
168 | 151 | $notify_users[] = $user->getId(); |
169 | 152 | } |
170 | 153 | } |
171 | 154 | } |
172 | | - |
| 155 | + |
173 | 156 | // Do the actual updates |
174 | | - if ( count( $insert_rows ) ) { |
175 | | - $dbw->replace( |
176 | | - 'user_message_state', |
177 | | - array( array( 'ums_user', 'ums_thread' ) ), |
178 | | - $insert_rows, |
179 | | - __METHOD__ |
180 | | - ); |
| 157 | + if ( count($insert_rows) ) { |
| 158 | + $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), |
| 159 | + $insert_rows, __METHOD__ ); |
181 | 160 | } |
182 | | - |
183 | | - if ( count( $notify_users ) ) { |
| 161 | + |
| 162 | + if ( count($notify_users) ) { |
184 | 163 | self::notifyUsersByMail( $t, $notify_users, wfTimestampNow(), $type ); |
185 | 164 | } |
186 | 165 | } |
187 | | - |
| 166 | + |
188 | 167 | // Would refactor User::decodeOptions, but the whole point is that this is |
189 | 168 | // compatible with old code :) |
190 | 169 | static function decodeUserOptions( $str ) { |
— | — | @@ -195,10 +174,10 @@ |
196 | 175 | $opts[$m[1]] = $m[2]; |
197 | 176 | } |
198 | 177 | } |
199 | | - |
| 178 | + |
200 | 179 | return $opts; |
201 | 180 | } |
202 | | - |
| 181 | + |
203 | 182 | static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) { |
204 | 183 | wfLoadExtensionMessages( 'LiquidThreads' ); |
205 | 184 | $messages = array( |
— | — | @@ -209,169 +188,148 @@ |
210 | 189 | Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', |
211 | 190 | Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread', |
212 | 191 | ); |
213 | | - |
214 | | - if ( !isset( $messages[$type] ) || !isset( $subjects[$type] ) ) { |
| 192 | + |
| 193 | + if ( !isset($messages[$type]) || !isset($subjects[$type]) ) { |
215 | 194 | wfDebugLog( 'LiquidThreads', "Email notification failed: type $type unrecognised" ); |
216 | 195 | return; |
217 | 196 | } else { |
218 | 197 | $msgName = $messages[$type]; |
219 | 198 | $subjectMsg = $subjects[$type]; |
220 | 199 | } |
221 | | - |
| 200 | + |
222 | 201 | // Send email notification, fetching all the data in one go |
223 | | - |
| 202 | + |
224 | 203 | global $wgVersion; |
225 | 204 | $tables = array( 'user' ); |
226 | 205 | $fields = array( 'user.*' ); |
227 | 206 | $join_conds = array(); |
228 | 207 | $oldPreferenceFormat = false; |
229 | | - if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
| 208 | + if (version_compare( $wgVersion, '1.16', '<' )) { |
230 | 209 | $oldPreferenceFormat = true; |
231 | 210 | } else { |
232 | 211 | $tables[] = 'user_properties as tc_prop'; |
233 | 212 | $fields[] = 'tc_prop.up_value as timecorrection'; |
234 | | - |
| 213 | + |
235 | 214 | $join_conds['user_properties as tc_prop'] = |
236 | | - array( 'left join', |
| 215 | + array( 'left join', |
237 | 216 | array( |
238 | 217 | 'up_user=user_id', |
239 | 218 | 'up_property' => 'timecorrection', |
240 | 219 | ) |
241 | 220 | ); |
242 | | - |
| 221 | + |
243 | 222 | $tables[] = 'user_properties as l_prop'; |
244 | 223 | $fields[] = 'l_prop.up_value as language'; |
245 | | - |
| 224 | + |
246 | 225 | $join_conds['user_properties as l_prop'] = |
247 | | - array( 'left join', |
| 226 | + array( 'left join', |
248 | 227 | array( |
249 | 228 | 'up_user=user_id', |
250 | 229 | 'up_property' => 'language', |
251 | 230 | ) |
252 | 231 | ); |
253 | 232 | } |
254 | | - |
| 233 | + |
255 | 234 | $dbr = wfGetDB( DB_SLAVE ); |
256 | | - $res = $dbr->select( |
257 | | - $tables, |
258 | | - $fields, |
259 | | - array( 'user_id' => $watching_users ), |
260 | | - __METHOD__, |
261 | | - array(), |
262 | | - $join_conds |
263 | | - ); |
264 | | - |
| 235 | + $res = $dbr->select( $tables, $fields, |
| 236 | + array( 'user_id' => $watching_users ), __METHOD__, array(), |
| 237 | + $join_conds |
| 238 | + ); |
| 239 | + |
265 | 240 | // Set up one-time data. |
266 | 241 | $link_title = clone $t->article()->getTitle(); |
267 | | - $link_title->setFragment( '#' . $t->getAnchorName() ); |
| 242 | + $link_title->setFragment( '#'.$t->getAnchorName() ); |
268 | 243 | $permalink = $link_title->getFullURL(); |
269 | 244 | $talkPage = $t->article()->getTitle()->getPrefixedText(); |
270 | 245 | $from = new MailAddress( $wgPasswordSender, 'WikiAdmin' ); |
271 | 246 | $threadSubject = $t->subject(); |
272 | | - |
| 247 | + |
273 | 248 | // Parse content and strip HTML of post content |
274 | 249 | // Doesn't work for some reason (transaction issues?) |
275 | 250 | // $content = $t->root()->getContent(); |
276 | 251 | // global $wgOut; |
277 | 252 | // $html = $wgOut->parse( $content ); |
278 | 253 | // $text = StringUtils::delimiterReplace( '<', '>', '', $html ); |
279 | | - |
280 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
| 254 | + |
| 255 | + while( $row = $dbr->fetchObject( $res ) ) { |
281 | 256 | $u = User::newFromRow( $row ); |
282 | | - |
283 | | - if ( $oldPreferenceFormat ) { |
| 257 | + |
| 258 | + if ($oldPreferenceFormat) { |
284 | 259 | $langCode = $u->getOption( 'language' ); |
285 | | - } elseif ( $row->language ) { |
| 260 | + } elseif ($row->language) { |
286 | 261 | $langCode = $row->language; |
287 | 262 | } else { |
288 | 263 | global $wgLanguageCode; |
289 | 264 | $langCode = $wgLanguageCode; |
290 | 265 | } |
291 | | - |
| 266 | + |
292 | 267 | $lang = Language::factory( $langCode ); |
293 | | - |
| 268 | + |
294 | 269 | // Adjust with time correction |
295 | | - if ( $oldPreferenceFormat ) { |
| 270 | + if ($oldPreferenceFormat) { |
296 | 271 | $timeCorrection = $u->getOption( 'timecorrection' ); |
297 | 272 | } else { |
298 | 273 | $timeCorrection = $row->timecorrection; |
299 | 274 | } |
300 | 275 | $adjustedTimestamp = $lang->userAdjust( $timestamp, $timeCorrection ); |
301 | | - |
| 276 | + |
302 | 277 | $date = $lang->date( $adjustedTimestamp ); |
303 | 278 | $time = $lang->time( $adjustedTimestamp ); |
304 | | - |
| 279 | + |
305 | 280 | $params = array( $u->getName(), $t->subjectWithoutIncrement(), |
306 | 281 | $date, $time, $talkPage, $permalink ); |
307 | | - |
| 282 | + |
308 | 283 | // Get message in user's own language, bug 20645 |
309 | 284 | $msg = wfMsgReal( $msgName, $params, true /* use DB */, $langCode, |
310 | 285 | true /*transform*/ ); |
311 | | - |
| 286 | + |
312 | 287 | global $wgPasswordSender; |
313 | | - |
| 288 | + |
314 | 289 | $to = new MailAddress( $u ); |
315 | | - $subject = wfMsgReal( $subjectMsg, array( $threadSubject ), true /* use DB */, |
316 | | - $langCode, true /* transform */ ); |
317 | | - |
| 290 | + $subject = wfMsgReal( $subjectMsg, array($threadSubject), true /* use DB */, |
| 291 | + $langCode, true /* transform */); |
| 292 | + |
318 | 293 | UserMailer::send( $to, $from, $subject, $msg ); |
319 | 294 | } |
320 | 295 | } |
321 | 296 | |
322 | 297 | static function newUserMessages( $user ) { |
323 | 298 | $talkPage = new Article( $user->getUserPage()->getTalkPage() ); |
324 | | - |
| 299 | + |
325 | 300 | $dbr = wfGetDB( DB_SLAVE ); |
326 | | - |
| 301 | + |
327 | 302 | $joinConds = array( 'ums_user' => null ); |
328 | | - $joinConds[] = $dbr->makeList( |
329 | | - array( |
330 | | - 'ums_user' => $user->getId(), |
331 | | - 'ums_thread=thread_id' |
332 | | - ), |
333 | | - LIST_AND |
334 | | - ); |
| 303 | + $joinConds[] = $dbr->makeList( array( 'ums_user' => $user->getId(), |
| 304 | + 'ums_thread=thread_id' ), LIST_AND ); |
335 | 305 | $joinClause = $dbr->makeList( $joinConds, LIST_OR ); |
336 | | - |
337 | | - $res = $dbr->select( |
338 | | - array( 'thread', 'user_message_state' ), |
339 | | - '*', |
340 | | - array( |
341 | | - 'ums_read_timestamp' => null, |
342 | | - Threads::articleClause( $talkPage ) |
343 | | - ), |
344 | | - __METHOD__, |
345 | | - array(), |
346 | | - array( |
347 | | - 'user_message_state' => |
348 | | - array( 'LEFT OUTER JOIN', $joinClause ) |
349 | | - ) |
350 | | - ); |
351 | | - |
| 306 | + |
| 307 | + $res = $dbr->select( array( 'thread', 'user_message_state' ), '*', |
| 308 | + array( 'ums_read_timestamp' => null, |
| 309 | + Threads::articleClause( $talkPage ) ), |
| 310 | + __METHOD__, array(), |
| 311 | + array( |
| 312 | + 'user_message_state' => |
| 313 | + array( 'LEFT OUTER JOIN', $joinClause ) |
| 314 | + ) ); |
| 315 | + |
352 | 316 | return Threads::loadFromResult( $res, $dbr ); |
353 | 317 | } |
354 | 318 | |
355 | 319 | static function watchedThreadsForUser( $user ) { |
356 | 320 | $talkPage = new Article( $user->getUserPage()->getTalkPage() ); |
357 | | - |
| 321 | + |
358 | 322 | $dbr = wfGetDB( DB_SLAVE ); |
359 | | - |
360 | | - $res = $dbr->select( |
361 | | - array( 'thread', 'user_message_state' ), |
362 | | - '*', |
363 | | - array( |
364 | | - 'ums_read_timestamp' => null, |
365 | | - 'ums_user' => $user->getId(), |
366 | | - 'not (' . Threads::articleClause( $talkPage ) . ')', |
367 | | - ), |
368 | | - __METHOD__, |
369 | | - array(), |
370 | | - array( |
371 | | - 'user_message_state' => |
372 | | - array( 'INNER JOIN', 'ums_thread=thread_id' ), |
373 | | - ) |
374 | | - ); |
375 | | - |
| 323 | + |
| 324 | + $res = $dbr->select( array( 'thread', 'user_message_state' ), '*', |
| 325 | + array( 'ums_read_timestamp' => null, |
| 326 | + 'ums_user' => $user->getId(), |
| 327 | + 'not (' . Threads::articleClause( $talkPage ) . ')', |
| 328 | + ), |
| 329 | + __METHOD__, array(), |
| 330 | + array( 'user_message_state' => |
| 331 | + array( 'INNER JOIN', 'ums_thread=thread_id' ), |
| 332 | + ) ); |
| 333 | + |
376 | 334 | return Threads::loadFromResult( $res, $dbr ); |
377 | 335 | } |
378 | 336 | } |
Index: trunk/extensions/LiquidThreads/classes/ThreadRevision.php |
— | — | @@ -6,157 +6,157 @@ |
7 | 7 | array( |
8 | 8 | 'th_id' => 'mId', |
9 | 9 | 'th_thread' => 'mThreadId', |
10 | | - |
| 10 | + |
11 | 11 | 'th_timestamp' => 'mTimestamp', |
12 | | - |
| 12 | + |
13 | 13 | 'th_user' => 'mUserId', |
14 | 14 | 'th_user_text' => 'mUserText', |
15 | | - |
| 15 | + |
16 | 16 | 'th_change_type' => 'mChangeType', |
17 | 17 | 'th_change_object' => 'mChangeObjectId', |
18 | 18 | 'th_change_comment' => 'mChangeComment', |
19 | 19 | 'th_content' => 'mObjSer', |
20 | 20 | ); |
21 | | - |
| 21 | + |
22 | 22 | protected $mId, $mThreadId, $mTimestamp, $mUserId, $mUserText, $mChangeType, |
23 | 23 | $mChangeObjectId, $mChangeObject, $mChangeComment, $mObjSer, $mThreadObj; |
24 | | - |
| 24 | + |
25 | 25 | static function loadFromId( $id ) { |
26 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
27 | 27 | $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' => $id ), __METHOD__ ); |
28 | | - |
| 28 | + |
29 | 29 | return self::loadFromRow( $row ); |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | static function loadFromRow( $row ) { |
33 | 33 | $rev = new ThreadRevision; |
34 | | - |
35 | | - foreach ( self::$load as $col => $field ) { |
| 34 | + |
| 35 | + foreach( self::$load as $col => $field ) { |
36 | 36 | $rev->$field = $row->$col; |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | $rev->mUser = User::newFromName( $rev->mUserText, /* Don't validate */ false ); |
40 | 40 | $rev->mThreadObj = unserialize( $rev->mObjSer ); |
41 | | - |
| 41 | + |
42 | 42 | return $rev; |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | static function create( $thread, $change_type, $change_object = null, $comment = '', |
46 | 46 | $user = null, $timestamp = null ) { |
47 | | - if ( is_null( $user ) ) { |
| 47 | + if ( is_null($user) ) { |
48 | 48 | global $wgUser; |
49 | 49 | $user = $wgUser; |
50 | 50 | } |
51 | | - |
52 | | - if ( is_null( $timestamp ) ) { |
| 51 | + |
| 52 | + if ( is_null($timestamp) ) { |
53 | 53 | $timestamp = wfTimestampNow(); |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | $rev = new ThreadRevision; |
57 | | - |
| 57 | + |
58 | 58 | $rev->mThreadId = $thread->topmostThread()->id(); |
59 | 59 | $rev->mTimestamp = $timestamp; |
60 | | - |
| 60 | + |
61 | 61 | $rev->mUser = $user; |
62 | 62 | $rev->mUserId = $user->getId(); |
63 | 63 | $rev->mUserText = $user->getName(); |
64 | | - |
| 64 | + |
65 | 65 | $rev->mChangeType = $change_type; |
66 | | - |
| 66 | + |
67 | 67 | if ( $change_object instanceof Thread ) { |
68 | 68 | $rev->mChangeObjectId = $change_object->id(); |
69 | 69 | $rev->mChangeObject = $change_object; |
70 | | - } elseif ( is_null( $change_object ) ) { |
| 70 | + } elseif ( is_null($change_object) ) { |
71 | 71 | $rev->mChangeObjectId = $thread->id(); |
72 | 72 | $rev->mChangeObject = $thread; |
73 | 73 | } else { |
74 | 74 | $rev->mChangeObjectId = $change_object; |
75 | 75 | } |
76 | | - |
| 76 | + |
77 | 77 | $rev->mChangeComment = $comment; |
78 | | - |
| 78 | + |
79 | 79 | $rev->mThreadObj = $thread->topmostThread(); |
80 | 80 | $rev->mObjSer = serialize( $rev->mThreadObj ); |
81 | | - |
| 81 | + |
82 | 82 | $rev->insert(); |
83 | | - |
| 83 | + |
84 | 84 | return $rev; |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | function insert() { |
88 | 88 | $dbw = wfGetDB( DB_MASTER ); |
89 | | - |
| 89 | + |
90 | 90 | $row = $this->getRow(); |
91 | 91 | $row['th_id'] = $dbw->nextSequenceValue( 'thread_history_th_id' ); |
92 | | - |
| 92 | + |
93 | 93 | $dbw->insert( 'thread_history', $row, __METHOD__ ); |
94 | | - |
| 94 | + |
95 | 95 | $this->mId = $dbw->insertId(); |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | function save() { |
99 | 99 | $row = $this->getRow(); |
100 | | - |
| 100 | + |
101 | 101 | $dbw = wfGetDB( DB_MASTER ); |
102 | | - |
| 102 | + |
103 | 103 | $dbw->replace( 'thread_history', array( 'th_thread' ), $row, __METHOD__ ); |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | function getRow() { |
107 | 107 | $row = array(); |
108 | | - |
| 108 | + |
109 | 109 | // First, prep the data for insertion |
110 | 110 | $dbw = wfGetDB( DB_MASTER ); |
111 | 111 | $this->mTimestamp = $dbw->timestamp( $this->mTimestamp ); |
112 | | - |
113 | | - foreach ( self::$load as $col => $field ) { |
| 112 | + |
| 113 | + foreach( self::$load as $col => $field ) { |
114 | 114 | $row[$col] = $this->$field; |
115 | 115 | } |
116 | | - |
| 116 | + |
117 | 117 | return $row; |
118 | 118 | } |
119 | | - |
| 119 | + |
120 | 120 | function getTimestamp() { |
121 | 121 | return wfTimestamp( TS_MW, $this->mTimestamp ); |
122 | 122 | } |
123 | | - |
| 123 | + |
124 | 124 | function getUser() { |
125 | | - if ( $this->mUserId ) { |
| 125 | + if ($this->mUserId) { |
126 | 126 | return User::newFromId( $this->mUserId ); |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | return User::newFromText( $this->mUserText, /* No validation */ false ); |
130 | 130 | } |
131 | | - |
| 131 | + |
132 | 132 | function getChangeType() { |
133 | 133 | return $this->mChangeType; |
134 | 134 | } |
135 | | - |
| 135 | + |
136 | 136 | function getChangeObject() { |
137 | 137 | if ( !$this->mChangeObject && $this->mChangeObjectId ) { |
138 | 138 | $this->mChangeObject = Threads::withId( $this->mChangeObjectId ); |
139 | 139 | } |
140 | | - |
| 140 | + |
141 | 141 | return $this->mChangeObject; |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | function getChangeComment() { |
145 | 145 | return $this->mChangeComment; |
146 | 146 | } |
147 | | - |
| 147 | + |
148 | 148 | function getId() { |
149 | 149 | return $this->mId; |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | function getThreadObj() { |
153 | 153 | if ( !$this->mThreadObj && $this->mObjSer ) { |
154 | 154 | $this->mThreadObj = unserialize( $this->mObjSer ); |
155 | | - } elseif ( !$this->mThreadObj ) { |
| 155 | + } elseif (!$this->mThreadObj) { |
156 | 156 | throw new MWException( "Missing mObjSer" ); |
157 | 157 | } |
158 | | - |
| 158 | + |
159 | 159 | $this->mThreadObj->threadRevision = $this; |
160 | | - |
| 160 | + |
161 | 161 | return $this->mThreadObj; |
162 | 162 | } |
163 | 163 | } |
Index: trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | $this->request = $wgRequest; |
28 | 28 | |
29 | 29 | $this->setHeaders(); |
30 | | - |
| 30 | + |
31 | 31 | $article = new Article( $this->getTitle() ); |
32 | 32 | $title = $this->getTitle(); |
33 | 33 | |
— | — | @@ -42,27 +42,21 @@ |
43 | 43 | $wgOut->addWikitext( wfMsg( 'lqt-no-new-messages' ) ); |
44 | 44 | return; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | $html = ''; |
48 | | - |
| 48 | + |
49 | 49 | $html .= $view->getReadAllButton( $both_sets ); |
50 | 50 | |
51 | 51 | $view->setHeaderLevel( 3 ); |
52 | 52 | |
53 | | - $html .= Xml::tags( |
54 | | - 'h2', |
55 | | - array( 'class' => 'lqt_newmessages_section' ), |
56 | | - wfMsgExt( 'lqt-messages-sent', 'parseinline' ) |
57 | | - ); |
| 53 | + $html .= Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ), |
| 54 | + wfMsgExt( 'lqt-messages-sent', 'parseinline' ) ); |
58 | 55 | $wgOut->addHTML( $html ); |
59 | 56 | $view->setThreads( $first_set ); |
60 | 57 | $view->show(); |
61 | 58 | |
62 | | - $wgOut->addHTML( Xml::tags( |
63 | | - 'h2', |
64 | | - array( 'class' => 'lqt_newmessages_section' ), |
65 | | - wfMsgExt( 'lqt-other-messages', 'parseinline' ) |
66 | | - ) ); |
| 59 | + $wgOut->addHTML( Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ), |
| 60 | + wfMsgExt( 'lqt-other-messages', 'parseinline' ) ) ); |
67 | 61 | $view->setThreads( $second_set ); |
68 | 62 | $view->show(); |
69 | 63 | } |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | function showHeader() { |
22 | 22 | /* Show the contents of the actual talkpage article if it exists. */ |
23 | | - |
| 23 | + |
24 | 24 | global $wgUser; |
25 | 25 | $sk = $wgUser->getSkin(); |
26 | 26 | |
— | — | @@ -32,124 +32,107 @@ |
33 | 33 | // when the first thread was posted to make the links blue. |
34 | 34 | if ( $article->exists() && $article->getContent() ) { |
35 | 35 | $html = ''; |
36 | | - |
| 36 | + |
37 | 37 | $article->view(); |
38 | | - |
| 38 | + |
39 | 39 | $actionLinks = array(); |
40 | | - $actionLinks[] = $sk->link( |
41 | | - $this->title, |
42 | | - wfMsgExt( 'edit', 'parseinline' ) . "↑", |
43 | | - array(), |
44 | | - array( 'action' => 'edit' ) |
45 | | - ); |
46 | | - $actionLinks[] = $sk->link( |
47 | | - $this->title, |
48 | | - wfMsgExt( 'history_short', 'parseinline' ) . "↑", |
49 | | - array(), |
50 | | - array( 'action' => 'history' ) |
51 | | - ); |
52 | | - |
| 40 | + $actionLinks[] = $sk->link( $this->title, |
| 41 | + wfMsgExt( 'edit', 'parseinline' ) . "↑", |
| 42 | + array(), array( 'action' => 'edit' ) ); |
| 43 | + $actionLinks[] = $sk->link( $this->title, |
| 44 | + wfMsgExt( 'history_short', 'parseinline' ) . "↑", |
| 45 | + array(), array( 'action' => 'history' ) ); |
| 46 | + |
53 | 47 | if ( $wgUser->isAllowed( 'delete' ) ) { |
54 | | - $actionLinks[] = $sk->link( |
55 | | - $this->title, |
56 | | - wfMsgExt( 'delete', 'parseinline' ) . '↑', |
57 | | - array(), |
58 | | - array( 'action' => 'delete' ) |
59 | | - ); |
| 48 | + $actionLinks[] = $sk->link( $this->title, |
| 49 | + wfMsgExt( 'delete', 'parseinline' ) . '↑', |
| 50 | + array(), array( 'action' => 'delete' ) ); |
60 | 51 | } |
61 | | - |
| 52 | + |
62 | 53 | $actions = ''; |
63 | | - foreach ( $actionLinks as $link ) { |
| 54 | + foreach( $actionLinks as $link ) { |
64 | 55 | $actions .= Xml::tags( 'li', null, "[$link]" ) . "\n"; |
65 | 56 | } |
66 | 57 | $actions = Xml::tags( 'ul', array( 'class' => 'lqt_header_commands' ), $actions ); |
67 | 58 | $html .= $actions; |
68 | 59 | |
69 | 60 | $html = Xml::tags( 'div', array( 'class' => 'lqt_header_content' ), $html ); |
70 | | - |
| 61 | + |
71 | 62 | $this->output->addHTML( $html ); |
72 | 63 | } else { |
73 | | - |
74 | | - $editLink = $sk->link( |
75 | | - $this->title, |
76 | | - wfMsgExt( 'lqt_add_header', 'parseinline' ), |
77 | | - array(), |
78 | | - array( 'action' => 'edit' ) |
79 | | - ); |
80 | | - |
| 64 | + |
| 65 | + $editLink = $sk->link( $this->title, wfMsgExt( 'lqt_add_header', 'parseinline' ), |
| 66 | + array(), array( 'action' => 'edit' ) ); |
| 67 | + |
81 | 68 | $html = Xml::tags( 'p', array( 'class' => 'lqt_header_notice' ), "[$editLink]" ); |
82 | | - |
| 69 | + |
83 | 70 | $this->output->addHTML( $html ); |
84 | 71 | } |
85 | 72 | } |
86 | | - |
| 73 | + |
87 | 74 | function getTOC( $threads ) { |
88 | 75 | global $wgLang; |
89 | | - |
| 76 | + |
90 | 77 | wfLoadExtensionMessages( 'LiquidThreads' ); |
91 | 78 | |
92 | 79 | $sk = $this->user->getSkin(); |
93 | | - |
| 80 | + |
94 | 81 | $html = ''; |
95 | | - |
| 82 | + |
96 | 83 | $h2_header = Xml::tags( 'h2', null, wfMsgExt( 'lqt_contents_title', 'parseinline' ) ); |
97 | | - |
| 84 | + |
98 | 85 | // Header row |
99 | 86 | $headerRow = ''; |
100 | | - $headers = array( |
101 | | - 'lqt_toc_thread_title', |
102 | | - 'lqt_toc_thread_author', |
103 | | - 'lqt_toc_thread_replycount', |
104 | | - 'lqt_toc_thread_modified' |
105 | | - ); |
106 | | - foreach ( $headers as $msg ) { |
| 87 | + $headers = array( 'lqt_toc_thread_title', 'lqt_toc_thread_author', |
| 88 | + 'lqt_toc_thread_replycount', 'lqt_toc_thread_modified' ); |
| 89 | + foreach( $headers as $msg ) { |
107 | 90 | $headerRow .= Xml::tags( 'th', null, wfMsgExt( $msg, 'parseinline' ) ); |
108 | 91 | } |
109 | 92 | $headerRow = Xml::tags( 'tr', null, $headerRow ); |
110 | 93 | $headerRow = Xml::tags( 'thead', null, $headerRow ); |
111 | | - |
| 94 | + |
112 | 95 | // Table body |
113 | 96 | $rows = array(); |
114 | | - foreach ( $threads as $thread ) { |
| 97 | + foreach( $threads as $thread ) { |
115 | 98 | $row = ''; |
116 | | - $anchor = '#' . $this->anchorName( $thread ); |
| 99 | + $anchor = '#'.$this->anchorName( $thread ); |
117 | 100 | $subject = $this->output->parseInline( $thread->subjectWithoutIncrement() ); |
118 | 101 | $subject = Xml::tags( 'a', array( 'href' => $anchor ), $subject ); |
119 | 102 | $row .= Xml::tags( 'td', null, $subject ); |
120 | | - |
| 103 | + |
121 | 104 | $author = $thread->author(); |
122 | 105 | $authorLink = $sk->userLink( $author->getId(), $author->getName() ); |
123 | 106 | $row .= Xml::tags( 'td', null, $authorLink ); |
124 | | - |
| 107 | + |
125 | 108 | $row .= Xml::element( 'td', null, count( $thread->replies() ) ); |
126 | | - |
| 109 | + |
127 | 110 | $timestamp = $wgLang->timeanddate( $thread->modified(), true ); |
128 | 111 | $row .= Xml::element( 'td', null, $timestamp ); |
129 | | - |
| 112 | + |
130 | 113 | $row = Xml::tags( 'tr', null, $row ); |
131 | 114 | $rows[] = $row; |
132 | 115 | } |
133 | | - |
| 116 | + |
134 | 117 | $html .= $headerRow . "\n" . Xml::tags( 'tbody', null, implode( "\n", $rows ) ); |
135 | 118 | $html = $h2_header . Xml::tags( 'table', array( 'class' => 'lqt_toc' ), $html ); |
136 | | - |
| 119 | + |
137 | 120 | return $html; |
138 | 121 | } |
139 | | - |
| 122 | + |
140 | 123 | function getList( $kind, $class, $id, $contents ) { |
141 | 124 | $html = ''; |
142 | 125 | foreach ( $contents as $li ) { |
143 | 126 | $html .= Xml::tags( 'li', null, $li ); |
144 | 127 | } |
145 | 128 | $html = Xml::tags( $kind, array( 'class' => $class, 'id' => $id ), $html ); |
146 | | - |
| 129 | + |
147 | 130 | return $html; |
148 | 131 | } |
149 | 132 | |
150 | 133 | function getArchiveWidget( ) { |
151 | 134 | wfLoadExtensionMessages( 'LiquidThreads' ); |
152 | 135 | $url = $this->talkpageUrl( $this->title, 'talkpage_archive' ); |
153 | | - |
| 136 | + |
154 | 137 | $html = ''; |
155 | 138 | $html = Xml::tags( 'div', array( 'class' => 'lqt_archive_teaser' ), $html ); |
156 | 139 | return $html; |
— | — | @@ -161,44 +144,32 @@ |
162 | 145 | if ( $article->exists() ) { |
163 | 146 | $form_action_url = $this->talkpageUrl( $this->title, 'talkpage_sort_order' ); |
164 | 147 | $go = wfMsg( 'go' ); |
165 | | - |
| 148 | + |
166 | 149 | $html = ''; |
167 | | - |
| 150 | + |
168 | 151 | $html .= Xml::label( wfMsg( 'lqt_sorting_order' ), 'lqt_sort_select' ) . ' '; |
169 | 152 | |
170 | 153 | $sortOrderSelect = |
171 | 154 | new XmlSelect( 'lqt_order', 'lqt_sort_select', $this->getSortType() ); |
172 | | - |
| 155 | + |
173 | 156 | $sortOrderSelect->setAttribute( 'class', 'lqt_sort_select' ); |
174 | | - $sortOrderSelect->addOption( |
175 | | - wfMsg( 'lqt_sort_newest_changes' ), |
176 | | - LQT_NEWEST_CHANGES |
177 | | - ); |
178 | | - $sortOrderSelect->addOption( |
179 | | - wfMsg( 'lqt_sort_newest_threads' ), |
180 | | - LQT_NEWEST_THREADS |
181 | | - ); |
182 | | - $sortOrderSelect->addOption( |
183 | | - wfMsg( 'lqt_sort_oldest_threads' ), |
184 | | - LQT_OLDEST_THREADS |
185 | | - ); |
| 157 | + $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_changes' ), |
| 158 | + LQT_NEWEST_CHANGES ); |
| 159 | + $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_threads' ), |
| 160 | + LQT_NEWEST_THREADS ); |
| 161 | + $sortOrderSelect->addOption( wfMsg( 'lqt_sort_oldest_threads' ), |
| 162 | + LQT_OLDEST_THREADS ); |
186 | 163 | $html .= $sortOrderSelect->getHTML(); |
187 | | - |
| 164 | + |
188 | 165 | $html .= Xml::submitButton( wfMsg( 'go' ), array( 'class' => 'lqt_go_sort' ) ); |
189 | 166 | $html .= Xml::hidden( 'title', $this->title->getPrefixedText() ); |
190 | | - |
191 | | - |
192 | | - $html = Xml::tags( |
193 | | - 'form', |
194 | | - array( |
195 | | - 'action' => $form_action_url, |
196 | | - 'method' => 'get', |
197 | | - 'name' => 'lqt_sort' |
198 | | - ), |
199 | | - $html |
200 | | - ); |
| 167 | + |
| 168 | + |
| 169 | + $html = Xml::tags( 'form', array( 'action' => $form_action_url, |
| 170 | + 'method' => 'get', |
| 171 | + 'name' => 'lqt_sort' ), $html ); |
201 | 172 | $html = Xml::tags( 'div', array( 'class' => 'lqt_view_options' ), $html ); |
202 | | - |
| 173 | + |
203 | 174 | return $html; |
204 | 175 | } |
205 | 176 | } |
— | — | @@ -211,62 +182,54 @@ |
212 | 183 | |
213 | 184 | $this->output->setPageTitle( $this->title->getPrefixedText() ); |
214 | 185 | self::addJSandCSS(); |
215 | | - |
| 186 | + |
216 | 187 | $sk = $this->user->getSkin(); |
217 | | - |
| 188 | + |
218 | 189 | $article = new Article( $this->title ); |
219 | | - |
| 190 | + |
220 | 191 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
221 | 192 | $this->doInlineEditForm(); |
222 | 193 | return false; |
223 | 194 | } |
224 | | - |
| 195 | + |
225 | 196 | // Search! |
226 | 197 | if ( $this->request->getCheck( 'lqt_search' ) ) { |
227 | 198 | $q = $this->request->getText( 'lqt_search' ); |
228 | | - $q .= ' ondiscussionpage:' . $article->getTitle()->getPrefixedText(); |
229 | | - |
230 | | - $params = array( |
231 | | - 'search' => $q, |
232 | | - 'fulltext' => 1, |
233 | | - 'ns' . NS_LQT_THREAD => 1, |
234 | | - ); |
235 | | - |
| 199 | + $q .= ' ondiscussionpage:'.$article->getTitle()->getPrefixedText(); |
| 200 | + |
| 201 | + $params = array( 'search' => $q, |
| 202 | + 'fulltext' => 1, |
| 203 | + 'ns'.NS_LQT_THREAD => 1, |
| 204 | + ); |
| 205 | + |
236 | 206 | $t = SpecialPage::getTitleFor( 'Search' ); |
237 | 207 | $url = $t->getLocalURL( wfArrayToCGI( $params ) ); |
238 | | - |
| 208 | + |
239 | 209 | $this->output->redirect( $url ); |
| 210 | + |
240 | 211 | } |
241 | 212 | |
242 | 213 | $this->showHeader(); |
243 | | - |
| 214 | + |
244 | 215 | $html = ''; |
245 | | - |
| 216 | + |
246 | 217 | // Set up a per-page header for new threads, search box, and sorting stuff. |
247 | | - |
| 218 | + |
248 | 219 | $talkpageHeader = ''; |
249 | | - |
| 220 | + |
250 | 221 | $newThreadText = wfMsgExt( 'lqt_new_thread', 'parseinline' ); |
251 | | - $newThreadLink = $sk->link( |
252 | | - $this->title, $newThreadText, |
253 | | - array(), |
254 | | - array( 'lqt_method' => 'talkpage_new_thread' ), |
255 | | - array( 'known' ) |
256 | | - ); |
257 | | - |
258 | | - $talkpageHeader .= Xml::tags( |
259 | | - 'strong', |
260 | | - array( 'class' => 'lqt_start_discussion' ), |
261 | | - $newThreadLink |
262 | | - ); |
| 222 | + $newThreadLink = $sk->link( $this->title, $newThreadText, |
| 223 | + array( ), |
| 224 | + array( 'lqt_method' => 'talkpage_new_thread' ), |
| 225 | + array( 'known' ) ); |
| 226 | + |
| 227 | + $talkpageHeader .= Xml::tags( 'strong', array( 'class' => 'lqt_start_discussion' ), |
| 228 | + $newThreadLink ); |
263 | 229 | $talkpageHeader .= $this->getSearchBox(); |
264 | 230 | $talkpageHeader .= $this->showTalkpageViewOptions( $article ); |
265 | | - $talkpageHeader = Xml::tags( |
266 | | - 'div', |
267 | | - array( 'class' => 'lqt-talkpage-header' ), |
268 | | - $talkpageHeader |
269 | | - ); |
270 | | - |
| 231 | + $talkpageHeader = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-header' ), |
| 232 | + $talkpageHeader ); |
| 233 | + |
271 | 234 | $this->output->addHTML( $talkpageHeader ); |
272 | 235 | |
273 | 236 | global $wgRequest; |
— | — | @@ -279,71 +242,63 @@ |
280 | 243 | $this->output->addHTML( Xml::tags( 'div', |
281 | 244 | array( 'class' => 'lqt-new-thread lqt-edit-form' ), '' ) ); |
282 | 245 | } |
283 | | - |
| 246 | + |
284 | 247 | $pager = $this->getPager(); |
285 | | - |
| 248 | + |
286 | 249 | $threads = $this->getPageThreads( $pager ); |
287 | 250 | |
288 | | - if ( count( $threads ) > 0 ) { |
| 251 | + if ( count($threads) > 0 ) { |
289 | 252 | $html .= Xml::element( 'br', array( 'style' => 'clear: both;' ) ); |
290 | 253 | $html .= $this->getTOC( $threads ); |
291 | 254 | } else { |
292 | 255 | $html .= wfMsgExt( 'lqt-no-threads', 'parseinline' ); |
293 | 256 | } |
294 | | - |
| 257 | + |
295 | 258 | $html .= $pager->getNavigationBar(); |
296 | | - |
| 259 | + |
297 | 260 | $this->output->addHTML( $html ); |
298 | 261 | |
299 | 262 | foreach ( $threads as $t ) { |
300 | 263 | $this->showThread( $t ); |
301 | 264 | } |
302 | | - |
| 265 | + |
303 | 266 | $this->output->addHTML( $pager->getNavigationBar() ); |
304 | | - |
| 267 | + |
305 | 268 | return false; |
306 | 269 | } |
307 | | - |
| 270 | + |
308 | 271 | function getSearchBox() { |
309 | 272 | $html = ''; |
310 | | - $html .= Xml::inputLabel( |
311 | | - wfMsg( 'lqt-search-label' ), |
312 | | - 'lqt_search', |
313 | | - 'lqt-search-box', |
314 | | - 45 |
315 | | - ); |
316 | | - |
| 273 | + $html .= Xml::inputLabel( wfMsg('lqt-search-label'), 'lqt_search', 'lqt-search-box', |
| 274 | + 45 ); |
| 275 | + |
317 | 276 | $html .= ' ' . Xml::submitButton( wfMsg( 'lqt-search-button' ) ); |
318 | 277 | $html .= Xml::hidden( 'title', $this->title->getPrefixedText() ); |
319 | | - $html = Xml::tags( |
320 | | - 'form', |
321 | | - array( |
322 | | - 'action' => $this->title->getLocalURL(), |
323 | | - 'method' => 'get' |
324 | | - ), |
325 | | - $html |
326 | | - ); |
327 | | - |
| 278 | + $html = Xml::tags( 'form', |
| 279 | + array( 'action' => $this->title->getLocalURL(), |
| 280 | + 'method' => 'get' ), |
| 281 | + $html ); |
| 282 | + |
328 | 283 | # $html = Xml::fieldset( wfMsg('lqt-search-legend' ), $html, |
329 | 284 | # array( 'class' => 'lqt-talkpage-search' ) ); |
330 | 285 | |
331 | 286 | $html = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-search' ), $html ); |
332 | | - |
| 287 | + |
333 | 288 | return $html; |
334 | 289 | } |
335 | | - |
| 290 | + |
336 | 291 | function getPager() { |
337 | | - |
| 292 | + |
338 | 293 | $sortType = $this->getSortType(); |
339 | 294 | return new LqtDiscussionPager( $this->article, $sortType ); |
340 | 295 | } |
341 | | - |
| 296 | + |
342 | 297 | function getPageThreads( $pager ) { |
343 | 298 | $rows = $pager->getRows(); |
344 | | - |
| 299 | + |
345 | 300 | return Thread::bulkLoad( $rows ); |
346 | 301 | } |
347 | | - |
| 302 | + |
348 | 303 | function getSortType() { |
349 | 304 | // Determine sort order |
350 | 305 | if ( $this->request->getCheck( 'lqt_order' ) ) { |
— | — | @@ -358,7 +313,7 @@ |
359 | 314 | return LQT_OLDEST_THREADS; |
360 | 315 | } |
361 | 316 | } |
362 | | - |
| 317 | + |
363 | 318 | // Default |
364 | 319 | return LQT_NEWEST_CHANGES; |
365 | 320 | } |
— | — | @@ -369,37 +324,39 @@ |
370 | 325 | function __construct( $article, $orderType ) { |
371 | 326 | $this->article = $article; |
372 | 327 | $this->orderType = $orderType; |
373 | | - |
| 328 | + |
374 | 329 | parent::__construct(); |
375 | | - |
| 330 | + |
376 | 331 | $this->mLimit = 20; |
377 | 332 | } |
378 | | - |
| 333 | + |
379 | 334 | function getQueryInfo() { |
380 | | - $queryInfo = array( |
381 | | - 'tables' => array( 'thread' ), |
382 | | - 'fields' => '*', |
383 | | - 'conds' => array( |
384 | | - Threads::articleClause( $this->article ), |
385 | | - Threads::topLevelClause(), |
386 | | - 'thread_type != ' . $this->mDb->addQuotes( Threads::TYPE_DELETED ), |
387 | | - ), |
388 | | - ); |
389 | | - |
| 335 | + $queryInfo = |
| 336 | + array( |
| 337 | + 'tables' => array( 'thread' ), |
| 338 | + 'fields' => '*', |
| 339 | + 'conds' => |
| 340 | + array( |
| 341 | + Threads::articleClause( $this->article ), |
| 342 | + Threads::topLevelClause(), |
| 343 | + 'thread_type != '. $this->mDb->addQuotes( Threads::TYPE_DELETED ), |
| 344 | + ), |
| 345 | + ); |
| 346 | + |
390 | 347 | return $queryInfo; |
391 | 348 | } |
392 | | - |
| 349 | + |
393 | 350 | // Adapted from getBody(). |
394 | 351 | function getRows() { |
395 | 352 | if ( !$this->mQueryDone ) { |
396 | 353 | $this->doQuery(); |
397 | 354 | } |
398 | | - |
| 355 | + |
399 | 356 | # Don't use any extra rows returned by the query |
400 | 357 | $numRows = min( $this->mResult->numRows(), $this->mLimit ); |
401 | 358 | |
402 | 359 | $rows = array(); |
403 | | - |
| 360 | + |
404 | 361 | if ( $numRows ) { |
405 | 362 | if ( $this->mIsBackwards ) { |
406 | 363 | for ( $i = $numRows - 1; $i >= 0; $i-- ) { |
— | — | @@ -415,14 +372,14 @@ |
416 | 373 | } |
417 | 374 | } |
418 | 375 | } |
419 | | - |
| 376 | + |
420 | 377 | return $rows; |
421 | 378 | } |
422 | | - |
| 379 | + |
423 | 380 | function formatRow( $row ) { |
424 | 381 | // No-op, we get the list of rows from getRows() |
425 | 382 | } |
426 | | - |
| 383 | + |
427 | 384 | function getIndexField() { |
428 | 385 | switch( $this->orderType ) { |
429 | 386 | case LQT_NEWEST_CHANGES: |
— | — | @@ -431,10 +388,10 @@ |
432 | 389 | case LQT_NEWEST_THREADS: |
433 | 390 | return 'thread_created'; |
434 | 391 | default: |
435 | | - throw new MWException( "Unknown sort order " . $this->orderType ); |
| 392 | + throw new MWException( "Unknown sort order ".$this->orderType ); |
436 | 393 | } |
437 | 394 | } |
438 | | - |
| 395 | + |
439 | 396 | function getDefaultDirections() { |
440 | 397 | switch( $this->orderType ) { |
441 | 398 | case LQT_NEWEST_CHANGES: |
— | — | @@ -443,10 +400,10 @@ |
444 | 401 | case LQT_OLDEST_THREADS: |
445 | 402 | return false; // Ascending |
446 | 403 | default: |
447 | | - throw new MWException( "Unknown sort order " . $this->orderType ); |
| 404 | + throw new MWException( "Unknown sort order ".$this->orderType ); |
448 | 405 | } |
449 | 406 | } |
450 | | - |
| 407 | + |
451 | 408 | /** |
452 | 409 | * A navigation bar with images |
453 | 410 | * Stolen from TablePager because it's pretty. |
— | — | @@ -496,7 +453,7 @@ |
497 | 454 | $s .= "</tr></table>\n"; |
498 | 455 | return $s; |
499 | 456 | } |
500 | | - |
| 457 | + |
501 | 458 | function getNavClass() { |
502 | 459 | return 'TalkpagePager_nav'; |
503 | 460 | } |
Index: trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php |
— | — | @@ -5,20 +5,23 @@ |
6 | 6 | |
7 | 7 | function getFormFields() { |
8 | 8 | $splitForm = array( |
9 | | - 'src' => array( |
10 | | - 'type' => 'info', |
11 | | - 'label-message' => 'lqt-thread-split-thread', |
12 | | - 'default' => LqtView::permalink( $this->mThread ), |
13 | | - 'raw' => 1, |
14 | | - ), |
15 | | - 'subject' => array( |
16 | | - 'type' => 'text', |
17 | | - 'label-message' => 'lqt-thread-split-subject', |
18 | | - ), |
19 | | - 'reason' => array( |
20 | | - 'label-message' => 'movereason', |
21 | | - 'type' => 'text', |
22 | | - ) |
| 9 | + 'src' => |
| 10 | + array( |
| 11 | + 'type' => 'info', |
| 12 | + 'label-message' => 'lqt-thread-split-thread', |
| 13 | + 'default' => LqtView::permalink( $this->mThread ), |
| 14 | + 'raw' => 1, |
| 15 | + ), |
| 16 | + 'subject' => |
| 17 | + array( |
| 18 | + 'type' => 'text', |
| 19 | + 'label-message' => 'lqt-thread-split-subject', |
| 20 | + ), |
| 21 | + 'reason' => |
| 22 | + array( |
| 23 | + 'label-message' => 'movereason', |
| 24 | + 'type' => 'text', |
| 25 | + ), |
23 | 26 | ); |
24 | 27 | |
25 | 28 | return $splitForm; |
— | — | @@ -50,16 +53,13 @@ |
51 | 54 | $this->mThread->commitRevision( Threads::CHANGE_SPLIT, null, $reason ); |
52 | 55 | |
53 | 56 | $title = clone $this->mThread->article()->getTitle(); |
54 | | - $title->setFragment( '#' . $this->mThread->getAnchorName() ); |
| 57 | + $title->setFragment( '#'.$this->mThread->getAnchorName() ); |
55 | 58 | |
56 | 59 | $link = $this->user->getSkin()->link( $title, $this->mThread->subject() ); |
57 | 60 | |
58 | 61 | global $wgOut; |
59 | | - $wgOut->addHTML( wfMsgExt( |
60 | | - 'lqt-split-success', |
61 | | - array( 'parseinline', 'replaceafter' ), |
62 | | - $link ) |
63 | | - ); |
| 62 | + $wgOut->addHTML( wfMsgExt( 'lqt-split-success', array( 'parseinline', 'replaceafter' ), |
| 63 | + $link ) ); |
64 | 64 | |
65 | 65 | return true; |
66 | 66 | } |
— | — | @@ -68,19 +68,19 @@ |
69 | 69 | $thread->setSubject( $subject ); |
70 | 70 | $thread->setAncestor( $ancestor->id() ); |
71 | 71 | |
72 | | - if ( $first ) { |
| 72 | + if ($first) { |
73 | 73 | $thread->setSuperThread( null ); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $thread->save( ); |
77 | 77 | |
78 | | - foreach ( $thread->replies() as $subThread ) { |
| 78 | + foreach( $thread->replies() as $subThread ) { |
79 | 79 | $this->recursiveSet( $subThread, $subject, $ancestor ); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | 83 | function validateSubject( $target ) { |
84 | | - if ( !$target ) { |
| 84 | + if (!$target) { |
85 | 85 | return wfMsgExt( 'lqt_split_nosubject', 'parseinline' ); |
86 | 86 | } |
87 | 87 | |
Index: trunk/extensions/LiquidThreads/pages/SummaryPageView.php |
— | — | @@ -8,14 +8,12 @@ |
9 | 9 | $thread = Threads::withSummary( $this->article ); |
10 | 10 | if ( $thread ) { |
11 | 11 | global $wgUser; |
12 | | - |
| 12 | + |
13 | 13 | $t = $thread->root()->getTitle(); |
14 | 14 | $link = $wgUser->getSkin()->link( $t ); |
15 | | - $this->output->setSubtitle( wfMsgExt( |
16 | | - 'lqt_summary_subtitle', |
17 | | - array( 'parseinline', 'replaceafter' ), |
18 | | - $link ) |
19 | | - ); |
| 15 | + $this->output->setSubtitle( |
| 16 | + wfMsgExt( 'lqt_summary_subtitle', array( 'parseinline', 'replaceafter' ), |
| 17 | + $link ) ); |
20 | 18 | } |
21 | 19 | return true; |
22 | 20 | } |
Index: trunk/extensions/LiquidThreads/pages/SpecialMergeThread.php |
— | — | @@ -5,66 +5,70 @@ |
6 | 6 | |
7 | 7 | function getFormFields() { |
8 | 8 | $splitForm = array( |
9 | | - 'src' => array( |
10 | | - 'type' => 'info', |
11 | | - 'label-message' => 'lqt-thread-merge-source', |
12 | | - 'default' => $this->formatThreadField( 'src', $this->mThread->id() ), |
13 | | - 'raw' => 1, |
14 | | - ), |
15 | | - 'dest' => array( |
16 | | - 'type' => 'info', |
17 | | - 'label-message' => 'lqt-thread-merge-dest', |
18 | | - 'default' => $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ), |
19 | | - 'raw' => 1, |
20 | | - ), |
21 | | - 'reason' => array( |
22 | | - 'label-message' => 'movereason', |
23 | | - 'type' => 'text', |
24 | | - ) |
| 9 | + 'src' => |
| 10 | + array( |
| 11 | + 'type' => 'info', |
| 12 | + 'label-message' => 'lqt-thread-merge-source', |
| 13 | + 'default' => $this->formatThreadField( 'src', $this->mThread->id() ), |
| 14 | + 'raw' => 1, |
| 15 | + ), |
| 16 | + 'dest' => |
| 17 | + array( |
| 18 | + 'type' => 'info', |
| 19 | + 'label-message' => 'lqt-thread-merge-dest', |
| 20 | + 'default' => |
| 21 | + $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ), |
| 22 | + 'raw' => 1, |
| 23 | + ), |
| 24 | + 'reason' => |
| 25 | + array( |
| 26 | + 'label-message' => 'movereason', |
| 27 | + 'type' => 'text', |
| 28 | + ), |
25 | 29 | ); |
26 | | - |
| 30 | + |
27 | 31 | return $splitForm; |
28 | 32 | } |
29 | | - |
| 33 | + |
30 | 34 | protected function getRightRequirement() { return 'lqt-merge'; } |
31 | | - |
| 35 | + |
32 | 36 | public function checkParameters( $par ) { |
33 | 37 | global $wgOut; |
34 | | - if ( !parent::checkParameters( $par ) ) { |
| 38 | + if ( !parent::checkParameters($par) ) { |
35 | 39 | return false; |
36 | 40 | } |
37 | | - |
| 41 | + |
38 | 42 | $dest = $this->request->getVal( 'dest' ); |
39 | | - |
40 | | - if ( !$dest ) { |
| 43 | + |
| 44 | + if (!$dest) { |
41 | 45 | $wgOut->addWikiMsg( 'lqt_threadrequired' ); |
42 | 46 | return false; |
43 | 47 | } |
44 | | - |
| 48 | + |
45 | 49 | $thread = Threads::withId( $dest ); |
46 | | - |
47 | | - if ( !$thread ) { |
| 50 | + |
| 51 | + if (!$thread) { |
48 | 52 | $wgOut->addWikiMsg( 'lqt_nosuchthread' ); |
49 | 53 | return false; |
50 | 54 | } |
51 | | - |
| 55 | + |
52 | 56 | $this->mDestThread = $thread; |
53 | | - |
| 57 | + |
54 | 58 | return true; |
55 | 59 | } |
56 | 60 | |
57 | 61 | function formatThreadField( $field, $threadid ) { |
58 | | - |
59 | | - if ( !is_object( $threadid ) ) { |
| 62 | + |
| 63 | + if ( !is_object($threadid) ) { |
60 | 64 | $t = Threads::withId( $threadid ); |
61 | 65 | } else { |
62 | 66 | $t = $threadid; |
63 | 67 | $threadid = $t->id(); |
64 | 68 | } |
65 | | - |
| 69 | + |
66 | 70 | $out = Xml::hidden( $field, $threadid ); |
67 | 71 | $out .= LqtView::permalink( $t ); |
68 | | - |
| 72 | + |
69 | 73 | return $out; |
70 | 74 | } |
71 | 75 | |
— | — | @@ -75,63 +79,63 @@ |
76 | 80 | wfLoadExtensionMessages( 'LiquidThreads' ); |
77 | 81 | return wfMsg( 'lqt_merge_thread' ); |
78 | 82 | } |
79 | | - |
| 83 | + |
80 | 84 | function trySubmit( $data ) { |
81 | 85 | // Load data |
82 | 86 | $srcThread = $this->mThread; |
83 | 87 | $dstThread = $this->mDestThread; |
84 | 88 | $newSubject = $dstThread->subject(); |
85 | 89 | $reason = $data['reason']; |
86 | | - |
| 90 | + |
87 | 91 | $oldTopThread = $srcThread->topmostThread(); |
88 | 92 | $oldParent = $srcThread->superthread(); |
89 | | - |
| 93 | + |
90 | 94 | $this->recursiveSet( $srcThread, $newSubject, $dstThread, $dstThread ); |
91 | 95 | |
92 | 96 | $dstThread->addReply( $srcThread ); |
93 | | - |
94 | | - if ( $oldParent ) { |
| 97 | + |
| 98 | + if ($oldParent) { |
95 | 99 | $oldParent->removeReply( $srcThread ); |
96 | 100 | } |
97 | | - |
| 101 | + |
98 | 102 | $oldTopThread->commitRevision( Threads::CHANGE_MERGED_FROM, $srcThread, $reason ); |
99 | 103 | $dstThread->commitRevision( Threads::CHANGE_MERGED_TO, $srcThread, $reason ); |
100 | | - |
| 104 | + |
101 | 105 | $srcTitle = clone $srcThread->article()->getTitle(); |
102 | | - $srcTitle->setFragment( '#' . $srcThread->getAnchorName() ); |
103 | | - |
| 106 | + $srcTitle->setFragment( '#'.$srcThread->getAnchorName() ); |
| 107 | + |
104 | 108 | $dstTitle = clone $dstThread->article()->getTitle(); |
105 | | - $dstTitle->setFragment( '#' . $dstThread->getAnchorName() ); |
106 | | - |
| 109 | + $dstTitle->setFragment( '#'.$dstThread->getAnchorName() ); |
| 110 | + |
107 | 111 | $srcLink = $this->user->getSkin()->link( $srcTitle, $srcThread->subject() ); |
108 | 112 | $dstLink = $this->user->getSkin()->link( $dstTitle, $dstThread->subject() ); |
109 | | - |
| 113 | + |
110 | 114 | global $wgOut; |
111 | 115 | $wgOut->addHTML( wfMsgExt( 'lqt-merge-success', array( 'parseinline', 'replaceafter' ), |
112 | 116 | $srcLink, $dstLink ) ); |
113 | | - |
| 117 | + |
114 | 118 | return true; |
115 | 119 | } |
116 | | - |
| 120 | + |
117 | 121 | function recursiveSet( $thread, $subject, $ancestor, $superthread = false ) { |
118 | 122 | $thread->setSubject( $subject ); |
119 | 123 | $thread->setAncestor( $ancestor->id() ); |
120 | | - |
121 | | - if ( $superthread ) { |
| 124 | + |
| 125 | + if ($superthread) { |
122 | 126 | $thread->setSuperThread( $superthread ); |
123 | 127 | } |
124 | | - |
| 128 | + |
125 | 129 | $thread->save(); |
126 | | - |
127 | | - foreach ( $thread->replies() as $subThread ) { |
| 130 | + |
| 131 | + foreach( $thread->replies() as $subThread ) { |
128 | 132 | $this->recursiveSet( $subThread, $subject, $ancestor ); |
129 | 133 | } |
130 | 134 | } |
131 | | - |
| 135 | + |
132 | 136 | function getPageName() { |
133 | 137 | return 'MergeThread'; |
134 | 138 | } |
135 | | - |
| 139 | + |
136 | 140 | function getSubmitText() { |
137 | 141 | wfLoadExtensionMessages( 'LiquidThreads' ); |
138 | 142 | return wfMsg( 'lqt-merge-submit' ); |
Index: trunk/extensions/LiquidThreads/pages/TalkpageHeaderView.php |
— | — | @@ -26,44 +26,30 @@ |
27 | 27 | |
28 | 28 | if ( $wgRequest->getVal( 'action' ) === 'edit' ) { |
29 | 29 | wfLoadExtensionMessages( 'LiquidThreads' ); |
30 | | - |
| 30 | + |
31 | 31 | $html = ''; |
32 | | - |
33 | | - $warn_bold = Xml::tags( |
34 | | - 'strong', |
35 | | - null, |
36 | | - wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) |
37 | | - ); |
38 | | - |
39 | | - $warn_link = $this->talkpageLink( |
40 | | - $wgTitle, |
41 | | - wfMsgExt( 'lqt_header_warning_new_discussion', 'parseinline' ), |
42 | | - 'talkpage_new_thread' |
43 | | - ); |
44 | | - |
45 | | - $html .= wfMsgExt( |
46 | | - 'lqt_header_warning_before_big', |
47 | | - array( 'parseinline', 'replaceafter' ), |
48 | | - array( $warn_bold, $warn_link ) |
49 | | - ); |
50 | | - $html .= Xml::tags( |
51 | | - 'big', |
52 | | - null, |
53 | | - wfMsgExt( |
54 | | - 'lqt_header_warning_big', |
55 | | - array( 'parseinline', 'replaceafter' ), |
56 | | - array( $warn_bold, $warn_link ) |
57 | | - ) |
58 | | - ); |
| 32 | + |
| 33 | + $warn_bold = Xml::tags( 'strong', null, |
| 34 | + wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) ); |
| 35 | + |
| 36 | + $warn_link = |
| 37 | + $this->talkpageLink( $wgTitle, wfMsgExt( 'lqt_header_warning_new_discussion', |
| 38 | + 'parseinline' ), 'talkpage_new_thread' ); |
| 39 | + |
| 40 | + $html .= wfMsgExt( 'lqt_header_warning_before_big', |
| 41 | + array('parseinline', 'replaceafter' ), |
| 42 | + array( $warn_bold, $warn_link ) ); |
| 43 | + $html .= Xml::tags( 'big', null, |
| 44 | + wfMsgExt( 'lqt_header_warning_big', |
| 45 | + array( 'parseinline', 'replaceafter' ), |
| 46 | + array( $warn_bold, $warn_link ) ) ); |
59 | 47 | $html .= wfMsg( 'word-separator' ); |
60 | | - $html .= wfMsgExt( |
61 | | - 'lqt_header_warning_after_big', |
62 | | - array( 'parseinline', 'replaceafter' ), |
63 | | - array( $warn_bold, $warn_link ) |
64 | | - ); |
65 | | - |
| 48 | + $html .= wfMsgExt( 'lqt_header_warning_after_big', |
| 49 | + array( 'parseinline', 'replaceafter' ), |
| 50 | + array( $warn_bold, $warn_link ) ); |
| 51 | + |
66 | 52 | $html = Xml::tags( 'p', array( 'class' => 'lqt_header_warning' ), $html ); |
67 | | - |
| 53 | + |
68 | 54 | $wgOut->addHTML( $html ); |
69 | 55 | } |
70 | 56 | |
Index: trunk/extensions/LiquidThreads/pages/IndividualThreadHistoryView.php |
— | — | @@ -16,16 +16,12 @@ |
17 | 17 | function customizeSubtitle() { |
18 | 18 | wfLoadExtensionMessages( 'LiquidThreads' ); |
19 | 19 | $msg = wfMsgExt( 'lqt_hist_view_whole_thread', 'parseinline' ); |
20 | | - $threadhist = $this->permalink( |
21 | | - $this->thread->topmostThread(), |
22 | | - $msg, |
23 | | - 'thread_history' |
24 | | - ); |
25 | | - $this->output->setSubtitle( |
26 | | - parent::getSubtitle() . '<br />' . |
27 | | - $this->output->getSubtitle() . |
28 | | - "<br />$threadhist" |
29 | | - ); |
| 20 | + $threadhist = $this->permalink( $this->thread->topmostThread(), |
| 21 | + $msg, |
| 22 | + 'thread_history' ); |
| 23 | + $this->output->setSubtitle( parent::getSubtitle() . '<br />' . |
| 24 | + $this->output->getSubtitle() . |
| 25 | + "<br />$threadhist" ); |
30 | 26 | return true; |
31 | 27 | } |
32 | 28 | |
Index: trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php |
— | — | @@ -11,125 +11,119 @@ |
12 | 12 | wfLoadExtensionMessages( 'LiquidThreads' ); |
13 | 13 | return wfMsg( 'lqt_movethread' ); |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | function getFormFields() { |
17 | | - return array( |
18 | | - 'dest-title' => array( |
19 | | - 'label-message' => 'lqt_move_destinationtitle', |
20 | | - 'type' => 'text', |
21 | | - 'validation-callback' => array( $this, 'validateTarget' ), |
22 | | - ), |
23 | | - 'reason' => array( |
24 | | - 'label-message' => 'movereason', |
25 | | - 'type' => 'text', |
26 | | - ), |
27 | | - ); |
| 17 | + return |
| 18 | + array( |
| 19 | + 'dest-title' => |
| 20 | + array( |
| 21 | + 'label-message' => 'lqt_move_destinationtitle', |
| 22 | + 'type' => 'text', |
| 23 | + 'validation-callback' => array( $this, 'validateTarget' ), |
| 24 | + ), |
| 25 | + 'reason' => |
| 26 | + array( |
| 27 | + 'label-message' => 'movereason', |
| 28 | + 'type' => 'text', |
| 29 | + ), |
| 30 | + ); |
28 | 31 | } |
29 | | - |
| 32 | + |
30 | 33 | function getPageName() { return 'MoveThread'; } |
31 | | - |
| 34 | + |
32 | 35 | function getSubmitText() { |
33 | 36 | wfLoadExtensionMessages( 'LiquidThreads' ); |
34 | 37 | return wfMsg( 'lqt_move_move' ); |
35 | 38 | } |
36 | | - |
| 39 | + |
37 | 40 | function buildForm() { |
38 | 41 | $form = parent::buildForm(); |
39 | | - |
| 42 | + |
40 | 43 | // Generate introduction |
41 | 44 | $intro = ''; |
42 | | - |
| 45 | + |
43 | 46 | global $wgUser; |
44 | 47 | $sk = $wgUser->getSkin(); |
45 | 48 | $page = $article_name = $this->mThread->article()->getTitle()->getPrefixedText(); |
46 | | - |
| 49 | + |
47 | 50 | $edit_text = wfMsgExt( 'lqt_move_torename_edit', 'parseinline' ); |
48 | | - $edit_link = $sk->link( |
49 | | - $this->mThread->title(), |
50 | | - $edit_text, |
51 | | - array(), |
52 | | - array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() ) |
53 | | - ); |
54 | | - |
55 | | - $intro .= wfMsgExt( |
56 | | - 'lqt_move_movingthread', |
57 | | - 'parse', |
58 | | - array( '[[' . $this->mTarget . ']]', '[[' . $page . ']]' ) |
59 | | - ); |
60 | | - $intro .= wfMsgExt( |
61 | | - 'lqt_move_torename', |
62 | | - array( 'parse', 'replaceafter' ), |
63 | | - array( $edit_link ) |
64 | | - ); |
65 | | - |
| 51 | + $edit_link = $sk->link( $this->mThread->title(), $edit_text, array(), |
| 52 | + array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() ) ); |
| 53 | + |
| 54 | + $intro .= wfMsgExt( 'lqt_move_movingthread', 'parse', |
| 55 | + array('[['.$this->mTarget.']]', '[['.$page.']]') ); |
| 56 | + $intro .= wfMsgExt( 'lqt_move_torename', array( 'parse', 'replaceafter' ), |
| 57 | + array( $edit_link ) ); |
| 58 | + |
66 | 59 | $form->setIntro( $intro ); |
67 | | - |
| 60 | + |
68 | 61 | return $form; |
69 | 62 | } |
70 | | - |
| 63 | + |
71 | 64 | function checkUserRights( $oldTitle, $newTitle ) { |
72 | 65 | global $wgUser, $wgOut; |
73 | | - |
| 66 | + |
74 | 67 | $oldErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser ); |
75 | 68 | $newErrors = $newTitle->getUserPermissionsErrors( 'move', $wgUser ); |
76 | | - |
| 69 | + |
77 | 70 | // Custom merge/unique function because we don't have the second parameter to |
78 | 71 | // array_unique on Wikimedia. |
79 | 72 | $mergedErrors = array(); |
80 | | - foreach ( array_merge( $oldErrors, $newErrors ) as $key => $value ) { |
81 | | - if ( !is_numeric( $key ) ) { |
| 73 | + foreach( array_merge( $oldErrors, $newErrors ) as $key => $value ) { |
| 74 | + if ( !is_numeric($key) ) { |
82 | 75 | $mergedErrors[$key] = $value; |
83 | 76 | } elseif ( !in_array( $value, $mergedErrors ) ) { |
84 | 77 | $mergedErrors[] = $value; |
85 | 78 | } |
86 | 79 | } |
87 | | - |
88 | | - if ( count( $mergedErrors ) > 0 ) { |
89 | | - return $wgOut->parse( |
90 | | - $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' ) |
91 | | - ); |
| 80 | + |
| 81 | + if ( count($mergedErrors) > 0 ) { |
| 82 | + return $wgOut->parse( |
| 83 | + $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' ) |
| 84 | + ); |
92 | 85 | } |
93 | 86 | |
94 | 87 | return true; |
95 | 88 | } |
96 | | - |
| 89 | + |
97 | 90 | function trySubmit( $data ) { |
98 | 91 | // Load data |
99 | 92 | $tmp = $data['dest-title']; |
100 | 93 | $newtitle = Title::newFromText( $tmp ); |
101 | 94 | $reason = $data['reason']; |
102 | | - |
| 95 | + |
103 | 96 | $rightsResult = $this->checkUserRights( $this->mThread->title(), $newtitle ); |
104 | | - |
105 | | - if ( $rightsResult !== true ) |
| 97 | + |
| 98 | + if ($rightsResult !== true) |
106 | 99 | return $rightsResult; |
107 | 100 | |
108 | 101 | // TODO no status code from this method. |
109 | 102 | $this->mThread->moveToPage( $newtitle, $reason, true ); |
110 | | - |
| 103 | + |
111 | 104 | global $wgOut, $wgUser; |
112 | 105 | $sk = $wgUser->getSkin(); |
113 | 106 | $wgOut->addHTML( wfMsgExt( 'lqt_move_success', array( 'parse', 'replaceafter' ), |
114 | 107 | array( $sk->link( $newtitle ) ) ) ); |
115 | | - |
| 108 | + |
116 | 109 | return true; |
117 | 110 | } |
118 | | - |
| 111 | + |
119 | 112 | function validateTarget( $target ) { |
120 | | - if ( !$target ) { |
| 113 | + if (!$target) { |
121 | 114 | return wfMsgExt( 'lqt_move_nodestination', 'parseinline' ); |
122 | 115 | } |
123 | | - |
| 116 | + |
124 | 117 | $title = Title::newFromText( $target ); |
125 | | - |
| 118 | + |
126 | 119 | if ( !$title || !LqtDispatch::isLqtPage( $title ) ) { |
127 | 120 | return wfMsgExt( 'lqt_move_thread_bad_destination', 'parseinline' ); |
128 | 121 | } |
129 | | - |
| 122 | + |
130 | 123 | if ( $title->equals( $this->mThread->article()->getTitle() ) ) { |
131 | 124 | return wfMsgExt( 'lqt_move_samedestination', 'parseinline' ); |
132 | 125 | } |
133 | | - |
| 126 | + |
134 | 127 | return true; |
135 | 128 | } |
| 129 | + |
136 | 130 | } |
Index: trunk/extensions/LiquidThreads/pages/ThreadActionPage.php |
— | — | @@ -6,40 +6,40 @@ |
7 | 7 | function __construct() { |
8 | 8 | parent::__construct( $this->getPageName(), $this->getRightRequirement() ); |
9 | 9 | $this->includable( false ); |
10 | | - |
| 10 | + |
11 | 11 | global $wgOut, $wgUser, $wgRequest; |
12 | 12 | $this->output = $wgOut; |
13 | 13 | $this->user = $wgUser; |
14 | 14 | $this->request = $wgRequest; |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | abstract function getPageName(); |
18 | | - |
| 18 | + |
19 | 19 | abstract function getFormFields(); |
20 | | - |
| 20 | + |
21 | 21 | protected function getRightRequirement() { return ''; } |
22 | 22 | |
23 | 23 | function execute( $par ) { |
24 | 24 | wfLoadExtensionMessages( 'LiquidThreads' ); |
25 | | - |
| 25 | + |
26 | 26 | global $wgOut, $wgUser; |
27 | | - |
| 27 | + |
28 | 28 | if ( !$this->userCanExecute( $wgUser ) ) { |
29 | 29 | $this->displayRestrictionError(); |
30 | 30 | return; |
31 | 31 | } |
32 | | - |
| 32 | + |
33 | 33 | // Page title |
34 | 34 | $wgOut->setPageTitle( $this->getDescription() ); |
35 | | - |
36 | | - if ( !$this->checkParameters( $par ) ) { |
| 35 | + |
| 36 | + if ( !$this->checkParameters($par) ) { |
37 | 37 | return; |
38 | 38 | } |
39 | | - |
| 39 | + |
40 | 40 | $form = $this->buildForm(); |
41 | 41 | $form->show(); |
42 | 42 | } |
43 | | - |
| 43 | + |
44 | 44 | // Loads stuff like the thread and so on |
45 | 45 | function checkParameters( $par ) { |
46 | 46 | // Handle parameter |
— | — | @@ -49,31 +49,32 @@ |
50 | 50 | $this->output->addHTML( wfMsg( 'lqt_threadrequired' ) ); |
51 | 51 | return false; |
52 | 52 | } |
53 | | - |
| 53 | + |
54 | 54 | $thread = Threads::withRoot( new Article( Title::newFromURL( $par ) ) ); |
55 | 55 | if ( !$thread ) { |
56 | 56 | $this->output->addHTML( wfMsg( 'lqt_nosuchthread' ) ); |
57 | 57 | return false; |
58 | 58 | } |
59 | | - |
| 59 | + |
60 | 60 | $this->mThread = $thread; |
61 | | - |
| 61 | + |
62 | 62 | return true; |
63 | 63 | } |
64 | | - |
| 64 | + |
65 | 65 | abstract function getSubmitText(); |
66 | | - |
| 66 | + |
67 | 67 | function buildForm() { |
68 | | - $form = new HTMLForm( $this->getFormFields(), 'lqt-' . $this->getPageName() ); |
69 | | - |
| 68 | + $form = new HTMLForm( $this->getFormFields(), 'lqt-'.$this->getPageName() ); |
| 69 | + |
70 | 70 | $par = $this->mThread->title()->getPrefixedText(); |
71 | | - |
| 71 | + |
72 | 72 | $form->setSubmitText( $this->getSubmitText() ); |
73 | 73 | $form->setTitle( SpecialPage::getTitleFor( $this->getPageName(), $par ) ); |
74 | 74 | $form->setSubmitCallback( array( $this, 'trySubmit' ) ); |
75 | | - |
| 75 | + |
76 | 76 | return $form; |
77 | 77 | } |
| 78 | + |
| 79 | + abstract function trySubmit( $data ); |
78 | 80 | |
79 | | - abstract function trySubmit( $data ); |
80 | 81 | } |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die; |
5 | 5 | |
6 | 6 | class ThreadHistoricalRevisionView extends ThreadPermalinkView { |
| 7 | + |
7 | 8 | public $mDisplayRevision = null; |
8 | 9 | |
9 | 10 | /* TOOD: customize tabs so that History is highlighted. */ |
— | — | @@ -11,16 +12,16 @@ |
12 | 13 | $changedObject = $this->mDisplayRevision->getChangeObject(); |
13 | 14 | $is_changed_thread = $changedObject && |
14 | 15 | ( $changedObject->id() == $thread->id() ); |
15 | | - |
| 16 | + |
16 | 17 | $class = parent::postDivClass( $thread ); |
17 | | - |
| 18 | + |
18 | 19 | if ( $is_changed_thread ) { |
19 | 20 | return "$class lqt_post_changed_by_history"; |
20 | 21 | } else { |
21 | 22 | return $class; |
22 | 23 | } |
23 | 24 | } |
24 | | - |
| 25 | + |
25 | 26 | function getMessageForChangeType( $ct ) { |
26 | 27 | static $messages = array( |
27 | 28 | Threads::CHANGE_NEW_THREAD => 'lqt_change_new_thread', |
— | — | @@ -35,11 +36,11 @@ |
36 | 37 | Threads::CHANGE_SPLIT_FROM => 'lqt_change_split_from', |
37 | 38 | Threads::CHANGE_EDITED_SUMMARY => 'lqt_change_edited_summary', |
38 | 39 | ); |
39 | | - |
40 | | - if ( isset( $messages[$ct] ) ) { |
| 40 | + |
| 41 | + if ( isset($messages[$ct]) ) { |
41 | 42 | return $messages[$ct]; |
42 | 43 | } |
43 | | - |
| 44 | + |
44 | 45 | return ''; |
45 | 46 | } |
46 | 47 | |
— | — | @@ -48,38 +49,33 @@ |
49 | 50 | wfLoadExtensionMessages( 'LiquidThreads' ); |
50 | 51 | |
51 | 52 | $html = ''; |
52 | | - $html .= wfMsgExt( |
53 | | - 'lqt_revision_as_of', 'parseinline', |
54 | | - array( |
55 | | - $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ), |
56 | | - $wgLang->date( $this->mDisplayRevision->getTimestamp() ), |
57 | | - $wgLang->time( $this->mDisplayRevision->getTimestamp() ) |
58 | | - ) |
59 | | - ); |
60 | | - |
| 53 | + $html .= wfMsgExt( 'lqt_revision_as_of', 'parseinline', |
| 54 | + array( |
| 55 | + $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ), |
| 56 | + $wgLang->date( $this->mDisplayRevision->getTimestamp() ), |
| 57 | + $wgLang->time( $this->mDisplayRevision->getTimestamp() ) |
| 58 | + ) |
| 59 | + ); |
| 60 | + |
61 | 61 | $html .= '<br/>'; |
62 | 62 | |
63 | 63 | $ct = $this->mDisplayRevision->getChangeType(); |
64 | | - |
| 64 | + |
65 | 65 | $msg = ''; |
66 | 66 | if ( $ct == Threads::CHANGE_EDITED_ROOT ) { |
67 | | - $diff_link = $this->diffPermalink( |
68 | | - $this->thread, |
69 | | - wfMsgExt( 'diff', 'parseinline' ), |
70 | | - $this->mDisplayRevision |
71 | | - ); |
72 | | - $msg = wfMsgExt( |
73 | | - 'lqt_change_edited_root', |
74 | | - 'parseinline' |
75 | | - ) . " [$diff_link]"; |
| 67 | + $diff_link = $this->diffPermalink( $this->thread, |
| 68 | + wfMsgExt( 'diff', 'parseinline' ), |
| 69 | + $this->mDisplayRevision ); |
| 70 | + $msg = wfMsgExt( 'lqt_change_edited_root', 'parseinline' ) . |
| 71 | + " [$diff_link]"; |
76 | 72 | } else { |
77 | | - $msg = wfMsgExt( $this->getMessageForChangeType( $ct ), 'parseinline' ); |
| 73 | + $msg = wfMsgExt( $this->getMessageForChangeType($ct), 'parseinline' ); |
78 | 74 | } |
79 | | - |
| 75 | + |
80 | 76 | $html .= $msg; |
81 | | - |
| 77 | + |
82 | 78 | $html = Xml::tags( 'div', array( 'class' => 'lqt_history_info' ), $html ); |
83 | | - |
| 79 | + |
84 | 80 | $this->output->addHTML( $html ); |
85 | 81 | } |
86 | 82 | |
— | — | @@ -88,12 +84,12 @@ |
89 | 85 | $this->showMissingThreadPage(); |
90 | 86 | return false; |
91 | 87 | } |
92 | | - |
| 88 | + |
93 | 89 | $oldid = $this->request->getInt( 'lqt_oldid' ); |
94 | 90 | $this->mDisplayRevision = ThreadRevision::loadFromId( $oldid ); |
95 | 91 | |
96 | 92 | $this->thread = $this->mDisplayRevision->getThreadObj(); |
97 | | - |
| 93 | + |
98 | 94 | $this->showHistoryInfo(); |
99 | 95 | parent::show(); |
100 | 96 | return false; |
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php |
— | — | @@ -10,13 +10,13 @@ |
11 | 11 | // Insert fake 'article' and 'discussion' tabs before the thread tab. |
12 | 12 | // If you call the key 'talk', the url gets re-set later. TODO: |
13 | 13 | // the access key for the talk tab doesn't work. |
14 | | - if ( $this->thread ) { |
| 14 | + if ($this->thread) { |
15 | 15 | $article_t = $this->thread->article()->getTitle(); |
16 | 16 | $talk_t = $this->thread->article()->getTitle(); |
17 | 17 | } else { |
18 | 18 | return true; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | $articleTab = |
22 | 22 | array( |
23 | 23 | 'text' => wfMsg( $article_t->getNamespaceKey() ), |
— | — | @@ -24,27 +24,27 @@ |
25 | 25 | 'class' => $article_t->exists() ? '' : 'new' |
26 | 26 | ); |
27 | 27 | efInsertIntoAssoc( 'article', $articleTab, 'nstab-thread', $content_actions ); |
28 | | - |
| 28 | + |
29 | 29 | $talkTab = |
30 | 30 | array( |
31 | 31 | // talkpage certainly exists since this thread is from it. |
32 | 32 | 'text' => wfMsg( 'talk' ), |
33 | 33 | 'href' => $talk_t->getFullURL() |
34 | 34 | ); |
35 | | - |
| 35 | + |
36 | 36 | efInsertIntoAssoc( 'not_talk', $talkTab, 'nstab-thread', $content_actions ); |
37 | 37 | |
38 | 38 | unset( $content_actions['edit'] ); |
39 | 39 | unset( $content_actions['viewsource'] ); |
40 | 40 | unset( $content_actions['talk'] ); |
41 | | - |
| 41 | + |
42 | 42 | $subpage = $this->thread->title()->getPrefixedText(); |
43 | | - |
| 43 | + |
44 | 44 | if ( array_key_exists( 'move', $content_actions ) && $this->thread ) { |
45 | 45 | $content_actions['move']['href'] = |
46 | 46 | SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL(); |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | if ( array_key_exists( 'delete', $content_actions ) && $this->thread ) { |
50 | 50 | $content_actions['delete']['href'] = |
51 | 51 | $this->thread->title()->getFullURL( 'action=delete' ); |
— | — | @@ -77,39 +77,33 @@ |
78 | 78 | |
79 | 79 | function getSubtitle() { |
80 | 80 | wfLoadExtensionMessages( 'LiquidThreads' ); |
81 | | - |
| 81 | + |
82 | 82 | $sk = $this->user->getSkin(); |
83 | | - $fragment = '#' . $this->anchorName( $this->thread ); |
84 | | - |
| 83 | + $fragment = '#'.$this->anchorName( $this->thread ); |
| 84 | + |
85 | 85 | if ( $this->thread->isHistorical() ) { |
86 | 86 | // TODO: Point to the relevant part of the archive. |
87 | 87 | $query = ''; |
88 | 88 | } else { |
89 | 89 | $query = ''; |
90 | 90 | } |
91 | | - |
| 91 | + |
92 | 92 | $talkpage = $this->thread->article()->getTitle(); |
93 | 93 | $talkpage->setFragment( $fragment ); |
94 | 94 | $talkpage_link = $sk->link( $talkpage ); |
95 | | - |
| 95 | + |
96 | 96 | if ( $this->thread->hasSuperthread() ) { |
97 | 97 | $topmostTitle = $this->thread->topmostThread()->title(); |
98 | 98 | $topmostTitle->setFragment( $fragment ); |
99 | | - |
| 99 | + |
100 | 100 | $linkText = wfMsgExt( 'lqt_discussion_link', 'parseinline' ); |
101 | 101 | $permalink = $sk->link( $topmostTitle, $linkText ); |
102 | | - |
103 | | - return wfMsgExt( |
104 | | - 'lqt_fragment', |
105 | | - array( 'parseinline', 'replaceafter' ), |
106 | | - array( $permalink, $talkpage_link ) |
107 | | - ); |
| 102 | + |
| 103 | + return wfMsgExt( 'lqt_fragment', array('parseinline', 'replaceafter'), |
| 104 | + array( $permalink, $talkpage_link ) ); |
108 | 105 | } else { |
109 | | - return wfMsgExt( |
110 | | - 'lqt_from_talk', |
111 | | - array( 'parseinline', 'replaceafter' ), |
112 | | - array( $talkpage_link ) |
113 | | - ); |
| 106 | + return wfMsgExt( 'lqt_from_talk', array('parseinline', 'replaceafter'), |
| 107 | + array($talkpage_link) ); |
114 | 108 | } |
115 | 109 | } |
116 | 110 | |
— | — | @@ -118,7 +112,7 @@ |
119 | 113 | parent::__construct( $output, $article, $title, $user, $request ); |
120 | 114 | |
121 | 115 | $t = Threads::withRoot( $this->article ); |
122 | | - |
| 116 | + |
123 | 117 | $this->thread = $t; |
124 | 118 | if ( !$t ) { |
125 | 119 | return; // error reporting is handled in show(). this kinda sucks. |
— | — | @@ -138,7 +132,7 @@ |
139 | 133 | $this->showMissingThreadPage(); |
140 | 134 | return false; |
141 | 135 | } |
142 | | - |
| 136 | + |
143 | 137 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
144 | 138 | $this->doInlineEditForm(); |
145 | 139 | return false; |
— | — | @@ -152,8 +146,8 @@ |
153 | 147 | elseif ( $this->methodApplies( 'split' ) ) |
154 | 148 | $this->showSplitForm( $this->thread ); |
155 | 149 | |
156 | | - $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => - 1, 'maxCount' => - 1 ) ); |
157 | | - |
| 150 | + $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => -1, 'maxCount' => -1 ) ); |
| 151 | + |
158 | 152 | $this->output->setPageTitle( $this->thread->subject() ); |
159 | 153 | return false; |
160 | 154 | } |
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php |
— | — | @@ -13,15 +13,10 @@ |
14 | 14 | $html = ''; |
15 | 15 | $html .= Xml::hidden( 'lqt_method', 'mark_as_read' ); |
16 | 16 | $html .= Xml::hidden( 'lqt_operand', $ids_s ); |
17 | | - $html .= Xml::submitButton( |
18 | | - $label, |
19 | | - array( |
20 | | - 'name' => 'lqt_read_button', |
21 | | - 'title' => $title |
22 | | - ) |
23 | | - ); |
| 17 | + $html .= Xml::submitButton( $label, array( 'name' => 'lqt_read_button', |
| 18 | + 'title' => $title ) ); |
24 | 19 | $html = Xml::tags( 'form', array( 'method' => 'post', 'class' => $class ), $html ); |
25 | | - |
| 20 | + |
26 | 21 | return $html; |
27 | 22 | } |
28 | 23 | |
— | — | @@ -29,56 +24,49 @@ |
30 | 25 | wfLoadExtensionMessages( 'LiquidThreads' ); |
31 | 26 | $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew |
32 | 27 | return $this->htmlForReadButton( |
33 | | - wfMsg( 'lqt-read-all' ), |
34 | | - wfMsg( 'lqt-read-all-tooltip' ), |
35 | | - "lqt_newmessages_read_all_button", |
36 | | - $ids |
37 | | - ); |
| 28 | + wfMsg( 'lqt-read-all' ), |
| 29 | + wfMsg( 'lqt-read-all-tooltip' ), |
| 30 | + "lqt_newmessages_read_all_button", |
| 31 | + $ids |
| 32 | + ); |
38 | 33 | } |
39 | 34 | |
40 | 35 | function getUndoButton( $ids ) { |
41 | 36 | wfLoadExtensionMessages( 'LiquidThreads' ); |
42 | | - |
| 37 | + |
43 | 38 | if ( count( $ids ) == 1 ) { |
44 | 39 | $t = Threads::withId( $ids[0] ); |
45 | 40 | if ( !$t ) |
46 | 41 | return; // empty or just bogus operand. |
47 | | - $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array( $t->subject() ) ); |
| 42 | + $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array($t->subject()) ); |
48 | 43 | } else { |
49 | 44 | $count = count( $ids ); |
50 | | - $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) ); |
| 45 | + $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array($count) ); |
51 | 46 | } |
52 | 47 | $operand = implode( ',', $ids ); |
53 | | - |
| 48 | + |
54 | 49 | $html = ''; |
55 | 50 | $html .= $msg; |
56 | 51 | $html .= Xml::hidden( 'lqt_method', 'mark_as_unread' ); |
57 | 52 | $html .= Xml::hidden( 'lqt_operand', $operand ); |
58 | | - $html .= Xml::submitButton( |
59 | | - wfMsg( 'lqt-email-undo' ), |
60 | | - array( |
61 | | - 'name' => 'lqt_read_button', |
62 | | - 'title' => wfMsg( 'lqt-email-info-undo' ) |
63 | | - ) |
64 | | - ); |
65 | | - |
66 | | - $html = Xml::tags( |
67 | | - 'form', |
68 | | - array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), |
69 | | - $html |
70 | | - ); |
71 | | - |
| 53 | + $html .= Xml::submitButton( wfMsg('lqt-email-undo'), array( 'name' => 'lqt_read_button', |
| 54 | + 'title' => wfMsg( 'lqt-email-info-undo' ) ) ); |
| 55 | + |
| 56 | + $html = Xml::tags( 'form', |
| 57 | + array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), |
| 58 | + $html ); |
| 59 | + |
72 | 60 | return $html; |
73 | 61 | } |
74 | 62 | |
75 | 63 | function postDivClass( $thread ) { |
76 | 64 | $origClass = parent::postDivClass( $thread ); |
77 | | - |
| 65 | + |
78 | 66 | $topid = $thread->topmostThread()->id(); |
79 | | - |
| 67 | + |
80 | 68 | if ( in_array( $thread->id(), $this->targets[$topid] ) ) |
81 | 69 | return "$origClass lqt_post_new_message"; |
82 | | - |
| 70 | + |
83 | 71 | return $origClass; |
84 | 72 | } |
85 | 73 | |
— | — | @@ -94,13 +82,11 @@ |
95 | 83 | |
96 | 84 | if ( $this->request->wasPosted() && $this->methodApplies( 'mark_as_unread' ) ) { |
97 | 85 | $ids = explode( ',', $this->request->getVal( 'lqt_operand', '' ) ); |
98 | | - |
| 86 | + |
99 | 87 | if ( $ids !== false ) { |
100 | 88 | foreach ( $ids as $id ) { |
101 | | - $tmp_thread = Threads::withId( $id ); |
102 | | - if ( $tmp_thread ) { |
| 89 | + $tmp_thread = Threads::withId( $id ); if ( $tmp_thread ) |
103 | 90 | NewMessages::markThreadAsUnReadByUser( $tmp_thread, $this->user ); |
104 | | - } |
105 | 91 | } |
106 | 92 | $this->output->redirect( $this->title->getFullURL() ); |
107 | 93 | } |
— | — | @@ -109,9 +95,8 @@ |
110 | 96 | if ( $ids !== false ) { |
111 | 97 | foreach ( $ids as $id ) { |
112 | 98 | $tmp_thread = Threads::withId( $id ); |
113 | | - if ( $tmp_thread ) { |
| 99 | + if ( $tmp_thread ) |
114 | 100 | NewMessages::markThreadAsReadByUser( $tmp_thread, $this->user ); |
115 | | - } |
116 | 101 | } |
117 | 102 | $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode( ',', $ids ); |
118 | 103 | $this->output->redirect( $this->title->getFullURL( $query ) ); |
— | — | @@ -126,7 +111,7 @@ |
127 | 112 | if ( ! is_array( $this->threads ) ) { |
128 | 113 | throw new MWException( 'You must use NewUserMessagesView::setThreads() before calling NewUserMessagesView::show().' ); |
129 | 114 | } |
130 | | - |
| 115 | + |
131 | 116 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
132 | 117 | $this->doInlineEditForm(); |
133 | 118 | return false; |
— | — | @@ -139,10 +124,10 @@ |
140 | 125 | $this->tops = array(); |
141 | 126 | foreach ( $this->threads as $t ) { |
142 | 127 | $top = $t->topmostThread(); |
143 | | - |
| 128 | + |
144 | 129 | // It seems that in some cases $top is zero. |
145 | | - if ( !$top ) |
146 | | - throw new MWException( "{$t->id()} seems to have no topmost thread" ); |
| 130 | + if (!$top) |
| 131 | + throw new MWException("{$t->id()} seems to have no topmost thread"); |
147 | 132 | |
148 | 133 | if ( !array_key_exists( $top->id(), $this->tops ) ) |
149 | 134 | $this->tops[$top->id()] = $top; |
— | — | @@ -150,7 +135,7 @@ |
151 | 136 | $this->targets[$top->id()] = array(); |
152 | 137 | $this->targets[$top->id()][] = $t->id(); |
153 | 138 | } |
154 | | - |
| 139 | + |
155 | 140 | $this->output->addHTML( '<table><tbody>' ); |
156 | 141 | |
157 | 142 | foreach ( $this->tops as $t ) { |
— | — | @@ -160,39 +145,34 @@ |
161 | 146 | |
162 | 147 | $this->showWrappedThread( $t ); |
163 | 148 | } |
164 | | - |
| 149 | + |
165 | 150 | $this->output->addHTML( '</tbody></table>' ); |
166 | | - |
| 151 | + |
167 | 152 | return false; |
168 | 153 | } |
169 | | - |
| 154 | + |
170 | 155 | function showWrappedThread( $t ) { |
171 | 156 | wfLoadExtensionMessages( 'LiquidThreads' ); |
172 | | - |
| 157 | + |
173 | 158 | $read_button = $this->htmlForReadButton( |
174 | 159 | wfMsg( 'lqt-read-message' ), |
175 | 160 | wfMsg( 'lqt-read-message-tooltip' ), |
176 | 161 | 'lqt_newmessages_read_button', |
177 | 162 | $this->targets[$t->id()] ); |
178 | | - |
| 163 | + |
179 | 164 | // Left-hand column � read button and context link to the full thread. |
180 | 165 | $topmostThread = $t->topmostThread(); |
181 | | - $contextLink = self::permalink( |
182 | | - $topmostThread, |
183 | | - wfMsgExt( 'lqt-newmessages-context', 'parseinline' ) |
184 | | - ); |
| 166 | + $contextLink = self::permalink( $topmostThread, |
| 167 | + wfMsgExt( 'lqt-newmessages-context', 'parseinline' ) ); |
185 | 168 | $leftColumn = Xml::tags( 'p', null, $read_button ) . |
186 | 169 | Xml::tags( 'p', null, $contextLink ); |
187 | | - $leftColumn = Xml::tags( |
188 | | - 'td', |
189 | | - array( 'class' => 'mw-lqt-newmessages-left' ), |
190 | | - $leftColumn |
191 | | - ); |
| 170 | + $leftColumn = Xml::tags( 'td', array( 'class' => 'mw-lqt-newmessages-left' ), |
| 171 | + $leftColumn ); |
192 | 172 | $html = "<tr>$leftColumn<td>"; |
193 | 173 | $this->output->addHTML( $html ); |
194 | 174 | |
195 | 175 | $this->showThread( $t ); |
196 | | - |
| 176 | + |
197 | 177 | $this->output->addHTML( "</td></tr>" ); |
198 | 178 | } |
199 | 179 | |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoryListingView.php |
— | — | @@ -13,90 +13,92 @@ |
14 | 14 | } |
15 | 15 | self::addJSandCSS(); |
16 | 16 | wfLoadExtensionMessages( 'LiquidThreads' ); |
17 | | - |
| 17 | + |
18 | 18 | $this->thread->updateHistory(); |
19 | 19 | |
20 | 20 | $this->output->setPageTitle( wfMsg( 'lqt-history-title' ) ); |
21 | 21 | $this->output->setSubtitle( $this->getSubtitle() . '<br />' . |
22 | 22 | wfMsg( 'lqt_hist_listing_subtitle' ) ); |
23 | 23 | $this->showThreadHeading( $this->thread ); |
24 | | - |
| 24 | + |
25 | 25 | $pager = new ThreadHistoryPager( $this, $this->thread ); |
26 | | - |
| 26 | + |
27 | 27 | $html = $pager->getNavigationBar() . |
28 | 28 | $pager->getBody() . |
29 | 29 | $pager->getNavigationBar(); |
30 | | - |
| 30 | + |
31 | 31 | $this->output->addHTML( $html ); |
32 | | - |
| 32 | + |
33 | 33 | $this->showThread( $this->thread ); |
34 | | - |
| 34 | + |
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | class ThreadHistoryPager extends TablePager { |
40 | 40 | static $change_names; |
| 41 | + |
41 | 42 | |
42 | | - |
43 | 43 | function __construct( $view, $thread ) { |
44 | 44 | parent::__construct(); |
45 | | - |
| 45 | + |
46 | 46 | $this->thread = $thread; |
47 | 47 | $this->view = $view; |
48 | | - |
49 | | - self::$change_names = array( |
50 | | - Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ), |
51 | | - Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ), |
52 | | - Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ), |
53 | | - Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ), |
54 | | - Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ), |
55 | | - Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ), |
56 | | - Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ), |
57 | | - Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ), |
58 | | - Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ), |
59 | | - Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ), |
60 | | - Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ), |
61 | | - Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ), |
62 | | - ); |
| 48 | + |
| 49 | + self::$change_names = |
| 50 | + array( |
| 51 | + Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ), |
| 52 | + Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ), |
| 53 | + Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ), |
| 54 | + Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ), |
| 55 | + Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ), |
| 56 | + Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ), |
| 57 | + Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ), |
| 58 | + Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ), |
| 59 | + Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ), |
| 60 | + Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ), |
| 61 | + Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ), |
| 62 | + Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ), |
| 63 | + ); |
63 | 64 | } |
64 | | - |
| 65 | + |
65 | 66 | function getQueryInfo() { |
66 | | - $queryInfo = array( |
67 | | - 'tables' => array( 'thread_history' ), |
68 | | - 'fields' => '*', |
69 | | - 'conds' => array( 'th_thread' => $this->thread->id() ), |
70 | | - 'options' => array( 'order by' => 'th_timestamp desc' ), |
71 | | - ); |
72 | | - |
| 67 | + $queryInfo = |
| 68 | + array( |
| 69 | + 'tables' => array( 'thread_history' ), |
| 70 | + 'fields' => '*', |
| 71 | + 'conds' => array( 'th_thread' => $this->thread->id() ), |
| 72 | + 'options' => array( 'order by' => 'th_timestamp desc' ), |
| 73 | + ); |
| 74 | + |
73 | 75 | return $queryInfo; |
74 | 76 | } |
75 | | - |
| 77 | + |
76 | 78 | function getFieldNames() { |
77 | 79 | static $headers = null; |
78 | 80 | |
79 | | - if ( !empty( $headers ) ) { |
| 81 | + if (!empty($headers)) { |
80 | 82 | return $headers; |
81 | 83 | } |
82 | 84 | |
83 | | - $headers = array( |
84 | | - 'th_timestamp' => 'lqt-history-time', |
85 | | - 'th_user_text' => 'lqt-history-user', |
| 85 | + $headers = array( |
| 86 | + 'th_timestamp' => 'lqt-history-time', |
| 87 | + 'th_user_text' => 'lqt-history-user', |
86 | 88 | 'th_change_type' => 'lqt-history-action', |
87 | | - 'th_change_comment' => 'lqt-history-comment', |
88 | | - ); |
| 89 | + 'th_change_comment' => 'lqt-history-comment', |
| 90 | + ); |
89 | 91 | |
90 | 92 | $headers = array_map( 'wfMsg', $headers ); |
91 | 93 | |
92 | 94 | return $headers; |
93 | 95 | } |
94 | | - |
| 96 | + |
95 | 97 | function formatValue( $name, $value ) { |
96 | | - global $wgOut, $wgLang, $wgTitle; |
| 98 | + global $wgOut,$wgLang, $wgTitle; |
97 | 99 | |
98 | | - static $sk = null; |
| 100 | + static $sk=null; |
99 | 101 | |
100 | | - if ( empty( $sk ) ) { |
| 102 | + if (empty($sk)) { |
101 | 103 | global $wgUser; |
102 | 104 | $sk = $wgUser->getSkin(); |
103 | 105 | } |
— | — | @@ -105,7 +107,7 @@ |
106 | 108 | |
107 | 109 | $formatted = ''; |
108 | 110 | |
109 | | - switch( $name ) { |
| 111 | + switch($name) { |
110 | 112 | case 'th_timestamp': |
111 | 113 | $formatted = $wgLang->timeanddate( $value ); |
112 | 114 | return $sk->link( $wgTitle, $formatted, array(), |
— | — | @@ -122,19 +124,20 @@ |
123 | 125 | break; |
124 | 126 | } |
125 | 127 | } |
126 | | - |
| 128 | + |
127 | 129 | function getIndexField() { |
128 | 130 | return 'th_timestamp'; |
129 | 131 | } |
130 | | - |
| 132 | + |
131 | 133 | function getDefaultSort() { |
132 | 134 | return 'th_timestamp'; |
133 | 135 | } |
134 | 136 | |
135 | | - function isFieldSortable( $name ) { |
| 137 | + function isFieldSortable($name) { |
136 | 138 | $sortable_fields = array( 'th_timestamp', 'th_user_text', 'th_change_type' ); |
137 | 139 | return in_array( $name, $sortable_fields ); |
138 | 140 | } |
139 | | - |
| 141 | + |
140 | 142 | function getDefaultDirections() { return true; /* descending */ } |
141 | 143 | } |
| 144 | + |
Index: trunk/extensions/LiquidThreads/migrateDatabase.php |
— | — | @@ -3,73 +3,71 @@ |
4 | 4 | // Utility script to update your LiquidThreads installation by batch-running lazy updates |
5 | 5 | // normally done on-demand when a thread is loaded. Also runs any necessary database updates. |
6 | 6 | |
7 | | -require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
8 | | - ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
| 7 | +require_once ( getenv('MW_INSTALL_PATH') !== false |
| 8 | + ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
9 | 9 | : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
10 | | - |
| 10 | + |
11 | 11 | $db = wfGetDB( DB_MASTER ); |
12 | 12 | |
13 | 13 | // Do database updates |
14 | | -$threadFieldUpdates = array( |
15 | | - 'thread_article_namespace' => 'split-thread_article.sql', |
16 | | - 'thread_article_title' => 'split-thread_article.sql', |
17 | | - 'thread_ancestor' => 'normalise-ancestry.sql', |
18 | | - 'thread_parent' => 'normalise-ancestry.sql', |
19 | | - 'thread_modified' => 'split-timestamps.sql', |
20 | | - 'thread_created' => 'split-timestamps.sql', |
21 | | - 'thread_editedness' => 'store-editedness.sql', |
22 | | - 'thread_subject' => 'store_subject-author.sql', |
23 | | - 'thread_author_id' => 'store_subject-author.sql', |
24 | | - 'thread_author_name' => 'store_subject-author.sql', |
25 | | -); |
26 | | -$threadIndexUpdates = array( 'thread_summary_page' => 'index-summary_page.sql' ); |
| 14 | +$threadFieldUpdates = array('thread_article_namespace' => 'split-thread_article.sql', |
| 15 | + 'thread_article_title' => 'split-thread_article.sql', |
| 16 | + 'thread_ancestor' => 'normalise-ancestry.sql', |
| 17 | + 'thread_parent' => 'normalise-ancestry.sql', |
| 18 | + 'thread_modified' => 'split-timestamps.sql', |
| 19 | + 'thread_created' => 'split-timestamps.sql', |
| 20 | + 'thread_editedness' => 'store-editedness.sql', |
| 21 | + 'thread_subject' => 'store_subject-author.sql', |
| 22 | + 'thread_author_id' => 'store_subject-author.sql', |
| 23 | + 'thread_author_name' => 'store_subject-author.sql', |
| 24 | + ); |
| 25 | +$threadIndexUpdates = array('thread_summary_page' => 'index-summary_page.sql'); |
27 | 26 | |
28 | 27 | $newTableUpdates = array( 'thread_history' => 'thread_history_table.sql' ); |
29 | 28 | |
30 | | -foreach ( $threadFieldUpdates as $field => $patch ) { |
31 | | - if ( !$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) { |
32 | | - dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
| 29 | +foreach( $threadFieldUpdates as $field => $patch ) { |
| 30 | + if (!$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) { |
| 31 | + dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
33 | 32 | } |
34 | 33 | } |
35 | 34 | |
36 | | -foreach ( $threadIndexUpdates as $index => $patch ) { |
37 | | - if ( !$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) { |
38 | | - dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
| 35 | +foreach( $threadIndexUpdates as $index => $patch ) { |
| 36 | + if (!$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) { |
| 37 | + dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
39 | 38 | } |
40 | 39 | } |
41 | 40 | |
42 | | -foreach ( $newTableUpdates as $table => $patch ) { |
43 | | - if ( !$db->tableExists( $table, 'lqt-update-script' ) ) { |
44 | | - dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
| 41 | +foreach( $newTableUpdates as $table => $patch ) { |
| 42 | + if (!$db->tableExists( $table, 'lqt-update-script' ) ) { |
| 43 | + dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
45 | 44 | } |
46 | 45 | } |
47 | 46 | |
| 47 | + |
48 | 48 | // Batch lazy updates |
49 | 49 | $upTo = $lastUpTo = 0; |
50 | 50 | |
51 | 51 | do { |
52 | 52 | $lastUpTo = $upTo; |
53 | | - |
| 53 | + |
54 | 54 | $db->begin(); |
55 | | - |
| 55 | + |
56 | 56 | // Read 500 rows |
57 | | - $res = $db->select( |
58 | | - 'thread', '*', array( 'thread_id>' . $db->addQuotes( $upTo ) ), |
59 | | - 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE', |
60 | | - 'ORDER BY' => 'thread_id asc' ) |
61 | | - ); |
62 | | - |
| 57 | + $res = $db->select( 'thread', '*', array( 'thread_id>'.$db->addQuotes($upTo ) ), |
| 58 | + 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE', |
| 59 | + 'ORDER BY' => 'thread_id asc' ) ); |
| 60 | + |
63 | 61 | $threads = Threads::loadFromResult( $res, $db ); |
64 | | - |
65 | | - foreach ( $threads as $thread ) { |
| 62 | + |
| 63 | + foreach( $threads as $thread ) { |
66 | 64 | $thread->doLazyUpdates(); |
67 | 65 | $thread->updateHistory(); |
68 | | - |
| 66 | + |
69 | 67 | if ( $thread->id() > $upTo ) { |
70 | 68 | $upTo = $thread->id(); |
71 | 69 | } |
72 | 70 | } |
73 | | - |
| 71 | + |
74 | 72 | $db->commit(); |
75 | | - |
| 73 | + |
76 | 74 | } while ( $lastUpTo != $upTo ); |
Property changes on: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php |
___________________________________________________________________ |
Deleted: svn:eol-style |
77 | 75 | - native |
Index: trunk/extensions/LiquidThreads/LqtFunctions.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * Recreate the original associative array so that a new pair with the given key |
21 | 21 | * and value is inserted before the given existing key. $original_array gets |
22 | 22 | * modified in-place. |
23 | | - */ |
| 23 | +*/ |
24 | 24 | function efInsertIntoAssoc( $new_key, $new_value, $before, &$original_array ) { |
25 | 25 | $ordered = array(); |
26 | 26 | $i = 0; |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | function lqtSetupParserFunctions() { |
47 | 47 | global $wgParser; |
48 | | - |
| 48 | + |
49 | 49 | $wgParser->setFunctionHook( 'useliquidthreads', |
50 | 50 | array( 'LqtParserFunctions', 'useLiquidThreads' ) ); |
51 | 51 | return true; |
Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | 'lqt-thread-split' => 'Split to new thread', |
185 | 185 | 'lqt-split-success' => 'You have successfully split off the thread $1.', |
186 | 186 | 'lqt_split_thread' => 'Split a thread', |
187 | | - 'lqt-thread-split-subject' => 'New thread subject:', |
| 187 | + 'lqt-thread-split-subject'=> 'New thread subject:', |
188 | 188 | 'lqt-thread-split-thread' => 'Thread:', |
189 | 189 | 'lqt-split-submit' => 'Split', |
190 | 190 | 'lqt_split_badsubject' => 'The subject you entered is invalid.', |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | 'lqt-ajax-update-link' => 'Update', |
251 | 251 | 'lqt-thread-show-replies' => 'Show $1 replies', |
252 | 252 | 'lqt-thread-show-more' => 'Show more replies', |
253 | | - |
| 253 | + |
254 | 254 | // Feeds |
255 | 255 | 'lqt-feed-title-all' => '{{SITENAME}} — New posts', |
256 | 256 | 'lqt-feed-title-all-from' => '{{SITENAME}} — New posts from $1', |
— | — | @@ -1426,7 +1426,7 @@ |
1427 | 1427 | 'lqt_invalid_subject' => 'El tema que heu introduït no és vàlid. |
1428 | 1428 | Pot: |
1429 | 1429 | * contenir caràcters no vàlids, com []{}<>, |
1430 | | -* ser massa llarg, o |
| 1430 | +* ser massa llarg, o |
1431 | 1431 | * entrar en conflicte amb prefixos interwiki o altres espai de noms.', |
1432 | 1432 | 'lqt_subject_change_forbidden' => "No podeu canviar el tema d'aquest fil perquè no teniu el permís de moure les pàgines.", |
1433 | 1433 | 'lqt_in_response_to' => 'En resposta a $1 per $2, amunt:', |