Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | | - * @param $file File: |
| 32 | + * @param $file File: |
33 | 33 | * @return void |
34 | 34 | */ |
35 | 35 | public function setFile( $file ) { |
— | — | @@ -106,11 +106,13 @@ |
107 | 107 | $showmeta = false; |
108 | 108 | } |
109 | 109 | |
110 | | - if ( !$diff && $this->displayImg->exists() ) |
| 110 | + if ( !$diff && $this->displayImg->exists() ) { |
111 | 111 | $wgOut->addHTML( $this->showTOC( $showmeta ) ); |
| 112 | + } |
112 | 113 | |
113 | | - if ( !$diff ) |
| 114 | + if ( !$diff ) { |
114 | 115 | $this->openShowImage(); |
| 116 | + } |
115 | 117 | |
116 | 118 | # No need to display noarticletext, we use our own message, output in openShowImage() |
117 | 119 | if ( $this->getID() ) { |
— | — | @@ -147,8 +149,9 @@ |
148 | 150 | # Allow extensions to add something after the image links |
149 | 151 | $html = ''; |
150 | 152 | wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) ); |
151 | | - if ( $html ) |
| 153 | + if ( $html ) { |
152 | 154 | $wgOut->addHTML( $html ); |
| 155 | + } |
153 | 156 | |
154 | 157 | if ( $showmeta ) { |
155 | 158 | $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" ); |
— | — | @@ -191,8 +194,9 @@ |
192 | 195 | |
193 | 196 | public function isRedirect( $text = false ) { |
194 | 197 | $this->loadFile(); |
195 | | - if ( $this->img->isLocal() ) |
| 198 | + if ( $this->img->isLocal() ) { |
196 | 199 | return parent::isRedirect( $text ); |
| 200 | + } |
197 | 201 | |
198 | 202 | return (bool)$this->img->getRedirected(); |
199 | 203 | } |
— | — | @@ -217,7 +221,8 @@ |
218 | 222 | if ( !is_null( $this->dupes ) ) { |
219 | 223 | return $this->dupes; |
220 | 224 | } |
221 | | - if ( !( $hash = $this->img->getSha1() ) ) { |
| 225 | + $hash = $this->img->getSha1(); |
| 226 | + if ( !( $hash ) ) { |
222 | 227 | return $this->dupes = array(); |
223 | 228 | } |
224 | 229 | $dupes = RepoGroup::singleton()->findBySha1( $hash ); |
— | — | @@ -226,13 +231,14 @@ |
227 | 232 | $size = $this->img->getSize(); |
228 | 233 | foreach ( $dupes as $index => $file ) { |
229 | 234 | $key = $file->getRepoName() . ':' . $file->getName(); |
230 | | - if ( $key == $self ) |
| 235 | + if ( $key == $self ) { |
231 | 236 | unset( $dupes[$index] ); |
232 | | - if ( $file->getSize() != $size ) |
| 237 | + } |
| 238 | + if ( $file->getSize() != $size ) { |
233 | 239 | unset( $dupes[$index] ); |
| 240 | + } |
234 | 241 | } |
235 | 242 | return $this->dupes = $dupes; |
236 | | - |
237 | 243 | } |
238 | 244 | |
239 | 245 | /** |
— | — | @@ -243,9 +249,9 @@ |
244 | 250 | */ |
245 | 251 | protected function showTOC( $metadata ) { |
246 | 252 | $r = array( |
247 | | - '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>', |
248 | | - '<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>', |
249 | | - '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>', |
| 253 | + '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>', |
| 254 | + '<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>', |
| 255 | + '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>', |
250 | 256 | ); |
251 | 257 | if ( $metadata ) { |
252 | 258 | $r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>'; |
— | — | @@ -343,7 +349,7 @@ |
344 | 350 | # image |
345 | 351 | |
346 | 352 | # "Download high res version" link below the image |
347 | | - # $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime ); |
| 353 | + # $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime ); |
348 | 354 | # We'll show a thumbnail of this image |
349 | 355 | if ( $width > $maxWidth || $height > $maxHeight ) { |
350 | 356 | # Calculate the thumbnail size. |
— | — | @@ -382,7 +388,7 @@ |
383 | 389 | $thumbnail = $this->displayImg->transform( $params ); |
384 | 390 | |
385 | 391 | $showLink = true; |
386 | | - $anchorclose = "<br />" . $msgsmall; |
| 392 | + $anchorclose = '<br />' . $msgsmall; |
387 | 393 | |
388 | 394 | $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; |
389 | 395 | if ( $isMulti ) { |
— | — | @@ -450,7 +456,7 @@ |
451 | 457 | $wgOut->addHTML( |
452 | 458 | '</td><td><div class="multipageimagenavbox">' . |
453 | 459 | Xml::openElement( 'form', $formParams ) . |
454 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) . |
| 460 | + Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . |
455 | 461 | wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) . |
456 | 462 | Xml::submitButton( wfMsg( 'imgmultigo' ) ) . |
457 | 463 | Xml::closeElement( 'form' ) . |
— | — | @@ -463,14 +469,13 @@ |
464 | 470 | $icon = $this->displayImg->iconThumb(); |
465 | 471 | |
466 | 472 | $wgOut->addHTML( '<div class="fullImageLink" id="file">' . |
467 | | - $icon->toHtml( array( 'file-link' => true ) ) . |
468 | | - "</div>\n" ); |
| 473 | + $icon->toHtml( array( 'file-link' => true ) ) . |
| 474 | + "</div>\n" ); |
469 | 475 | } |
470 | 476 | |
471 | 477 | $showLink = true; |
472 | 478 | } |
473 | 479 | |
474 | | - |
475 | 480 | if ( $showLink ) { |
476 | 481 | $filename = wfEscapeWikiText( $this->displayImg->getName() ); |
477 | 482 | $linktext = $filename; |
— | — | @@ -505,11 +510,9 @@ |
506 | 511 | $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
507 | 512 | $nofile = array( |
508 | 513 | 'filepage-nofile-link', |
509 | | - $uploadTitle->getFullUrl( array( 'wpDestFile' => $this->img->getName() ) ) |
| 514 | + $uploadTitle->getFullURL( array( 'wpDestFile' => $this->img->getName() ) ) |
510 | 515 | ); |
511 | | - } |
512 | | - else |
513 | | - { |
| 516 | + } else { |
514 | 517 | $nofile = 'filepage-nofile'; |
515 | 518 | } |
516 | 519 | // Note, if there is an image description page, but |
— | — | @@ -520,7 +523,7 @@ |
521 | 524 | if ( !$this->getID() ) { |
522 | 525 | // If there is no image, no shared image, and no description page, |
523 | 526 | // output a 404, to be consistent with articles. |
524 | | - $wgRequest->response()->header( "HTTP/1.1 404 Not Found" ); |
| 527 | + $wgRequest->response()->header( 'HTTP/1.1 404 Not Found' ); |
525 | 528 | } |
526 | 529 | } |
527 | 530 | } |
— | — | @@ -584,7 +587,7 @@ |
585 | 588 | public function getUploadUrl() { |
586 | 589 | $this->loadFile(); |
587 | 590 | $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
588 | | - return $uploadTitle->getFullUrl( array( |
| 591 | + return $uploadTitle->getFullURL( array( |
589 | 592 | 'wpDestFile' => $this->img->getName(), |
590 | 593 | 'wpForReUpload' => 1 |
591 | 594 | ) ); |
— | — | @@ -602,8 +605,9 @@ |
603 | 606 | } |
604 | 607 | |
605 | 608 | $this->loadFile(); |
606 | | - if ( !$this->img->isLocal() ) |
| 609 | + if ( !$this->img->isLocal() ) { |
607 | 610 | return; |
| 611 | + } |
608 | 612 | |
609 | 613 | $sk = $wgUser->getSkin(); |
610 | 614 | |
— | — | @@ -628,7 +632,11 @@ |
629 | 633 | ), |
630 | 634 | array( 'known', 'noclasses' ) |
631 | 635 | ); |
632 | | - $wgOut->addHTML( '<li id="mw-imagepage-edit-external">' . $elink . ' <small>' . wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) . "</small></li>\n" ); |
| 636 | + $wgOut->addHTML( |
| 637 | + '<li id="mw-imagepage-edit-external">' . $elink . ' <small>' . |
| 638 | + wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) . |
| 639 | + "</small></li>\n" |
| 640 | + ); |
633 | 641 | } |
634 | 642 | |
635 | 643 | $wgOut->addHTML( "</ul>\n" ); |
— | — | @@ -673,7 +681,11 @@ |
674 | 682 | ); |
675 | 683 | $count = $dbr->numRows( $res ); |
676 | 684 | if ( $count == 0 ) { |
677 | | - $wgOut->wrapWikiMsg( Html::rawElement( 'div', array ( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ), 'nolinkstoimage' ); |
| 685 | + $wgOut->wrapWikiMsg( |
| 686 | + Html::rawElement( 'div', |
| 687 | + array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ), |
| 688 | + 'nolinkstoimage' |
| 689 | + ); |
678 | 690 | return; |
679 | 691 | } |
680 | 692 | |
— | — | @@ -688,7 +700,10 @@ |
689 | 701 | ); |
690 | 702 | } |
691 | 703 | |
692 | | - $wgOut->addHTML( Html::openElement( 'ul', array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n" ); |
| 704 | + $wgOut->addHTML( |
| 705 | + Html::openElement( 'ul', |
| 706 | + array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n" |
| 707 | + ); |
693 | 708 | $sk = $wgUser->getSkin(); |
694 | 709 | $count = 0; |
695 | 710 | $elements = array(); |
— | — | @@ -701,16 +716,16 @@ |
702 | 717 | } |
703 | 718 | |
704 | 719 | // Sort the list by namespace:title |
705 | | - usort ( $elements, array( $this, 'compare' ) ); |
| 720 | + usort( $elements, array( $this, 'compare' ) ); |
706 | 721 | |
707 | 722 | // Create links for every element |
708 | 723 | foreach( $elements as $element ) { |
709 | 724 | $link = $sk->linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) ); |
710 | 725 | $wgOut->addHTML( Html::rawElement( |
711 | | - 'li', |
712 | | - array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ), |
713 | | - $link |
714 | | - ) . "\n" |
| 726 | + 'li', |
| 727 | + array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ), |
| 728 | + $link |
| 729 | + ) . "\n" |
715 | 730 | ); |
716 | 731 | |
717 | 732 | }; |
— | — | @@ -728,7 +743,9 @@ |
729 | 744 | global $wgUser, $wgOut, $wgLang; |
730 | 745 | |
731 | 746 | $redirects = $this->getTitle()->getRedirectsHere( NS_FILE ); |
732 | | - if ( count( $redirects ) == 0 ) return; |
| 747 | + if ( count( $redirects ) == 0 ) { |
| 748 | + return; |
| 749 | + } |
733 | 750 | |
734 | 751 | $wgOut->addHTML( "<div id='mw-imagepage-section-redirectstofile'>\n" ); |
735 | 752 | $wgOut->addWikiMsg( 'redirectstofile', |
— | — | @@ -748,7 +765,6 @@ |
749 | 766 | $wgOut->addHTML( "<li>{$link}</li>\n" ); |
750 | 767 | } |
751 | 768 | $wgOut->addHTML( "</ul></div>\n" ); |
752 | | - |
753 | 769 | } |
754 | 770 | |
755 | 771 | protected function imageDupes() { |
— | — | @@ -824,13 +840,13 @@ |
825 | 841 | public function doPurge() { |
826 | 842 | $this->loadFile(); |
827 | 843 | if ( $this->img->exists() ) { |
828 | | - wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" ); |
| 844 | + wfDebug( 'ImagePage::doPurge purging ' . $this->img->getName() . "\n" ); |
829 | 845 | $update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ); |
830 | 846 | $update->doUpdate(); |
831 | 847 | $this->img->upgradeRow(); |
832 | 848 | $this->img->purgeCache(); |
833 | 849 | } else { |
834 | | - wfDebug( "ImagePage::doPurge no image for " . $this->img->getName() . "; limiting purge to cache only\n" ); |
| 850 | + wfDebug( 'ImagePage::doPurge no image for ' . $this->img->getName() . "; limiting purge to cache only\n" ); |
835 | 851 | // even if the file supposedly doesn't exist, force any cached information |
836 | 852 | // to be updated (in case the cached information is wrong) |
837 | 853 | $this->img->purgeCache(); |
— | — | @@ -843,8 +859,8 @@ |
844 | 860 | */ |
845 | 861 | function showError( $description ) { |
846 | 862 | global $wgOut; |
847 | | - $wgOut->setPageTitle( wfMsg( "internalerror" ) ); |
848 | | - $wgOut->setRobotPolicy( "noindex,nofollow" ); |
| 863 | + $wgOut->setPageTitle( wfMsg( 'internalerror' ) ); |
| 864 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
849 | 865 | $wgOut->setArticleRelated( false ); |
850 | 866 | $wgOut->enableClientCache( false ); |
851 | 867 | $wgOut->addWikiText( $description ); |
— | — | @@ -944,8 +960,8 @@ |
945 | 961 | } |
946 | 962 | |
947 | 963 | /** |
948 | | - * @param $iscur |
949 | | - * @param File $file |
| 964 | + * @param $iscur |
| 965 | + * @param $file File |
950 | 966 | * @return string |
951 | 967 | */ |
952 | 968 | public function imageHistoryLine( $iscur, $file ) { |
— | — | @@ -966,8 +982,9 @@ |
967 | 983 | # Link to remove from history |
968 | 984 | if ( $wgUser->isAllowed( 'delete' ) ) { |
969 | 985 | $q = array( 'action' => 'delete' ); |
970 | | - if ( !$iscur ) |
| 986 | + if ( !$iscur ) { |
971 | 987 | $q['oldimage'] = $img; |
| 988 | + } |
972 | 989 | $row .= $this->skin->link( |
973 | 990 | $this->title, |
974 | 991 | wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ), |
— | — | @@ -1059,7 +1076,7 @@ |
1060 | 1077 | // Image dimensions + size |
1061 | 1078 | $row .= '<td>'; |
1062 | 1079 | $row .= htmlspecialchars( $file->getDimensionsString() ); |
1063 | | - $row .= " <span style='white-space: nowrap;'>(" . $this->skin->formatSize( $file->getSize() ) . ')</span>'; |
| 1080 | + $row .= ' <span style="white-space: nowrap;">(' . $this->skin->formatSize( $file->getSize() ) . ')</span>'; |
1064 | 1081 | $row .= '</td>'; |
1065 | 1082 | |
1066 | 1083 | // Uploading user |
— | — | @@ -1069,8 +1086,8 @@ |
1070 | 1087 | if ( $file->isDeleted( File::DELETED_USER ) ) { |
1071 | 1088 | $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
1072 | 1089 | } else { |
1073 | | - $row .= $this->skin->userLink( $user, $usertext ) . " <span style='white-space: nowrap;'>" . |
1074 | | - $this->skin->userToolLinks( $user, $usertext ) . "</span>"; |
| 1090 | + $row .= $this->skin->userLink( $user, $usertext ) . ' <span style="white-space: nowrap;">' . |
| 1091 | + $this->skin->userToolLinks( $user, $usertext ) . '</span>'; |
1075 | 1092 | } |
1076 | 1093 | } else { |
1077 | 1094 | $row .= htmlspecialchars( $usertext ); |
— | — | @@ -1087,13 +1104,13 @@ |
1088 | 1105 | |
1089 | 1106 | $rowClass = null; |
1090 | 1107 | wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) ); |
1091 | | - $classAttr = $rowClass ? " class='$rowClass'" : ""; |
| 1108 | + $classAttr = $rowClass ? " class='$rowClass'" : ''; |
1092 | 1109 | |
1093 | 1110 | return "<tr{$classAttr}>{$row}</tr>\n"; |
1094 | 1111 | } |
1095 | 1112 | |
1096 | 1113 | /** |
1097 | | - * @param File $file |
| 1114 | + * @param $file File |
1098 | 1115 | * @return string |
1099 | 1116 | */ |
1100 | 1117 | protected function getThumbForLine( $file ) { |
— | — | @@ -1115,7 +1132,9 @@ |
1116 | 1133 | 'file-link' => true, |
1117 | 1134 | ); |
1118 | 1135 | |
1119 | | - if ( !$thumbnail ) return wfMsgHtml( 'filehist-nothumb' ); |
| 1136 | + if ( !$thumbnail ) { |
| 1137 | + return wfMsgHtml( 'filehist-nothumb' ); |
| 1138 | + } |
1120 | 1139 | |
1121 | 1140 | return $thumbnail->toHtml( $options ); |
1122 | 1141 | } else { |
— | — | @@ -1197,7 +1216,9 @@ |
1198 | 1217 | } |
1199 | 1218 | |
1200 | 1219 | function doQuery() { |
1201 | | - if ( $this->mQueryDone ) return; |
| 1220 | + if ( $this->mQueryDone ) { |
| 1221 | + return; |
| 1222 | + } |
1202 | 1223 | $this->mImg = $this->mImagePage->getFile(); // ensure loading |
1203 | 1224 | if ( !$this->mImg->exists() ) { |
1204 | 1225 | return; |