r63986 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63985‎ | r63986 | r63987 >
Date:22:58, 20 March 2010
Author:btongminh
Status:ok
Tags:
Comment:
stylize.php on ImagePage.php
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImagePage.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -if( !defined( 'MEDIAWIKI' ) )
 4+if ( !defined( 'MEDIAWIKI' ) )
55 die( 1 );
66
77 /**
@@ -30,20 +30,20 @@
3131 }
3232
3333 protected function loadFile() {
34 - if( $this->fileLoaded ) {
 34+ if ( $this->fileLoaded ) {
3535 return true;
3636 }
3737 $this->fileLoaded = true;
3838
3939 $this->displayImg = $this->img = false;
4040 wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) );
41 - if( !$this->img ) {
 41+ if ( !$this->img ) {
4242 $this->img = wfFindFile( $this->mTitle );
43 - if( !$this->img ) {
 43+ if ( !$this->img ) {
4444 $this->img = wfLocalFile( $this->mTitle );
4545 }
4646 }
47 - if( !$this->displayImg ) {
 47+ if ( !$this->displayImg ) {
4848 $this->displayImg = $this->img;
4949 }
5050 $this->repo = $this->img->getRepo();
@@ -63,8 +63,8 @@
6464 global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
6565 $this->loadFile();
6666
67 - if( $this->mTitle->getNamespace() == NS_FILE && $this->img->getRedirected() ) {
68 - if( $this->mTitle->getDBkey() == $this->img->getName() ) {
 67+ if ( $this->mTitle->getNamespace() == NS_FILE && $this->img->getRedirected() ) {
 68+ if ( $this->mTitle->getDBkey() == $this->img->getName() ) {
6969 // mTitle is the same as the redirect target so ask Article
7070 // to perform the redirect for us.
7171 return Article::view();
@@ -82,12 +82,12 @@
8383 $diff = $wgRequest->getVal( 'diff' );
8484 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
8585
86 - if( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) )
 86+ if ( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) )
8787 return Article::view();
8888
8989 $this->showRedirectedFromHeader();
9090
91 - if( $wgShowEXIF && $this->displayImg->exists() ) {
 91+ if ( $wgShowEXIF && $this->displayImg->exists() ) {
9292 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
9393 $formattedMetadata = $this->displayImg->formatMetadata();
9494 $showmeta = $formattedMetadata !== false;
@@ -95,14 +95,14 @@
9696 $showmeta = false;
9797 }
9898
99 - if( !$diff && $this->displayImg->exists() )
100 - $wgOut->addHTML( $this->showTOC($showmeta) );
 99+ if ( !$diff && $this->displayImg->exists() )
 100+ $wgOut->addHTML( $this->showTOC( $showmeta ) );
101101
102 - if( !$diff )
 102+ if ( !$diff )
103103 $this->openShowImage();
104104
105105 # No need to display noarticletext, we use our own message, output in openShowImage()
106 - if( $this->getID() ) {
 106+ if ( $this->getID() ) {
107107 Article::view();
108108 } else {
109109 # Just need to set the right headers
@@ -112,9 +112,9 @@
113113 }
114114
115115 # Show shared description, if needed
116 - if( $this->mExtraDescription ) {
 116+ if ( $this->mExtraDescription ) {
117117 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
118 - if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
 118+ if ( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
119119 $wgOut->addWikiText( $fol );
120120 }
121121 $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
@@ -123,7 +123,7 @@
124124 $this->closeShowImage();
125125 $this->imageHistory();
126126 // TODO: Cleanup the following
127 -
 127+
128128 $wgOut->addHTML( Xml::element( 'h2',
129129 array( 'id' => 'filelinks' ),
130130 wfMsg( 'imagelinks' ) ) . "\n" );
@@ -136,10 +136,10 @@
137137 # Allow extensions to add something after the image links
138138 $html = '';
139139 wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) );
140 - if ( $html)
 140+ if ( $html )
141141 $wgOut->addHTML( $html );
142142
143 - if( $showmeta ) {
 143+ if ( $showmeta ) {
144144 global $wgStylePath, $wgStyleVersion;
145145 $expand = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-expand' ) ) );
146146 $collapse = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-collapse' ) ) );
@@ -153,32 +153,32 @@
154154
155155 public function getRedirectTarget() {
156156 $this->loadFile();
157 - if( $this->img->isLocal() ) {
 157+ if ( $this->img->isLocal() ) {
158158 return parent::getRedirectTarget();
159159 }
160160 // Foreign image page
161161 $from = $this->img->getRedirected();
162162 $to = $this->img->getName();
163 - if( $from == $to ) {
164 - return null;
 163+ if ( $from == $to ) {
 164+ return null;
165165 }
166166 return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to );
167167 }
168168 public function followRedirect() {
169169 $this->loadFile();
170 - if( $this->img->isLocal() ) {
 170+ if ( $this->img->isLocal() ) {
171171 return parent::followRedirect();
172172 }
173173 $from = $this->img->getRedirected();
174174 $to = $this->img->getName();
175 - if( $from == $to ) {
176 - return false;
 175+ if ( $from == $to ) {
 176+ return false;
177177 }
178 - return Title::makeTitle( NS_FILE, $to );
 178+ return Title::makeTitle( NS_FILE, $to );
179179 }
180180 public function isRedirect( $text = false ) {
181181 $this->loadFile();
182 - if( $this->img->isLocal() )
 182+ if ( $this->img->isLocal() )
183183 return parent::isRedirect( $text );
184184
185185 return (bool)$this->img->getRedirected();
@@ -201,21 +201,21 @@
202202
203203 public function getDuplicates() {
204204 $this->loadFile();
205 - if( !is_null($this->dupes) ) {
 205+ if ( !is_null( $this->dupes ) ) {
206206 return $this->dupes;
207207 }
208 - if( !( $hash = $this->img->getSha1() ) ) {
 208+ if ( !( $hash = $this->img->getSha1() ) ) {
209209 return $this->dupes = array();
210210 }
211211 $dupes = RepoGroup::singleton()->findBySha1( $hash );
212212 // Remove duplicates with self and non matching file sizes
213 - $self = $this->img->getRepoName().':'.$this->img->getName();
 213+ $self = $this->img->getRepoName() . ':' . $this->img->getName();
214214 $size = $this->img->getSize();
215215 foreach ( $dupes as $index => $file ) {
216 - $key = $file->getRepoName().':'.$file->getName();
217 - if( $key == $self )
 216+ $key = $file->getRepoName() . ':' . $file->getName();
 217+ if ( $key == $self )
218218 unset( $dupes[$index] );
219 - if( $file->getSize() != $size )
 219+ if ( $file->getSize() != $size )
220220 unset( $dupes[$index] );
221221 }
222222 return $this->dupes = $dupes;
@@ -233,7 +233,7 @@
234234 $r = array(
235235 '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>',
236236 '<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>',
237 - '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>',
 237+ '<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>',
238238 );
239239 if ( $metadata ) {
240240 $r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>';
@@ -260,7 +260,7 @@
261261 foreach ( $stuff as $v ) {
262262 # FIXME, why is this using escapeId for a class?!
263263 $class = Sanitizer::escapeId( $v['id'] );
264 - if( $type == 'collapsed' ) {
 264+ if ( $type == 'collapsed' ) {
265265 $class .= ' collapsable';
266266 }
267267 $r .= "<tr class=\"$class\">\n";
@@ -280,7 +280,7 @@
281281 */
282282 public function getContent() {
283283 $this->loadFile();
284 - if( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
 284+ if ( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
285285 return '';
286286 }
287287 return Article::getContent();
@@ -294,13 +294,13 @@
295295
296296 $full_url = $this->displayImg->getURL();
297297 $linkAttribs = false;
298 - $sizeSel = intval( $wgUser->getOption( 'imagesize') );
299 - if( !isset( $wgImageLimits[$sizeSel] ) ) {
 298+ $sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
 299+ if ( !isset( $wgImageLimits[$sizeSel] ) ) {
300300 $sizeSel = User::getDefaultOption( 'imagesize' );
301301
302302 // The user offset might still be incorrect, specially if
303303 // $wgImageLimits got changed (see bug #8858).
304 - if( !isset( $wgImageLimits[$sizeSel] ) ) {
 304+ if ( !isset( $wgImageLimits[$sizeSel] ) ) {
305305 // Default to the first offset in $wgImageLimits
306306 $sizeSel = 0;
307307 }
@@ -311,10 +311,10 @@
312312 $sk = $wgUser->getSkin();
313313 $dirmark = $wgContLang->getDirMark();
314314
315 - if( $this->displayImg->exists() ) {
 315+ if ( $this->displayImg->exists() ) {
316316 # image
317317 $page = $wgRequest->getIntOrNull( 'page' );
318 - if( is_null( $page ) ) {
 318+ if ( is_null( $page ) ) {
319319 $params = array();
320320 $page = 1;
321321 } else {
@@ -331,21 +331,21 @@
332332
333333 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
334334
335 - if( $this->displayImg->allowInlineDisplay() ) {
 335+ if ( $this->displayImg->allowInlineDisplay() ) {
336336 # image
337337
338338 # "Download high res version" link below the image
339 - #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime );
 339+ # $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime );
340340 # We'll show a thumbnail of this image
341 - if( $width > $maxWidth || $height > $maxHeight ) {
 341+ if ( $width > $maxWidth || $height > $maxHeight ) {
342342 # Calculate the thumbnail size.
343343 # First case, the limiting factor is the width, not the height.
344 - if( $width / $height >= $maxWidth / $maxHeight ) {
345 - $height = round( $height * $maxWidth / $width);
 344+ if ( $width / $height >= $maxWidth / $maxHeight ) {
 345+ $height = round( $height * $maxWidth / $width );
346346 $width = $maxWidth;
347347 # Note that $height <= $maxHeight now.
348348 } else {
349 - $newwidth = floor( $width * $maxHeight / $height);
 349+ $newwidth = floor( $width * $maxHeight / $height );
350350 $height = round( $height * $newwidth / $width );
351351 $width = $newwidth;
352352 # Note that $height <= $maxHeight now, but might not be identical
@@ -366,7 +366,7 @@
367367 $thumbnail = $this->displayImg->transform( $params );
368368
369369 $anchorclose = "<br />";
370 - if( $this->displayImg->mustRender() ) {
 370+ if ( $this->displayImg->mustRender() ) {
371371 $showLink = true;
372372 } else {
373373 $anchorclose .=
@@ -375,11 +375,11 @@
376376 }
377377
378378 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
379 - if( $isMulti ) {
 379+ if ( $isMulti ) {
380380 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
381381 }
382382
383 - if( $thumbnail ) {
 383+ if ( $thumbnail ) {
384384 $options = array(
385385 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
386386 'file-link' => true,
@@ -389,10 +389,10 @@
390390 $anchorclose . "</div>\n" );
391391 }
392392
393 - if( $isMulti ) {
 393+ if ( $isMulti ) {
394394 $count = $this->displayImg->pageCount();
395395
396 - if( $page > 1 ) {
 396+ if ( $page > 1 ) {
397397 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
398398 $link = $sk->link(
399399 $this->mTitle,
@@ -407,7 +407,7 @@
408408 $thumb1 = '';
409409 }
410410
411 - if( $page < $count ) {
 411+ if ( $page < $count ) {
412412 $label = wfMsg( 'imgmultipagenext' );
413413 $link = $sk->link(
414414 $this->mTitle,
@@ -431,8 +431,8 @@
432432 );
433433
434434 $option = array();
435 - for ( $i=1; $i <= $count; $i++ ) {
436 - $options[] = Xml::option( $wgLang->formatNum($i), $i, $i == $page );
 435+ for ( $i = 1; $i <= $count; $i++ ) {
 436+ $options[] = Xml::option( $wgLang->formatNum( $i ), $i, $i == $page );
437437 }
438438 $select = Xml::tags( 'select',
439439 array( 'id' => 'pageselector', 'name' => 'page' ),
@@ -449,9 +449,9 @@
450450 );
451451 }
452452 } else {
453 - #if direct link is allowed but it's not a renderable image, show an icon.
454 - if( $this->displayImg->isSafeFile() ) {
455 - $icon= $this->displayImg->iconThumb();
 453+ # if direct link is allowed but it's not a renderable image, show an icon.
 454+ if ( $this->displayImg->isSafeFile() ) {
 455+ $icon = $this->displayImg->iconThumb();
456456
457457 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
458458 $icon->toHtml( array( 'file-link' => true ) ) .
@@ -462,11 +462,11 @@
463463 }
464464
465465
466 - if($showLink) {
 466+ if ( $showLink ) {
467467 $filename = wfEscapeWikiText( $this->displayImg->getName() );
468468 $medialink = "[[Media:$filename|$filename]]";
469469
470 - if( !$this->displayImg->isSafeFile() ) {
 470+ if ( !$this->displayImg->isSafeFile() ) {
471471 $warning = wfMsgNoTrans( 'mediawarning' );
472472 $wgOut->addWikiText( <<<EOT
473473 <div class="fullMedia">
@@ -487,7 +487,7 @@
488488 }
489489 }
490490
491 - if( !$this->displayImg->isLocal() ) {
 491+ if ( !$this->displayImg->isLocal() ) {
492492 $this->printSharedImageText();
493493 }
494494 } else {
@@ -524,7 +524,7 @@
525525 $repo = $this->img->getRepo()->getDisplayName();
526526
527527 $msg = '';
528 - if( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
 528+ if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
529529 $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
530530 } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
531531 $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
@@ -532,7 +532,7 @@
533533 $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
534534 }
535535
536 - if( $descText ) {
 536+ if ( $descText ) {
537537 $this->mExtraDescription = $descText;
538538 }
539539 }
@@ -553,10 +553,10 @@
554554 protected function uploadLinksBox() {
555555 global $wgUser, $wgOut, $wgEnableUploads, $wgUseExternalEditor;
556556
557 - if( !$wgEnableUploads ) { return; }
 557+ if ( !$wgEnableUploads ) { return; }
558558
559559 $this->loadFile();
560 - if( !$this->img->isLocal() )
 560+ if ( !$this->img->isLocal() )
561561 return;
562562
563563 $sk = $wgUser->getSkin();
@@ -564,7 +564,7 @@
565565 $wgOut->addHTML( "<br /><ul>\n" );
566566
567567 # "Upload a new version of this file" link
568 - if( UploadBase::userCanReUpload($wgUser,$this->img->name) ) {
 568+ if ( UploadBase::userCanReUpload( $wgUser, $this->img->name ) ) {
569569 $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
570570 $wgOut->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
571571 }
@@ -588,7 +588,7 @@
589589 $wgOut->addHTML( "</ul>\n" );
590590 }
591591
592 - protected function closeShowImage() {} # For overloading
 592+ protected function closeShowImage() { } # For overloading
593593
594594 /**
595595 * If the page we've just displayed is in the "Image" namespace,
@@ -605,7 +605,7 @@
606606
607607 # Exist check because we don't want to show this on pages where an image
608608 # doesn't exist along with the noimage message, that would suck. -ævar
609 - if( $this->img->exists() ) {
 609+ if ( $this->img->exists() ) {
610610 $this->uploadLinksBox();
611611 }
612612 }
@@ -622,10 +622,10 @@
623623 array( 'page_namespace', 'page_title' ),
624624 array( 'il_to' => $this->mTitle->getDBkey(), 'il_from = page_id' ),
625625 __METHOD__,
626 - array( 'LIMIT' => $limit + 1)
 626+ array( 'LIMIT' => $limit + 1 )
627627 );
628628 $count = $dbr->numRows( $res );
629 - if( $count == 0 ) {
 629+ if ( $count == 0 ) {
630630 $wgOut->addHTML( "<div id='mw-imagepage-nolinkstoimage'>\n" );
631631 $wgOut->addWikiMsg( 'nolinkstoimage' );
632632 $wgOut->addHTML( "</div>\n" );
@@ -633,7 +633,7 @@
634634 }
635635
636636 $wgOut->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
637 - if( $count <= $limit - 1 ) {
 637+ if ( $count <= $limit - 1 ) {
638638 $wgOut->addWikiMsg( 'linkstoimage', $count );
639639 } else {
640640 // More links than the limit. Add a link to [[Special:Whatlinkshere]]
@@ -648,7 +648,7 @@
649649 $count = 0;
650650 while ( $s = $res->fetchObject() ) {
651651 $count++;
652 - if( $count <= $limit ) {
 652+ if ( $count <= $limit ) {
653653 // We have not yet reached the extra one that tells us there is more to fetch
654654 $link = $sk->link(
655655 Title::makeTitle( $s->page_namespace, $s->page_title ),
@@ -664,7 +664,7 @@
665665 $res->free();
666666
667667 // Add a links to [[Special:Whatlinkshere]]
668 - if( $count > $limit )
 668+ if ( $count > $limit )
669669 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() );
670670 $wgOut->addHTML( "</div>\n" );
671671 }
@@ -673,7 +673,7 @@
674674 global $wgUser, $wgOut, $wgLang;
675675
676676 $redirects = $this->getTitle()->getRedirectsHere( NS_FILE );
677 - if( count( $redirects ) == 0 ) return;
 677+ if ( count( $redirects ) == 0 ) return;
678678
679679 $wgOut->addHTML( "<div id='mw-imagepage-section-redirectstofile'>\n" );
680680 $wgOut->addWikiMsg( 'redirectstofile',
@@ -702,7 +702,7 @@
703703 $this->loadFile();
704704
705705 $dupes = $this->getDuplicates();
706 - if( count( $dupes ) == 0 ) return;
 706+ if ( count( $dupes ) == 0 ) return;
707707
708708 $wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
709709 $wgOut->addWikiMsg( 'duplicatesoffile',
@@ -713,7 +713,7 @@
714714 $sk = $wgUser->getSkin();
715715 foreach ( $dupes as $file ) {
716716 $fromSrc = '';
717 - if( $file->isLocal() ) {
 717+ if ( $file->isLocal() ) {
718718 $link = $sk->link(
719719 $file->getTitle(),
720720 null,
@@ -736,14 +736,14 @@
737737 */
738738 public function delete() {
739739 global $wgUploadMaintenance;
740 - if( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) {
 740+ if ( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) {
741741 global $wgOut;
742742 $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n", array( 'filedelete-maintenance' ) );
743743 return;
744744 }
745745
746746 $this->loadFile();
747 - if( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) {
 747+ if ( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) {
748748 // Standard article deletion
749749 Article::delete();
750750 return;
@@ -766,7 +766,7 @@
767767 */
768768 public function doPurge() {
769769 $this->loadFile();
770 - if( $this->img->exists() ) {
 770+ if ( $this->img->exists() ) {
771771 wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" );
772772 $update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' );
773773 $update->doUpdate();
@@ -834,7 +834,7 @@
835835 . $navLinks . "\n"
836836 . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
837837 . '<tr><td></td>'
838 - . ( $this->current->isLocal() && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deletedhistory') ) ? '<td></td>' : '' )
 838+ . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ? '<td></td>' : '' )
839839 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
840840 . ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
841841 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
@@ -850,22 +850,22 @@
851851 public function imageHistoryLine( $iscur, $file ) {
852852 global $wgUser, $wgLang, $wgContLang, $wgTitle;
853853
854 - $timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
 854+ $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
855855 $img = $iscur ? $file->getName() : $file->getArchiveName();
856 - $user = $file->getUser('id');
857 - $usertext = $file->getUser('text');
 856+ $user = $file->getUser( 'id' );
 857+ $usertext = $file->getUser( 'text' );
858858 $description = $file->getDescription();
859859
860860 $local = $this->current->isLocal();
861861 $row = $css = $selected = '';
862862
863863 // Deletion link
864 - if( $local && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deletedhistory') ) ) {
 864+ if ( $local && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ) {
865865 $row .= '<td>';
866866 # Link to remove from history
867 - if( $wgUser->isAllowed( 'delete' ) ) {
 867+ if ( $wgUser->isAllowed( 'delete' ) ) {
868868 $q = array( 'action' => 'delete' );
869 - if( !$iscur )
 869+ if ( !$iscur )
870870 $q['oldimage'] = $img;
871871 $row .= $this->skin->link(
872872 $this->title,
@@ -875,22 +875,22 @@
876876 }
877877 # Link to hide content. Don't show useless link to people who cannot hide revisions.
878878 $canHide = $wgUser->isAllowed( 'deleterevision' );
879 - if( $canHide || ($wgUser->isAllowed('deletedhistory') && $file->getVisibility()) ) {
880 - if( $wgUser->isAllowed('delete') ) {
 879+ if ( $canHide || ( $wgUser->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
 880+ if ( $wgUser->isAllowed( 'delete' ) ) {
881881 $row .= '<br />';
882882 }
883883 // If file is top revision or locked from this user, don't link
884 - if( $iscur || !$file->userCan(File::DELETED_RESTRICTED) ) {
 884+ if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED ) ) {
885885 $del = $this->skin->revDeleteLinkDisabled( $canHide );
886886 } else {
887887 list( $ts, $name ) = explode( '!', $img, 2 );
888888 $query = array(
889889 'type' => 'oldimage',
890 - 'target' => $wgTitle->getPrefixedText(),
 890+ 'target' => $wgTitle->getPrefixedText(),
891891 'ids' => $ts,
892892 );
893893 $del = $this->skin->revDeleteLink( $query,
894 - $file->isDeleted(File::DELETED_RESTRICTED), $canHide );
 894+ $file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
895895 }
896896 $row .= $del;
897897 }
@@ -899,11 +899,11 @@
900900
901901 // Reversion link/current indicator
902902 $row .= '<td>';
903 - if( $iscur ) {
 903+ if ( $iscur ) {
904904 $row .= wfMsgHtml( 'filehist-current' );
905 - } elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
906 - if( $file->isDeleted(File::DELETED_FILE) ) {
907 - $row .= wfMsgHtml('filehist-revert');
 905+ } elseif ( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
 906+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 907+ $row .= wfMsgHtml( 'filehist-revert' );
908908 } else {
909909 $row .= $this->skin->link(
910910 $this->title,
@@ -921,14 +921,14 @@
922922 $row .= '</td>';
923923
924924 // Date/time and image link
925 - if( $file->getTimestamp() === $this->img->getTimestamp() ) {
 925+ if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
926926 $selected = "class='filehistory-selected'";
927927 }
928928 $row .= "<td $selected style='white-space: nowrap;'>";
929 - if( !$file->userCan(File::DELETED_FILE) ) {
 929+ if ( !$file->userCan( File::DELETED_FILE ) ) {
930930 # Don't link to unviewable files
931931 $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
932 - } elseif( $file->isDeleted(File::DELETED_FILE) ) {
 932+ } elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
933933 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
934934 # Make a link to review the image
935935 $url = $this->skin->link(
@@ -942,7 +942,7 @@
943943 ),
944944 array( 'known', 'noclasses' )
945945 );
946 - $row .= '<span class="history-deleted">'.$url.'</span>';
 946+ $row .= '<span class="history-deleted">' . $url . '</span>';
947947 } else {
948948 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
949949 $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) );
@@ -962,12 +962,12 @@
963963
964964 // Uploading user
965965 $row .= '<td>';
966 - if( $local ) {
 966+ if ( $local ) {
967967 // Hide deleted usernames
968 - if( $file->isDeleted(File::DELETED_USER) ) {
 968+ if ( $file->isDeleted( File::DELETED_USER ) ) {
969969 $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
970970 } else {
971 - $row .= $this->skin->userLink( $user, $usertext ) . " <span style='white-space: nowrap;'>" .
 971+ $row .= $this->skin->userLink( $user, $usertext ) . " <span style='white-space: nowrap;'>" .
972972 $this->skin->userToolLinks( $user, $usertext ) . "</span>";
973973 }
974974 } else {
@@ -976,8 +976,8 @@
977977 $row .= '</td><td>';
978978
979979 // Don't show deleted descriptions
980 - if( $file->isDeleted(File::DELETED_COMMENT) ) {
981 - $row .= '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
 980+ if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
 981+ $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
982982 } else {
983983 $row .= $this->skin->commentBlock( $description, $this->title );
984984 }
@@ -992,12 +992,12 @@
993993 protected function getThumbForLine( $file ) {
994994 global $wgLang;
995995
996 - if( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
 996+ if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
997997 $params = array(
998998 'width' => '120',
999999 'height' => '120',
10001000 );
1001 - $timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
 1001+ $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
10021002
10031003 $thumbnail = $file->transform( $params );
10041004 $options = array(
@@ -1021,7 +1021,7 @@
10221022 function __construct( $imagePage ) {
10231023 parent::__construct();
10241024 $this->mImagePage = $imagePage;
1025 - $this->mTitle = clone( $imagePage->getTitle() );
 1025+ $this->mTitle = clone ( $imagePage->getTitle() );
10261026 $this->mTitle->setFragment( '#filehistory' );
10271027 $this->mImg = null;
10281028 $this->mHist = array();
@@ -1047,68 +1047,68 @@
10481048 function getBody() {
10491049 $s = '';
10501050 $this->doQuery();
1051 - if( count($this->mHist) ) {
 1051+ if ( count( $this->mHist ) ) {
10521052 $list = new ImageHistoryList( $this->mImagePage );
10531053 # Generate prev/next links
10541054 $navLink = $this->getNavigationBar();
1055 - $s = $list->beginImageHistoryList($navLink);
 1055+ $s = $list->beginImageHistoryList( $navLink );
10561056 // Skip rows there just for paging links
1057 - for( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
 1057+ for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
10581058 $file = $this->mHist[$i];
10591059 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
10601060 }
1061 - $s .= $list->endImageHistoryList($navLink);
 1061+ $s .= $list->endImageHistoryList( $navLink );
10621062 }
10631063 return $s;
10641064 }
10651065
10661066 function doQuery() {
1067 - if( $this->mQueryDone ) return;
 1067+ if ( $this->mQueryDone ) return;
10681068 $this->mImg = $this->mImagePage->getFile(); // ensure loading
1069 - if( !$this->mImg->exists() ) {
 1069+ if ( !$this->mImg->exists() ) {
10701070 return;
10711071 }
10721072 $queryLimit = $this->mLimit + 1; // limit plus extra row
1073 - if( $this->mIsBackwards ) {
 1073+ if ( $this->mIsBackwards ) {
10741074 // Fetch the file history
1075 - $this->mHist = $this->mImg->getHistory($queryLimit,null,$this->mOffset,false);
 1075+ $this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
10761076 // The current rev may not meet the offset/limit
1077 - $numRows = count($this->mHist);
1078 - if( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
1079 - $this->mHist = array_merge( array($this->mImg), $this->mHist );
 1077+ $numRows = count( $this->mHist );
 1078+ if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
 1079+ $this->mHist = array_merge( array( $this->mImg ), $this->mHist );
10801080 }
10811081 } else {
10821082 // The current rev may not meet the offset
1083 - if( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
 1083+ if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
10841084 $this->mHist[] = $this->mImg;
10851085 }
10861086 // Old image versions (fetch extra row for nav links)
1087 - $oiLimit = count($this->mHist) ? $this->mLimit : $this->mLimit+1;
 1087+ $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
10881088 // Fetch the file history
10891089 $this->mHist = array_merge( $this->mHist,
1090 - $this->mImg->getHistory($oiLimit,$this->mOffset,null,false) );
 1090+ $this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
10911091 }
1092 - $numRows = count($this->mHist); // Total number of query results
1093 - if( $numRows ) {
 1092+ $numRows = count( $this->mHist ); // Total number of query results
 1093+ if ( $numRows ) {
10941094 # Index value of top item in the list
10951095 $firstIndex = $this->mIsBackwards ?
1096 - $this->mHist[$numRows-1]->getTimestamp() : $this->mHist[0]->getTimestamp();
 1096+ $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
10971097 # Discard the extra result row if there is one
1098 - if( $numRows > $this->mLimit && $numRows > 1 ) {
1099 - if( $this->mIsBackwards ) {
 1098+ if ( $numRows > $this->mLimit && $numRows > 1 ) {
 1099+ if ( $this->mIsBackwards ) {
11001100 # Index value of item past the index
11011101 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
11021102 # Index value of bottom item in the list
11031103 $lastIndex = $this->mHist[1]->getTimestamp();
11041104 # Display range
1105 - $this->mRange = array( 1, $numRows-1 );
 1105+ $this->mRange = array( 1, $numRows - 1 );
11061106 } else {
11071107 # Index value of item past the index
1108 - $this->mPastTheEndIndex = $this->mHist[$numRows-1]->getTimestamp();
 1108+ $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
11091109 # Index value of bottom item in the list
1110 - $lastIndex = $this->mHist[$numRows-2]->getTimestamp();
 1110+ $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
11111111 # Display range
1112 - $this->mRange = array( 0, $numRows-2 );
 1112+ $this->mRange = array( 0, $numRows - 2 );
11131113 }
11141114 } else {
11151115 # Setting indexes to an empty string means that they will be
@@ -1118,16 +1118,16 @@
11191119 $this->mPastTheEndIndex = '';
11201120 # Index value of bottom item in the list
11211121 $lastIndex = $this->mIsBackwards ?
1122 - $this->mHist[0]->getTimestamp() : $this->mHist[$numRows-1]->getTimestamp();
 1122+ $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
11231123 # Display range
1124 - $this->mRange = array( 0, $numRows-1 );
 1124+ $this->mRange = array( 0, $numRows - 1 );
11251125 }
11261126 } else {
11271127 $firstIndex = '';
11281128 $lastIndex = '';
11291129 $this->mPastTheEndIndex = '';
11301130 }
1131 - if( $this->mIsBackwards ) {
 1131+ if ( $this->mIsBackwards ) {
11321132 $this->mIsFirst = ( $numRows < $queryLimit );
11331133 $this->mIsLast = ( $this->mOffset == '' );
11341134 $this->mLastShown = $firstIndex;

Status & tagging log