Index: trunk/extensions/Reviews/includes/Review.php |
— | — | @@ -359,14 +359,42 @@ |
360 | 360 | public function getHTML( User $user, Language $lang ) { |
361 | 361 | $ratings = $this->getRatings( true ); |
362 | 362 | |
| 363 | + $controlLinks = array(); |
| 364 | + |
| 365 | + if ( $user->isAllowed( 'reviewsadmin' ) ) { |
| 366 | + $controlLinks[] = Linker::linkKnown( |
| 367 | + SpecialPage::getTitleFor( 'Reviews', $this->getId() ), |
| 368 | + wfMsg( 'reviews-review-details' ) |
| 369 | + ); |
| 370 | + } |
| 371 | + |
| 372 | + if ( $user->getId() === $this->getField( 'user_id' ) ) { |
| 373 | + $controlLinks[] = Linker::linkKnown( |
| 374 | + SpecialPage::getTitleFor( 'MyReviews', $this->getId() ), |
| 375 | + wfMsg( 'reviews-review-edit' ) |
| 376 | + ); |
| 377 | + } |
| 378 | + |
| 379 | + $stateControl = $this->getStateControl( $user, false ); |
| 380 | + |
363 | 381 | $html = '<table class="review-table">'; |
364 | 382 | |
365 | 383 | $html .= '<tr><th colspan="2" class="review-table-title">' . htmlspecialchars( $this->getField( 'title' ) ) . '</th></tr>'; |
366 | 384 | |
367 | 385 | $html .= '<tr>'; |
368 | 386 | |
369 | | - $html .= '<td rowspan="' . ( $this->hasRatings() ? 3 : 2 ) . '" class="review-author-box">'; |
| 387 | + $rowspan = 1; |
370 | 388 | |
| 389 | + if ( $this->hasRatings() ) { |
| 390 | + $rowspan++; |
| 391 | + } |
| 392 | + |
| 393 | + if ( count( $controlLinks ) > 0 || $stateControl !== '' ) { |
| 394 | + $rowspan++; |
| 395 | + } |
| 396 | + |
| 397 | + $html .= '<td rowspan="' . $rowspan . '" class="review-author-box">'; |
| 398 | + |
371 | 399 | $html .= ReviewRating::getDisplayHTMLFor( $this->getRating() ); |
372 | 400 | |
373 | 401 | $html .= Html::element( 'p', array( 'class' => 'reviews-posted-by' ), wfMsgExt( |
— | — | @@ -399,32 +427,18 @@ |
400 | 428 | $html .= '</tr>'; |
401 | 429 | } |
402 | 430 | |
403 | | - $html .= '<tr><td>'; |
404 | | - |
405 | | - $html .= $this->getStateControl( $user, false ); |
406 | | - |
407 | | - $controlLinks = array(); |
408 | | - |
409 | | - if ( $user->isAllowed( 'reviewsadmin' ) ) { |
410 | | - $controlLinks[] = Linker::linkKnown( |
411 | | - SpecialPage::getTitleFor( 'Reviews', $this->getId() ), |
412 | | - wfMsg( 'reviews-review-details' ) |
413 | | - ); |
| 431 | + if ( count( $controlLinks ) > 0 || $stateControl ) { |
| 432 | + $html .= '<tr><td>'; |
| 433 | + |
| 434 | + $html .= $stateControl; |
| 435 | + |
| 436 | + if ( count( $controlLinks ) > 0 ) { |
| 437 | + $html .= '(' . $lang->pipeList( $controlLinks ) . ')'; |
| 438 | + } |
| 439 | + |
| 440 | + $html .= '</td></tr>'; |
414 | 441 | } |
415 | 442 | |
416 | | - if ( $user->getId() === $this->getField( 'user_id' ) ) { |
417 | | - $controlLinks[] = Linker::linkKnown( |
418 | | - SpecialPage::getTitleFor( 'MyReviews', $this->getId() ), |
419 | | - wfMsg( 'reviews-review-edit' ) |
420 | | - ); |
421 | | - } |
422 | | - |
423 | | - if ( count( $controlLinks ) > 0 ) { |
424 | | - $html .= '(' . $lang->pipeList( $controlLinks ) . ')'; |
425 | | - } |
426 | | - |
427 | | - $html .= '</td></tr>'; |
428 | | - |
429 | 443 | $html .= '</table>'; |
430 | 444 | |
431 | 445 | return Html::openElement( |
— | — | @@ -486,23 +500,32 @@ |
487 | 501 | 'reviewed' => array(), |
488 | 502 | ); |
489 | 503 | |
| 504 | + $canView = false; |
| 505 | + |
490 | 506 | if ( $user->isAllowed( 'reviewsadmin' ) ) { |
491 | 507 | $states['new'] = array( 'flagged', 'reviewed' ); |
492 | 508 | $states['flagged'] = array( 'new', 'reviewed' ); |
493 | 509 | $states['reviewed'] = array( 'flagged' ); |
| 510 | + $canView = true; |
494 | 511 | } |
495 | 512 | else { |
496 | 513 | if ( $user->isAllowed( 'reviewreview' ) ) { |
497 | 514 | $states['flagged'] = array( 'new', 'reviewed' ); |
| 515 | + $canView = true; |
498 | 516 | } |
499 | 517 | |
500 | 518 | if ( $user->isAllowed( 'flagreview' ) ) { |
501 | 519 | $states['reviewed'] = array( 'flagged' ); |
502 | 520 | $states['new'][] = 'flagged'; |
503 | 521 | $states['new'] = array_unique( $states['new'] ); |
| 522 | + $canView = true; |
504 | 523 | } |
505 | 524 | } |
506 | 525 | |
| 526 | + if ( !$canView ) { |
| 527 | + return ''; |
| 528 | + } |
| 529 | + |
507 | 530 | $control = Html::element( |
508 | 531 | 'div', |
509 | 532 | array( |