Index: trunk/phase3/includes/PatrolLog.php |
— | — | @@ -35,16 +35,14 @@ |
36 | 36 | * |
37 | 37 | * @param $title Title of the page that was patrolled |
38 | 38 | * @param $params Array: log parameters (from logging.log_params) |
39 | | - * @param $skin Skin to use for building links, etc. |
| 39 | + * @param $lang Language object to use, or false |
40 | 40 | * @return String |
41 | 41 | */ |
42 | | - public static function makeActionText( $title, $params, $skin ) { |
43 | | - global $wgLang; |
44 | | - |
| 42 | + public static function makeActionText( $title, $params, $lang ) { |
45 | 43 | list( $cur, /* $prev */, $auto ) = $params; |
46 | | - if( is_object( $skin ) ) { |
| 44 | + if( is_object( $lang ) ) { |
47 | 45 | # Standard link to the page in question |
48 | | - $link = $skin->link( $title ); |
| 46 | + $link = Linker::link( $title ); |
49 | 47 | if( $title->exists() ) { |
50 | 48 | # Generate a diff link |
51 | 49 | $query = array( |
— | — | @@ -52,9 +50,9 @@ |
53 | 51 | 'diff' => 'prev' |
54 | 52 | ); |
55 | 53 | |
56 | | - $diff = $skin->link( |
| 54 | + $diff = Linker::link( |
57 | 55 | $title, |
58 | | - htmlspecialchars( wfMsg( 'patrol-log-diff', $wgLang->formatNum( $cur, true ) ) ), |
| 56 | + htmlspecialchars( wfMsg( 'patrol-log-diff', $lang->formatNum( $cur, true ) ) ), |
59 | 57 | array(), |
60 | 58 | $query, |
61 | 59 | array( 'known', 'noclasses' ) |
Index: trunk/phase3/includes/revisiondelete/RevisionDeleter.php |
— | — | @@ -67,45 +67,36 @@ |
68 | 68 | * @param $count Integer: The number of effected revisions. |
69 | 69 | * @param $nbitfield Integer: The new bitfield for the revision. |
70 | 70 | * @param $obitfield Integer: The old bitfield for the revision. |
| 71 | + * @param $language Language object to use |
71 | 72 | * @param $isForLog Boolean |
72 | | - * @param $forContent Boolean |
73 | 73 | */ |
74 | | - public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false, $forContent = false ) { |
75 | | - global $wgLang, $wgContLang; |
76 | | - |
77 | | - $lang = $forContent ? $wgContLang : $wgLang; |
78 | | - $msgFunc = $forContent ? "wfMsgForContent" : "wfMsg"; |
79 | | - |
| 74 | + public static function getLogMessage( $count, $nbitfield, $obitfield, $language, $isForLog = false ) { |
80 | 75 | $changes = self::getChanges( $nbitfield, $obitfield ); |
81 | | - array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $forContent ); |
| 76 | + array_walk( $changes, array( __CLASS__, 'expandMessageArray' ), $language ); |
82 | 77 | |
83 | 78 | $changesText = array(); |
84 | 79 | |
85 | 80 | if( count( $changes[0] ) ) { |
86 | | - $changesText[] = $msgFunc( 'revdelete-hid', $lang->commaList( $changes[0] ) ); |
| 81 | + $changesText[] = wfMsgExt( 'revdelete-hid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[0] ) ); |
87 | 82 | } |
88 | 83 | if( count( $changes[1] ) ) { |
89 | | - $changesText[] = $msgFunc( 'revdelete-unhid', $lang->commaList( $changes[1] ) ); |
| 84 | + $changesText[] = wfMsgExt( 'revdelete-unhid', array( 'parsemag', 'language' => $language ), $language->commaList( $changes[1] ) ); |
90 | 85 | } |
91 | 86 | |
92 | | - $s = $lang->semicolonList( $changesText ); |
| 87 | + $s = $language->semicolonList( $changesText ); |
93 | 88 | if( count( $changes[2] ) ) { |
94 | 89 | $s .= $s ? ' (' . $changes[2][0] . ')' : ' ' . $changes[2][0]; |
95 | 90 | } |
96 | 91 | |
97 | 92 | $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message'; |
98 | | - return wfMsgExt( $msg, $forContent ? array( 'parsemag', 'content' ) : array( 'parsemag' ), $s, $lang->formatNum($count) ); |
| 93 | + return wfMsgExt( $msg, array( 'parsemag', 'language' => $language ), $s, $language->formatNum($count) ); |
99 | 94 | } |
100 | 95 | |
101 | | - private static function expandMessageArray(& $msg, $key, $forContent) { |
| 96 | + private static function expandMessageArray( &$msg, $key, $language ) { |
102 | 97 | if ( is_array ( $msg ) ) { |
103 | | - array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $forContent ); |
| 98 | + array_walk( $msg, array( __CLASS__, 'expandMessageArray' ), $language ); |
104 | 99 | } else { |
105 | | - if ( $forContent ) { |
106 | | - $msg = wfMsgForContent($msg); |
107 | | - } else { |
108 | | - $msg = wfMsg($msg); |
109 | | - } |
| 100 | + $msg = wfMsgExt( $msg, array( 'parsemag', 'language' => $language ) ); |
110 | 101 | } |
111 | 102 | } |
112 | 103 | |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -169,7 +169,7 @@ |
170 | 170 | $hideVal = 1 - intval($val); |
171 | 171 | $query[$queryKey] = $hideVal; |
172 | 172 | |
173 | | - $link = $this->skin->link( |
| 173 | + $link = Linker::link( |
174 | 174 | $this->getDisplayTitle(), |
175 | 175 | $messages[$hideVal], |
176 | 176 | array(), |
— | — | @@ -352,10 +352,10 @@ |
353 | 353 | $userLinks = '<span class="history-deleted">' . |
354 | 354 | wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
355 | 355 | } else { |
356 | | - $userLinks = $this->skin->userLink( $row->log_user, $row->user_name ); |
| 356 | + $userLinks = Linker::userLink( $row->log_user, $row->user_name ); |
357 | 357 | // Talk|Contribs links... |
358 | 358 | if( !( $this->flags & self::NO_EXTRA_USER_LINKS ) ) { |
359 | | - $userLinks .= $this->skin->userToolLinks( |
| 359 | + $userLinks .= Linker::userToolLinks( |
360 | 360 | $row->log_user, $row->user_name, true, 0, $row->user_editcount ); |
361 | 361 | } |
362 | 362 | } |
— | — | @@ -380,7 +380,7 @@ |
381 | 381 | } else { |
382 | 382 | global $wgLang; |
383 | 383 | $comment = $wgLang->getDirMark() . |
384 | | - $this->skin->commentBlock( $row->log_comment ); |
| 384 | + Linker::commentBlock( $row->log_comment ); |
385 | 385 | } |
386 | 386 | return $comment; |
387 | 387 | } |
— | — | @@ -405,7 +405,7 @@ |
406 | 406 | if( self::typeAction( $row, 'move', 'move', 'move' ) && !empty( $paramArray[0] ) ) { |
407 | 407 | $destTitle = Title::newFromText( $paramArray[0] ); |
408 | 408 | if( $destTitle ) { |
409 | | - $revert = '(' . $this->skin->link( |
| 409 | + $revert = '(' . Linker::link( |
410 | 410 | SpecialPage::getTitleFor( 'Movepage' ), |
411 | 411 | $this->message['revertmove'], |
412 | 412 | array(), |
— | — | @@ -425,7 +425,7 @@ |
426 | 426 | } else { |
427 | 427 | $viewdeleted = $this->message['undeletelink']; |
428 | 428 | } |
429 | | - $revert = '(' . $this->skin->link( |
| 429 | + $revert = '(' . Linker::link( |
430 | 430 | SpecialPage::getTitleFor( 'Undelete' ), |
431 | 431 | $viewdeleted, |
432 | 432 | array(), |
— | — | @@ -435,7 +435,7 @@ |
436 | 436 | // Show unblock/change block link |
437 | 437 | } elseif( self::typeAction( $row, array( 'block', 'suppress' ), array( 'block', 'reblock' ), 'block' ) ) { |
438 | 438 | $revert = '(' . |
439 | | - $this->skin->link( |
| 439 | + Linker::link( |
440 | 440 | SpecialPage::getTitleFor( 'Unblock', $row->log_title ), |
441 | 441 | $this->message['unblocklink'], |
442 | 442 | array(), |
— | — | @@ -443,7 +443,7 @@ |
444 | 444 | 'known' |
445 | 445 | ) . |
446 | 446 | $this->message['pipe-separator'] . |
447 | | - $this->skin->link( |
| 447 | + Linker::link( |
448 | 448 | SpecialPage::getTitleFor( 'Block', $row->log_title ), |
449 | 449 | $this->message['change-blocklink'], |
450 | 450 | array(), |
— | — | @@ -454,7 +454,7 @@ |
455 | 455 | // Show change protection link |
456 | 456 | } elseif( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) { |
457 | 457 | $revert .= ' (' . |
458 | | - $this->skin->link( $title, |
| 458 | + Linker::link( $title, |
459 | 459 | $this->message['hist'], |
460 | 460 | array(), |
461 | 461 | array( |
— | — | @@ -464,7 +464,7 @@ |
465 | 465 | ); |
466 | 466 | if( $wgUser->isAllowed( 'protect' ) ) { |
467 | 467 | $revert .= $this->message['pipe-separator'] . |
468 | | - $this->skin->link( $title, |
| 468 | + Linker::link( $title, |
469 | 469 | $this->message['protect_change'], |
470 | 470 | array(), |
471 | 471 | array( 'action' => 'protect' ), |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | $revert .= ')'; |
475 | 475 | // Show unmerge link |
476 | 476 | } elseif( self::typeAction( $row, 'merge', 'merge', 'mergehistory' ) ) { |
477 | | - $revert = '(' . $this->skin->link( |
| 477 | + $revert = '(' . Linker::link( |
478 | 478 | SpecialPage::getTitleFor( 'MergeHistory' ), |
479 | 479 | $this->message['revertmerge'], |
480 | 480 | array(), |
— | — | @@ -495,7 +495,7 @@ |
496 | 496 | // $paramArray[1] is a CSV of the IDs |
497 | 497 | $query = $paramArray[0]; |
498 | 498 | // Link to each hidden object ID, $paramArray[1] is the url param |
499 | | - $revert = '(' . $this->skin->link( |
| 499 | + $revert = '(' . Linker::link( |
500 | 500 | $revdel, |
501 | 501 | $this->message['revdel-restore'], |
502 | 502 | array(), |
— | — | @@ -510,10 +510,10 @@ |
511 | 511 | // Self-created users |
512 | 512 | } elseif( self::typeAction( $row, 'newusers', 'create2' ) ) { |
513 | 513 | if( isset( $paramArray[0] ) ) { |
514 | | - $revert = $this->skin->userToolLinks( $paramArray[0], $title->getDBkey(), true ); |
| 514 | + $revert = Linker::userToolLinks( $paramArray[0], $title->getDBkey(), true ); |
515 | 515 | } else { |
516 | 516 | # Fall back to a blue contributions link |
517 | | - $revert = $this->skin->userToolLinks( 1, $title->getDBkey() ); |
| 517 | + $revert = Linker::userToolLinks( 1, $title->getDBkey() ); |
518 | 518 | } |
519 | 519 | if( wfTimestamp( TS_MW, $row->log_timestamp ) < '20080129000000' ) { |
520 | 520 | # Suppress $comment from old entries (before 2008-01-29), |
— | — | @@ -548,7 +548,7 @@ |
549 | 549 | $canHide = $wgUser->isAllowed( 'deleterevision' ); |
550 | 550 | // If event was hidden from sysops |
551 | 551 | if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) { |
552 | | - $del = $this->skin->revDeleteLinkDisabled( $canHide ); |
| 552 | + $del = Linker::revDeleteLinkDisabled( $canHide ); |
553 | 553 | } else { |
554 | 554 | $target = SpecialPage::getTitleFor( 'Log', $row->log_type ); |
555 | 555 | $query = array( |
— | — | @@ -556,7 +556,7 @@ |
557 | 557 | 'type' => 'logging', |
558 | 558 | 'ids' => $row->log_id, |
559 | 559 | ); |
560 | | - $del = $this->skin->revDeleteLink( $query, |
| 560 | + $del = Linker::revDeleteLink( $query, |
561 | 561 | self::isDeleted( $row, LogPage::DELETED_RESTRICTED ), $canHide ); |
562 | 562 | } |
563 | 563 | } |
— | — | @@ -716,7 +716,7 @@ |
717 | 717 | # If there is exactly one log type, we can link to Special:Log?type=foo |
718 | 718 | if ( count( $types ) == 1 ) |
719 | 719 | $urlParam['type'] = $types[0]; |
720 | | - $s .= $wgUser->getSkin()->link( |
| 720 | + $s .= Linker::link( |
721 | 721 | SpecialPage::getTitleFor( 'Log' ), |
722 | 722 | wfMsgHtml( 'log-fulllog' ), |
723 | 723 | array(), |
Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -207,26 +207,32 @@ |
208 | 208 | { |
209 | 209 | global $wgLang, $wgContLang, $wgLogActions; |
210 | 210 | |
| 211 | + if ( is_null( $skin ) ) { |
| 212 | + $langObj = $wgContLang; |
| 213 | + $langObjOrNull = null; |
| 214 | + } else { |
| 215 | + $langObj = $wgLang; |
| 216 | + $langObjOrNull = $wgLang; |
| 217 | + } |
| 218 | + |
211 | 219 | $key = "$type/$action"; |
212 | 220 | # Defer patrol log to PatrolLog class |
213 | 221 | if( $key == 'patrol/patrol' ) { |
214 | | - return PatrolLog::makeActionText( $title, $params, $skin ); |
| 222 | + return PatrolLog::makeActionText( $title, $params, $langObjOrNull ); |
215 | 223 | } |
216 | 224 | if( isset( $wgLogActions[$key] ) ) { |
217 | 225 | if( is_null( $title ) ) { |
218 | | - $rv = wfMsgHtml( $wgLogActions[$key] ); |
| 226 | + $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'language' => $langObj ) ); |
219 | 227 | } else { |
220 | | - $titleLink = self::getTitleLink( $type, $skin, $title, $params ); |
| 228 | + $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params ); |
221 | 229 | if( preg_match( '/^rights\/(rights|autopromote)/', $key ) ) { |
| 230 | + $rightsnone = wfMsgExt( 'rightsnone', array( 'parsemag', 'language' => $langObj ) ); |
222 | 231 | if( $skin ) { |
223 | | - $rightsnone = wfMsg( 'rightsnone' ); |
224 | 232 | foreach ( $params as &$param ) { |
225 | 233 | $groupArray = array_map( 'trim', explode( ',', $param ) ); |
226 | 234 | $groupArray = array_map( array( 'User', 'getGroupMember' ), $groupArray ); |
227 | 235 | $param = $wgLang->listToText( $groupArray ); |
228 | 236 | } |
229 | | - } else { |
230 | | - $rightsnone = wfMsgForContent( 'rightsnone' ); |
231 | 237 | } |
232 | 238 | if( !isset( $params[0] ) || trim( $params[0] ) == '' ) { |
233 | 239 | $params[0] = $rightsnone; |
— | — | @@ -236,11 +242,7 @@ |
237 | 243 | } |
238 | 244 | } |
239 | 245 | if( count( $params ) == 0 ) { |
240 | | - if ( $skin ) { |
241 | | - $rv = wfMsgHtml( $wgLogActions[$key], $titleLink ); |
242 | | - } else { |
243 | | - $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $titleLink ); |
244 | | - } |
| 246 | + $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $titleLink ); |
245 | 247 | } else { |
246 | 248 | $details = ''; |
247 | 249 | array_unshift( $params, $titleLink ); |
— | — | @@ -253,7 +255,7 @@ |
254 | 256 | $params[1] = $wgContLang->translateBlockExpiry( $params[1] ); |
255 | 257 | } |
256 | 258 | $params[2] = isset( $params[2] ) ? |
257 | | - self::formatBlockFlags( $params[2], is_null( $skin ) ) : ''; |
| 259 | + self::formatBlockFlags( $params[2], $langObj ) : ''; |
258 | 260 | |
259 | 261 | // Page protections |
260 | 262 | } elseif ( $type == 'protect' && count($params) == 3 ) { |
— | — | @@ -265,21 +267,13 @@ |
266 | 268 | } |
267 | 269 | // Cascading flag... |
268 | 270 | if( $params[2] ) { |
269 | | - if ( $skin ) { |
270 | | - $details .= ' [' . wfMsg( 'protect-summary-cascade' ) . ']'; |
271 | | - } else { |
272 | | - $details .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']'; |
273 | | - } |
| 271 | + $details .= ' [' . wfMsgExt( 'protect-summary-cascade', array( 'parsemag', 'language' => $langObj ) ) . ']'; |
274 | 272 | } |
275 | 273 | |
276 | 274 | // Page moves |
277 | 275 | } elseif ( $type == 'move' && count( $params ) == 3 ) { |
278 | 276 | if( $params[2] ) { |
279 | | - if ( $skin ) { |
280 | | - $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']'; |
281 | | - } else { |
282 | | - $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']'; |
283 | | - } |
| 277 | + $details .= ' [' . wfMsgExt( 'move-redirect-suppressed', array( 'parsemag', 'language' => $langObj ) ) . ']'; |
284 | 278 | } |
285 | 279 | |
286 | 280 | // Revision deletion |
— | — | @@ -287,21 +281,17 @@ |
288 | 282 | $count = substr_count( $params[2], ',' ) + 1; // revisions |
289 | 283 | $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x> |
290 | 284 | $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x> |
291 | | - $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null( $skin ) ); |
| 285 | + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, false ); |
292 | 286 | |
293 | 287 | // Log deletion |
294 | 288 | } elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) { |
295 | 289 | $count = substr_count( $params[1], ',' ) + 1; // log items |
296 | 290 | $ofield = intval( substr( $params[2], 7 ) ); // <ofield=x> |
297 | 291 | $nfield = intval( substr( $params[3], 7 ) ); // <nfield=x> |
298 | | - $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null( $skin ) ); |
| 292 | + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, true ); |
299 | 293 | } |
300 | 294 | |
301 | | - if ( $skin ) { |
302 | | - $rv = wfMsgHtml( $wgLogActions[$key], $params ) . $details; |
303 | | - } else { |
304 | | - $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'content' ), $params ) . $details; |
305 | | - } |
| 295 | + $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $params ) . $details; |
306 | 296 | } |
307 | 297 | } |
308 | 298 | } else { |
— | — | @@ -335,14 +325,14 @@ |
336 | 326 | /** |
337 | 327 | * TODO document |
338 | 328 | * @param $type String |
339 | | - * @param $skin Skin |
| 329 | + * @param $lang Language or null |
340 | 330 | * @param $title Title |
341 | 331 | * @param $params Array |
342 | 332 | * @return String |
343 | 333 | */ |
344 | | - protected static function getTitleLink( $type, $skin, $title, &$params ) { |
345 | | - global $wgLang, $wgContLang, $wgUserrightsInterwikiDelimiter; |
346 | | - if( !$skin ) { |
| 334 | + protected static function getTitleLink( $type, $lang, $title, &$params ) { |
| 335 | + global $wgContLang, $wgUserrightsInterwikiDelimiter; |
| 336 | + if( !$lang ) { |
347 | 337 | return $title->getPrefixedText(); |
348 | 338 | } |
349 | 339 | switch( $type ) { |
— | — | @@ -398,7 +388,7 @@ |
399 | 389 | Title::newFromText( $params[0] ), |
400 | 390 | htmlspecialchars( $params[0] ) |
401 | 391 | ); |
402 | | - $params[1] = $wgLang->timeanddate( $params[1] ); |
| 392 | + $params[1] = $lang->timeanddate( $params[1] ); |
403 | 393 | break; |
404 | 394 | default: |
405 | 395 | if( $title->getNamespace() == NS_SPECIAL ) { |
— | — | @@ -507,19 +497,16 @@ |
508 | 498 | * into a more readable (and translated) form |
509 | 499 | * |
510 | 500 | * @param $flags Flags to format |
511 | | - * @param $forContent Whether to localize the message depending of the user |
512 | | - * language |
| 501 | + * @param $lang Language object to use |
513 | 502 | * @return String |
514 | 503 | */ |
515 | | - public static function formatBlockFlags( $flags, $forContent = false ) { |
516 | | - global $wgLang; |
517 | | - |
| 504 | + public static function formatBlockFlags( $flags, $lang ) { |
518 | 505 | $flags = explode( ',', trim( $flags ) ); |
519 | 506 | if( count( $flags ) > 0 ) { |
520 | 507 | for( $i = 0; $i < count( $flags ); $i++ ) { |
521 | | - $flags[$i] = self::formatBlockFlag( $flags[$i], $forContent ); |
| 508 | + $flags[$i] = self::formatBlockFlag( $flags[$i], $lang ); |
522 | 509 | } |
523 | | - return '(' . $wgLang->commaList( $flags ) . ')'; |
| 510 | + return '(' . $lang->commaList( $flags ) . ')'; |
524 | 511 | } else { |
525 | 512 | return ''; |
526 | 513 | } |
— | — | @@ -529,19 +516,15 @@ |
530 | 517 | * Translate a block log flag if possible |
531 | 518 | * |
532 | 519 | * @param $flag int Flag to translate |
533 | | - * @param $forContent Whether to localize the message depending of the user |
534 | | - * language |
| 520 | + * @param $lang Language object to use |
535 | 521 | * @return String |
536 | 522 | */ |
537 | | - public static function formatBlockFlag( $flag, $forContent = false ) { |
| 523 | + public static function formatBlockFlag( $flag, $lang ) { |
538 | 524 | static $messages = array(); |
539 | 525 | if( !isset( $messages[$flag] ) ) { |
540 | 526 | $messages[$flag] = htmlspecialchars( $flag ); // Fallback |
541 | 527 | |
542 | | - $msg = wfMessage( 'block-log-flags-' . $flag ); |
543 | | - if ( $forContent ) { |
544 | | - $msg->inContentLanguage(); |
545 | | - } |
| 528 | + $msg = wfMessage( 'block-log-flags-' . $flag )->inLanguage( $lang ); |
546 | 529 | if ( $msg->exists() ) { |
547 | 530 | $messages[$flag] = $msg->escaped(); |
548 | 531 | } |