Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -43,17 +43,17 @@ |
44 | 44 | var $updateRecentChanges, $sendToUDP; |
45 | 45 | |
46 | 46 | /** |
47 | | - * Constructor |
48 | | - * |
49 | | - * @param $type String: one of '', 'block', 'protect', 'rights', 'delete', |
50 | | - * 'upload', 'move' |
51 | | - * @param $rc Boolean: whether to update recent changes as well as the logging table |
52 | | - * @param $udp String: pass 'UDP' to send to the UDP feed if NOT sent to RC |
53 | | - */ |
| 47 | + * Constructor |
| 48 | + * |
| 49 | + * @param $type String: one of '', 'block', 'protect', 'rights', 'delete', |
| 50 | + * 'upload', 'move' |
| 51 | + * @param $rc Boolean: whether to update recent changes as well as the logging table |
| 52 | + * @param $udp String: pass 'UDP' to send to the UDP feed if NOT sent to RC |
| 53 | + */ |
54 | 54 | public function __construct( $type, $rc = true, $udp = 'skipUDP' ) { |
55 | 55 | $this->type = $type; |
56 | 56 | $this->updateRecentChanges = $rc; |
57 | | - $this->sendToUDP = ($udp == 'UDP'); |
| 57 | + $this->sendToUDP = ( $udp == 'UDP' ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | protected function saveContent() { |
— | — | @@ -77,23 +77,29 @@ |
78 | 78 | 'log_params' => $this->params |
79 | 79 | ); |
80 | 80 | $dbw->insert( 'logging', $data, __METHOD__ ); |
81 | | - $newId = !is_null($log_id) ? $log_id : $dbw->insertId(); |
| 81 | + $newId = !is_null( $log_id ) ? $log_id : $dbw->insertId(); |
82 | 82 | |
83 | 83 | # And update recentchanges |
84 | 84 | if( $this->updateRecentChanges ) { |
85 | 85 | $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); |
86 | | - RecentChange::notifyLog( $now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, |
87 | | - $this->action, $this->target, $this->comment, $this->params, $newId ); |
88 | | - } else if( $this->sendToUDP ) { |
| 86 | + RecentChange::notifyLog( |
| 87 | + $now, $titleObj, $this->doer, $this->getRcComment(), '', |
| 88 | + $this->type, $this->action, $this->target, $this->comment, |
| 89 | + $this->params, $newId |
| 90 | + ); |
| 91 | + } elseif( $this->sendToUDP ) { |
89 | 92 | # Don't send private logs to UDP |
90 | | - if( isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] !='*' ) { |
| 93 | + if( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) { |
91 | 94 | return true; |
92 | 95 | } |
93 | 96 | # Notify external application via UDP. |
94 | 97 | # We send this to IRC but do not want to add it the RC table. |
95 | 98 | $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); |
96 | | - $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $this->getRcComment(), '', |
97 | | - $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); |
| 99 | + $rc = RecentChange::newLogEntry( |
| 100 | + $now, $titleObj, $this->doer, $this->getRcComment(), '', |
| 101 | + $this->type, $this->action, $this->target, $this->comment, |
| 102 | + $this->params, $newId |
| 103 | + ); |
98 | 104 | $rc->notifyRC2UDP(); |
99 | 105 | } |
100 | 106 | return $newId; |
— | — | @@ -105,10 +111,11 @@ |
106 | 112 | public function getRcComment() { |
107 | 113 | $rcComment = $this->actionText; |
108 | 114 | if( $this->comment != '' ) { |
109 | | - if ($rcComment == '') |
| 115 | + if ( $rcComment == '' ) { |
110 | 116 | $rcComment = $this->comment; |
111 | | - else |
| 117 | + } else { |
112 | 118 | $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment; |
| 119 | + } |
113 | 120 | } |
114 | 121 | return $rcComment; |
115 | 122 | } |
— | — | @@ -166,7 +173,7 @@ |
167 | 174 | */ |
168 | 175 | public static function logHeader( $type ) { |
169 | 176 | global $wgLogHeaders; |
170 | | - return wfMsgExt($wgLogHeaders[$type], array( 'parseinline' ) ); |
| 177 | + return wfMsgExt( $wgLogHeaders[$type], array( 'parseinline' ) ); |
171 | 178 | } |
172 | 179 | |
173 | 180 | /** |
— | — | @@ -176,13 +183,13 @@ |
177 | 184 | * @param $action String: log action |
178 | 185 | * @param $title Mixed: Title object or null |
179 | 186 | * @param $skin Mixed: Skin object or null. If null, we want to use the wiki |
180 | | - * content language, since that will go to the irc feed. |
| 187 | + * content language, since that will go to the IRC feed. |
181 | 188 | * @param $params Array: parameters |
182 | 189 | * @param $filterWikilinks Boolean: whether to filter wiki links |
183 | 190 | * @return HTML string |
184 | 191 | */ |
185 | 192 | public static function actionText( $type, $action, $title = null, $skin = null, |
186 | | - $params = array(), $filterWikilinks = false ) |
| 193 | + $params = array(), $filterWikilinks = false ) |
187 | 194 | { |
188 | 195 | global $wgLang, $wgContLang, $wgLogActions; |
189 | 196 | |
— | — | @@ -207,10 +214,12 @@ |
208 | 215 | } else { |
209 | 216 | $rightsnone = wfMsgForContent( 'rightsnone' ); |
210 | 217 | } |
211 | | - if( !isset( $params[0] ) || trim( $params[0] ) == '' ) |
| 218 | + if( !isset( $params[0] ) || trim( $params[0] ) == '' ) { |
212 | 219 | $params[0] = $rightsnone; |
213 | | - if( !isset( $params[1] ) || trim( $params[1] ) == '' ) |
| 220 | + } |
| 221 | + if( !isset( $params[1] ) || trim( $params[1] ) == '' ) { |
214 | 222 | $params[1] = $rightsnone; |
| 223 | + } |
215 | 224 | } |
216 | 225 | if( count( $params ) == 0 ) { |
217 | 226 | if ( $skin ) { |
— | — | @@ -224,16 +233,16 @@ |
225 | 234 | // User suppression |
226 | 235 | if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) { |
227 | 236 | if ( $skin ) { |
228 | | - $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . |
| 237 | + $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . |
229 | 238 | $wgLang->translateBlockExpiry( $params[1] ) . '</span>'; |
230 | 239 | } else { |
231 | 240 | $params[1] = $wgContLang->translateBlockExpiry( $params[1] ); |
232 | 241 | } |
233 | | - $params[2] = isset( $params[2] ) ? |
| 242 | + $params[2] = isset( $params[2] ) ? |
234 | 243 | self::formatBlockFlags( $params[2], is_null( $skin ) ) : ''; |
235 | 244 | |
236 | 245 | // Page protections |
237 | | - } else if ( $type == 'protect' && count($params) == 3 ) { |
| 246 | + } elseif ( $type == 'protect' && count($params) == 3 ) { |
238 | 247 | // Restrictions and expiries |
239 | 248 | if( $skin ) { |
240 | 249 | $details .= htmlspecialchars( " {$params[1]}" ); |
— | — | @@ -243,14 +252,14 @@ |
244 | 253 | // Cascading flag... |
245 | 254 | if( $params[2] ) { |
246 | 255 | if ( $skin ) { |
247 | | - $details .= ' ['.wfMsg('protect-summary-cascade').']'; |
| 256 | + $details .= ' [' . wfMsg( 'protect-summary-cascade' ) . ']'; |
248 | 257 | } else { |
249 | | - $details .= ' ['.wfMsgForContent('protect-summary-cascade').']'; |
| 258 | + $details .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']'; |
250 | 259 | } |
251 | 260 | } |
252 | 261 | |
253 | 262 | // Page moves |
254 | | - } else if ( $type == 'move' && count( $params ) == 3 && $action != 'move_rev' ) { |
| 263 | + } elseif ( $type == 'move' && count( $params ) == 3 && $action != 'move_rev' ) { |
255 | 264 | if( $params[2] ) { |
256 | 265 | if ( $skin ) { |
257 | 266 | $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']'; |
— | — | @@ -260,18 +269,18 @@ |
261 | 270 | } |
262 | 271 | |
263 | 272 | // Revision deletion |
264 | | - } else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) { |
| 273 | + } elseif ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) { |
265 | 274 | $count = substr_count( $params[2], ',' ) + 1; // revisions |
266 | 275 | $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x> |
267 | 276 | $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x> |
268 | | - $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null($skin) ); |
| 277 | + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false, is_null( $skin ) ); |
269 | 278 | |
270 | 279 | // Log deletion |
271 | | - } else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) { |
| 280 | + } elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) { |
272 | 281 | $count = substr_count( $params[1], ',' ) + 1; // log items |
273 | 282 | $ofield = intval( substr( $params[2], 7 ) ); // <ofield=x> |
274 | 283 | $nfield = intval( substr( $params[3], 7 ) ); // <nfield=x> |
275 | | - $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null($skin) ); |
| 284 | + $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true, is_null( $skin ) ); |
276 | 285 | } |
277 | 286 | |
278 | 287 | if ( $skin ) { |
— | — | @@ -291,24 +300,24 @@ |
292 | 301 | $rv = "$action"; |
293 | 302 | } |
294 | 303 | } |
295 | | - |
| 304 | + |
296 | 305 | // For the perplexed, this feature was added in r7855 by Erik. |
297 | | - // The feature was added because we liked adding [[$1]] in our log entries |
298 | | - // but the log entries are parsed as Wikitext on RecentChanges but as HTML |
299 | | - // on Special:Log. The hack is essentially that [[$1]] represented a link |
300 | | - // to the title in question. The first parameter to the HTML version (Special:Log) |
301 | | - // is that link in HTML form, and so this just gets rid of the ugly [[]]. |
302 | | - // However, this is a horrible hack and it doesn't work like you expect if, say, |
303 | | - // you want to link to something OTHER than the title of the log entry. |
304 | | - // The real problem, which Erik was trying to fix (and it sort-of works now) is |
305 | | - // that the same messages are being treated as both wikitext *and* HTML. |
| 306 | + // The feature was added because we liked adding [[$1]] in our log entries |
| 307 | + // but the log entries are parsed as Wikitext on RecentChanges but as HTML |
| 308 | + // on Special:Log. The hack is essentially that [[$1]] represented a link |
| 309 | + // to the title in question. The first parameter to the HTML version (Special:Log) |
| 310 | + // is that link in HTML form, and so this just gets rid of the ugly [[]]. |
| 311 | + // However, this is a horrible hack and it doesn't work like you expect if, say, |
| 312 | + // you want to link to something OTHER than the title of the log entry. |
| 313 | + // The real problem, which Erik was trying to fix (and it sort-of works now) is |
| 314 | + // that the same messages are being treated as both wikitext *and* HTML. |
306 | 315 | if( $filterWikilinks ) { |
307 | | - $rv = str_replace( "[[", "", $rv ); |
308 | | - $rv = str_replace( "]]", "", $rv ); |
| 316 | + $rv = str_replace( '[[', '', $rv ); |
| 317 | + $rv = str_replace( ']]', '', $rv ); |
309 | 318 | } |
310 | 319 | return $rv; |
311 | 320 | } |
312 | | - |
| 321 | + |
313 | 322 | protected static function getTitleLink( $type, $skin, $title, &$params ) { |
314 | 323 | global $wgLang, $wgContLang, $wgUserrightsInterwikiDelimiter; |
315 | 324 | if( !$skin ) { |
— | — | @@ -317,7 +326,7 @@ |
318 | 327 | switch( $type ) { |
319 | 328 | case 'move': |
320 | 329 | $titleLink = $skin->link( |
321 | | - $title, |
| 330 | + $title, |
322 | 331 | htmlspecialchars( $title->getPrefixedText() ), |
323 | 332 | array(), |
324 | 333 | array( 'redirect' => 'no' ) |
— | — | @@ -350,8 +359,9 @@ |
351 | 360 | if ( count( $parts ) == 2 ) { |
352 | 361 | $titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0], |
353 | 362 | htmlspecialchars( $title->getPrefixedText() ) ); |
354 | | - if ( $titleLink !== false ) |
| 363 | + if ( $titleLink !== false ) { |
355 | 364 | break; |
| 365 | + } |
356 | 366 | } |
357 | 367 | $titleLink = $skin->link( Title::makeTitle( NS_USER, $text ) ); |
358 | 368 | break; |
— | — | @@ -373,7 +383,7 @@ |
374 | 384 | list( $name, $par ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() ); |
375 | 385 | # Use the language name for log titles, rather than Log/X |
376 | 386 | if( $name == 'Log' ) { |
377 | | - $titleLink = '('.$skin->link( $title, LogPage::logName( $par ) ).')'; |
| 387 | + $titleLink = '(' . $skin->link( $title, LogPage::logName( $par ) ) . ')'; |
378 | 388 | } else { |
379 | 389 | $titleLink = $skin->link( $title ); |
380 | 390 | } |
— | — | @@ -398,27 +408,29 @@ |
399 | 409 | $params = array( $params ); |
400 | 410 | } |
401 | 411 | |
402 | | - if ( $comment === null ) $comment = ""; |
| 412 | + if ( $comment === null ) { |
| 413 | + $comment = ''; |
| 414 | + } |
403 | 415 | |
404 | 416 | $this->action = $action; |
405 | 417 | $this->target = $target; |
406 | 418 | $this->comment = $comment; |
407 | 419 | $this->params = LogPage::makeParamBlob( $params ); |
408 | | - |
409 | | - if ($doer === null) { |
| 420 | + |
| 421 | + if ( $doer === null ) { |
410 | 422 | global $wgUser; |
411 | 423 | $doer = $wgUser; |
412 | | - } elseif (!is_object( $doer ) ) { |
| 424 | + } elseif ( !is_object( $doer ) ) { |
413 | 425 | $doer = User::newFromId( $doer ); |
414 | 426 | } |
415 | | - |
| 427 | + |
416 | 428 | $this->doer = $doer; |
417 | 429 | |
418 | 430 | $this->actionText = LogPage::actionText( $this->type, $action, $target, null, $params ); |
419 | 431 | |
420 | 432 | return $this->saveContent(); |
421 | 433 | } |
422 | | - |
| 434 | + |
423 | 435 | /** |
424 | 436 | * Add relations to log_search table |
425 | 437 | * |
— | — | @@ -428,11 +440,16 @@ |
429 | 441 | * @return Boolean |
430 | 442 | */ |
431 | 443 | public function addRelations( $field, $values, $logid ) { |
432 | | - if( !strlen($field) || empty($values) ) |
| 444 | + if( !strlen( $field ) || empty( $values ) ) { |
433 | 445 | return false; // nothing |
| 446 | + } |
434 | 447 | $data = array(); |
435 | 448 | foreach( $values as $value ) { |
436 | | - $data[] = array('ls_field' => $field,'ls_value' => $value,'ls_log_id' => $logid); |
| 449 | + $data[] = array( |
| 450 | + 'ls_field' => $field, |
| 451 | + 'ls_value' => $value, |
| 452 | + 'ls_log_id' => $logid |
| 453 | + ); |
437 | 454 | } |
438 | 455 | $dbw = wfGetDB( DB_MASTER ); |
439 | 456 | $dbw->insert( 'log_search', $data, __METHOD__, 'IGNORE' ); |
— | — | @@ -477,8 +494,9 @@ |
478 | 495 | |
479 | 496 | $flags = explode( ',', trim( $flags ) ); |
480 | 497 | if( count( $flags ) > 0 ) { |
481 | | - for( $i = 0; $i < count( $flags ); $i++ ) |
| 498 | + for( $i = 0; $i < count( $flags ); $i++ ) { |
482 | 499 | $flags[$i] = self::formatBlockFlag( $flags[$i], $forContent ); |
| 500 | + } |
483 | 501 | return '(' . $wgLang->commaList( $flags ) . ')'; |
484 | 502 | } else { |
485 | 503 | return ''; |
— | — | @@ -497,10 +515,11 @@ |
498 | 516 | static $messages = array(); |
499 | 517 | if( !isset( $messages[$flag] ) ) { |
500 | 518 | $k = 'block-log-flags-' . $flag; |
501 | | - if( $forContent ) |
| 519 | + if( $forContent ) { |
502 | 520 | $msg = wfMsgForContent( $k ); |
503 | | - else |
| 521 | + } else { |
504 | 522 | $msg = wfMsg( $k ); |
| 523 | + } |
505 | 524 | $messages[$flag] = htmlspecialchars( wfEmptyMsg( $k, $msg ) ? $flag : $msg ); |
506 | 525 | } |
507 | 526 | return $messages[$flag]; |