Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -if( !defined( 'MEDIAWIKI' ) ) |
| 4 | +if ( !defined( 'MEDIAWIKI' ) ) |
5 | 5 | die( 1 ); |
6 | 6 | |
7 | 7 | /** |
— | — | @@ -30,20 +30,20 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | protected function loadFile() { |
34 | | - if( $this->fileLoaded ) { |
| 34 | + if ( $this->fileLoaded ) { |
35 | 35 | return true; |
36 | 36 | } |
37 | 37 | $this->fileLoaded = true; |
38 | 38 | |
39 | 39 | $this->displayImg = $this->img = false; |
40 | 40 | wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) ); |
41 | | - if( !$this->img ) { |
| 41 | + if ( !$this->img ) { |
42 | 42 | $this->img = wfFindFile( $this->mTitle ); |
43 | | - if( !$this->img ) { |
| 43 | + if ( !$this->img ) { |
44 | 44 | $this->img = wfLocalFile( $this->mTitle ); |
45 | 45 | } |
46 | 46 | } |
47 | | - if( !$this->displayImg ) { |
| 47 | + if ( !$this->displayImg ) { |
48 | 48 | $this->displayImg = $this->img; |
49 | 49 | } |
50 | 50 | $this->repo = $this->img->getRepo(); |
— | — | @@ -63,8 +63,8 @@ |
64 | 64 | global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; |
65 | 65 | $this->loadFile(); |
66 | 66 | |
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() ) { |
69 | 69 | // mTitle is the same as the redirect target so ask Article |
70 | 70 | // to perform the redirect for us. |
71 | 71 | return Article::view(); |
— | — | @@ -82,12 +82,12 @@ |
83 | 83 | $diff = $wgRequest->getVal( 'diff' ); |
84 | 84 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
85 | 85 | |
86 | | - if( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) |
| 86 | + if ( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) |
87 | 87 | return Article::view(); |
88 | 88 | |
89 | 89 | $this->showRedirectedFromHeader(); |
90 | 90 | |
91 | | - if( $wgShowEXIF && $this->displayImg->exists() ) { |
| 91 | + if ( $wgShowEXIF && $this->displayImg->exists() ) { |
92 | 92 | // FIXME: bad interface, see note on MediaHandler::formatMetadata(). |
93 | 93 | $formattedMetadata = $this->displayImg->formatMetadata(); |
94 | 94 | $showmeta = $formattedMetadata !== false; |
— | — | @@ -95,14 +95,14 @@ |
96 | 96 | $showmeta = false; |
97 | 97 | } |
98 | 98 | |
99 | | - if( !$diff && $this->displayImg->exists() ) |
100 | | - $wgOut->addHTML( $this->showTOC($showmeta) ); |
| 99 | + if ( !$diff && $this->displayImg->exists() ) |
| 100 | + $wgOut->addHTML( $this->showTOC( $showmeta ) ); |
101 | 101 | |
102 | | - if( !$diff ) |
| 102 | + if ( !$diff ) |
103 | 103 | $this->openShowImage(); |
104 | 104 | |
105 | 105 | # No need to display noarticletext, we use our own message, output in openShowImage() |
106 | | - if( $this->getID() ) { |
| 106 | + if ( $this->getID() ) { |
107 | 107 | Article::view(); |
108 | 108 | } else { |
109 | 109 | # Just need to set the right headers |
— | — | @@ -112,9 +112,9 @@ |
113 | 113 | } |
114 | 114 | |
115 | 115 | # Show shared description, if needed |
116 | | - if( $this->mExtraDescription ) { |
| 116 | + if ( $this->mExtraDescription ) { |
117 | 117 | $fol = wfMsgNoTrans( 'shareddescriptionfollows' ); |
118 | | - if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) { |
| 118 | + if ( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) { |
119 | 119 | $wgOut->addWikiText( $fol ); |
120 | 120 | } |
121 | 121 | $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" ); |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | $this->closeShowImage(); |
125 | 125 | $this->imageHistory(); |
126 | 126 | // TODO: Cleanup the following |
127 | | - |
| 127 | + |
128 | 128 | $wgOut->addHTML( Xml::element( 'h2', |
129 | 129 | array( 'id' => 'filelinks' ), |
130 | 130 | wfMsg( 'imagelinks' ) ) . "\n" ); |
— | — | @@ -136,10 +136,10 @@ |
137 | 137 | # Allow extensions to add something after the image links |
138 | 138 | $html = ''; |
139 | 139 | wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) ); |
140 | | - if ( $html) |
| 140 | + if ( $html ) |
141 | 141 | $wgOut->addHTML( $html ); |
142 | 142 | |
143 | | - if( $showmeta ) { |
| 143 | + if ( $showmeta ) { |
144 | 144 | global $wgStylePath, $wgStyleVersion; |
145 | 145 | $expand = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-expand' ) ) ); |
146 | 146 | $collapse = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-collapse' ) ) ); |
— | — | @@ -153,32 +153,32 @@ |
154 | 154 | |
155 | 155 | public function getRedirectTarget() { |
156 | 156 | $this->loadFile(); |
157 | | - if( $this->img->isLocal() ) { |
| 157 | + if ( $this->img->isLocal() ) { |
158 | 158 | return parent::getRedirectTarget(); |
159 | 159 | } |
160 | 160 | // Foreign image page |
161 | 161 | $from = $this->img->getRedirected(); |
162 | 162 | $to = $this->img->getName(); |
163 | | - if( $from == $to ) { |
164 | | - return null; |
| 163 | + if ( $from == $to ) { |
| 164 | + return null; |
165 | 165 | } |
166 | 166 | return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to ); |
167 | 167 | } |
168 | 168 | public function followRedirect() { |
169 | 169 | $this->loadFile(); |
170 | | - if( $this->img->isLocal() ) { |
| 170 | + if ( $this->img->isLocal() ) { |
171 | 171 | return parent::followRedirect(); |
172 | 172 | } |
173 | 173 | $from = $this->img->getRedirected(); |
174 | 174 | $to = $this->img->getName(); |
175 | | - if( $from == $to ) { |
176 | | - return false; |
| 175 | + if ( $from == $to ) { |
| 176 | + return false; |
177 | 177 | } |
178 | | - return Title::makeTitle( NS_FILE, $to ); |
| 178 | + return Title::makeTitle( NS_FILE, $to ); |
179 | 179 | } |
180 | 180 | public function isRedirect( $text = false ) { |
181 | 181 | $this->loadFile(); |
182 | | - if( $this->img->isLocal() ) |
| 182 | + if ( $this->img->isLocal() ) |
183 | 183 | return parent::isRedirect( $text ); |
184 | 184 | |
185 | 185 | return (bool)$this->img->getRedirected(); |
— | — | @@ -201,21 +201,21 @@ |
202 | 202 | |
203 | 203 | public function getDuplicates() { |
204 | 204 | $this->loadFile(); |
205 | | - if( !is_null($this->dupes) ) { |
| 205 | + if ( !is_null( $this->dupes ) ) { |
206 | 206 | return $this->dupes; |
207 | 207 | } |
208 | | - if( !( $hash = $this->img->getSha1() ) ) { |
| 208 | + if ( !( $hash = $this->img->getSha1() ) ) { |
209 | 209 | return $this->dupes = array(); |
210 | 210 | } |
211 | 211 | $dupes = RepoGroup::singleton()->findBySha1( $hash ); |
212 | 212 | // 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(); |
214 | 214 | $size = $this->img->getSize(); |
215 | 215 | 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 ) |
218 | 218 | unset( $dupes[$index] ); |
219 | | - if( $file->getSize() != $size ) |
| 219 | + if ( $file->getSize() != $size ) |
220 | 220 | unset( $dupes[$index] ); |
221 | 221 | } |
222 | 222 | return $this->dupes = $dupes; |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | $r = array( |
235 | 235 | '<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>', |
236 | 236 | '<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>', |
238 | 238 | ); |
239 | 239 | if ( $metadata ) { |
240 | 240 | $r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>'; |
— | — | @@ -260,7 +260,7 @@ |
261 | 261 | foreach ( $stuff as $v ) { |
262 | 262 | # FIXME, why is this using escapeId for a class?! |
263 | 263 | $class = Sanitizer::escapeId( $v['id'] ); |
264 | | - if( $type == 'collapsed' ) { |
| 264 | + if ( $type == 'collapsed' ) { |
265 | 265 | $class .= ' collapsable'; |
266 | 266 | } |
267 | 267 | $r .= "<tr class=\"$class\">\n"; |
— | — | @@ -280,7 +280,7 @@ |
281 | 281 | */ |
282 | 282 | public function getContent() { |
283 | 283 | $this->loadFile(); |
284 | | - if( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) { |
| 284 | + if ( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) { |
285 | 285 | return ''; |
286 | 286 | } |
287 | 287 | return Article::getContent(); |
— | — | @@ -294,13 +294,13 @@ |
295 | 295 | |
296 | 296 | $full_url = $this->displayImg->getURL(); |
297 | 297 | $linkAttribs = false; |
298 | | - $sizeSel = intval( $wgUser->getOption( 'imagesize') ); |
299 | | - if( !isset( $wgImageLimits[$sizeSel] ) ) { |
| 298 | + $sizeSel = intval( $wgUser->getOption( 'imagesize' ) ); |
| 299 | + if ( !isset( $wgImageLimits[$sizeSel] ) ) { |
300 | 300 | $sizeSel = User::getDefaultOption( 'imagesize' ); |
301 | 301 | |
302 | 302 | // The user offset might still be incorrect, specially if |
303 | 303 | // $wgImageLimits got changed (see bug #8858). |
304 | | - if( !isset( $wgImageLimits[$sizeSel] ) ) { |
| 304 | + if ( !isset( $wgImageLimits[$sizeSel] ) ) { |
305 | 305 | // Default to the first offset in $wgImageLimits |
306 | 306 | $sizeSel = 0; |
307 | 307 | } |
— | — | @@ -311,10 +311,10 @@ |
312 | 312 | $sk = $wgUser->getSkin(); |
313 | 313 | $dirmark = $wgContLang->getDirMark(); |
314 | 314 | |
315 | | - if( $this->displayImg->exists() ) { |
| 315 | + if ( $this->displayImg->exists() ) { |
316 | 316 | # image |
317 | 317 | $page = $wgRequest->getIntOrNull( 'page' ); |
318 | | - if( is_null( $page ) ) { |
| 318 | + if ( is_null( $page ) ) { |
319 | 319 | $params = array(); |
320 | 320 | $page = 1; |
321 | 321 | } else { |
— | — | @@ -331,21 +331,21 @@ |
332 | 332 | |
333 | 333 | wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) ); |
334 | 334 | |
335 | | - if( $this->displayImg->allowInlineDisplay() ) { |
| 335 | + if ( $this->displayImg->allowInlineDisplay() ) { |
336 | 336 | # image |
337 | 337 | |
338 | 338 | # "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 ); |
340 | 340 | # We'll show a thumbnail of this image |
341 | | - if( $width > $maxWidth || $height > $maxHeight ) { |
| 341 | + if ( $width > $maxWidth || $height > $maxHeight ) { |
342 | 342 | # Calculate the thumbnail size. |
343 | 343 | # 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 ); |
346 | 346 | $width = $maxWidth; |
347 | 347 | # Note that $height <= $maxHeight now. |
348 | 348 | } else { |
349 | | - $newwidth = floor( $width * $maxHeight / $height); |
| 349 | + $newwidth = floor( $width * $maxHeight / $height ); |
350 | 350 | $height = round( $height * $newwidth / $width ); |
351 | 351 | $width = $newwidth; |
352 | 352 | # Note that $height <= $maxHeight now, but might not be identical |
— | — | @@ -366,7 +366,7 @@ |
367 | 367 | $thumbnail = $this->displayImg->transform( $params ); |
368 | 368 | |
369 | 369 | $anchorclose = "<br />"; |
370 | | - if( $this->displayImg->mustRender() ) { |
| 370 | + if ( $this->displayImg->mustRender() ) { |
371 | 371 | $showLink = true; |
372 | 372 | } else { |
373 | 373 | $anchorclose .= |
— | — | @@ -375,11 +375,11 @@ |
376 | 376 | } |
377 | 377 | |
378 | 378 | $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; |
379 | | - if( $isMulti ) { |
| 379 | + if ( $isMulti ) { |
380 | 380 | $wgOut->addHTML( '<table class="multipageimage"><tr><td>' ); |
381 | 381 | } |
382 | 382 | |
383 | | - if( $thumbnail ) { |
| 383 | + if ( $thumbnail ) { |
384 | 384 | $options = array( |
385 | 385 | 'alt' => $this->displayImg->getTitle()->getPrefixedText(), |
386 | 386 | 'file-link' => true, |
— | — | @@ -389,10 +389,10 @@ |
390 | 390 | $anchorclose . "</div>\n" ); |
391 | 391 | } |
392 | 392 | |
393 | | - if( $isMulti ) { |
| 393 | + if ( $isMulti ) { |
394 | 394 | $count = $this->displayImg->pageCount(); |
395 | 395 | |
396 | | - if( $page > 1 ) { |
| 396 | + if ( $page > 1 ) { |
397 | 397 | $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false ); |
398 | 398 | $link = $sk->link( |
399 | 399 | $this->mTitle, |
— | — | @@ -407,7 +407,7 @@ |
408 | 408 | $thumb1 = ''; |
409 | 409 | } |
410 | 410 | |
411 | | - if( $page < $count ) { |
| 411 | + if ( $page < $count ) { |
412 | 412 | $label = wfMsg( 'imgmultipagenext' ); |
413 | 413 | $link = $sk->link( |
414 | 414 | $this->mTitle, |
— | — | @@ -431,8 +431,8 @@ |
432 | 432 | ); |
433 | 433 | |
434 | 434 | $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 ); |
437 | 437 | } |
438 | 438 | $select = Xml::tags( 'select', |
439 | 439 | array( 'id' => 'pageselector', 'name' => 'page' ), |
— | — | @@ -449,9 +449,9 @@ |
450 | 450 | ); |
451 | 451 | } |
452 | 452 | } 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(); |
456 | 456 | |
457 | 457 | $wgOut->addHTML( '<div class="fullImageLink" id="file">' . |
458 | 458 | $icon->toHtml( array( 'file-link' => true ) ) . |
— | — | @@ -462,11 +462,11 @@ |
463 | 463 | } |
464 | 464 | |
465 | 465 | |
466 | | - if($showLink) { |
| 466 | + if ( $showLink ) { |
467 | 467 | $filename = wfEscapeWikiText( $this->displayImg->getName() ); |
468 | 468 | $medialink = "[[Media:$filename|$filename]]"; |
469 | 469 | |
470 | | - if( !$this->displayImg->isSafeFile() ) { |
| 470 | + if ( !$this->displayImg->isSafeFile() ) { |
471 | 471 | $warning = wfMsgNoTrans( 'mediawarning' ); |
472 | 472 | $wgOut->addWikiText( <<<EOT |
473 | 473 | <div class="fullMedia"> |
— | — | @@ -487,7 +487,7 @@ |
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | | - if( !$this->displayImg->isLocal() ) { |
| 491 | + if ( !$this->displayImg->isLocal() ) { |
492 | 492 | $this->printSharedImageText(); |
493 | 493 | } |
494 | 494 | } else { |
— | — | @@ -524,7 +524,7 @@ |
525 | 525 | $repo = $this->img->getRepo()->getDisplayName(); |
526 | 526 | |
527 | 527 | $msg = ''; |
528 | | - if( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) { |
| 528 | + if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) { |
529 | 529 | $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) ); |
530 | 530 | } elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) { |
531 | 531 | $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) ); |
— | — | @@ -532,7 +532,7 @@ |
533 | 533 | $wgOut->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ ); |
534 | 534 | } |
535 | 535 | |
536 | | - if( $descText ) { |
| 536 | + if ( $descText ) { |
537 | 537 | $this->mExtraDescription = $descText; |
538 | 538 | } |
539 | 539 | } |
— | — | @@ -553,10 +553,10 @@ |
554 | 554 | protected function uploadLinksBox() { |
555 | 555 | global $wgUser, $wgOut, $wgEnableUploads, $wgUseExternalEditor; |
556 | 556 | |
557 | | - if( !$wgEnableUploads ) { return; } |
| 557 | + if ( !$wgEnableUploads ) { return; } |
558 | 558 | |
559 | 559 | $this->loadFile(); |
560 | | - if( !$this->img->isLocal() ) |
| 560 | + if ( !$this->img->isLocal() ) |
561 | 561 | return; |
562 | 562 | |
563 | 563 | $sk = $wgUser->getSkin(); |
— | — | @@ -564,7 +564,7 @@ |
565 | 565 | $wgOut->addHTML( "<br /><ul>\n" ); |
566 | 566 | |
567 | 567 | # "Upload a new version of this file" link |
568 | | - if( UploadBase::userCanReUpload($wgUser,$this->img->name) ) { |
| 568 | + if ( UploadBase::userCanReUpload( $wgUser, $this->img->name ) ) { |
569 | 569 | $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) ); |
570 | 570 | $wgOut->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" ); |
571 | 571 | } |
— | — | @@ -588,7 +588,7 @@ |
589 | 589 | $wgOut->addHTML( "</ul>\n" ); |
590 | 590 | } |
591 | 591 | |
592 | | - protected function closeShowImage() {} # For overloading |
| 592 | + protected function closeShowImage() { } # For overloading |
593 | 593 | |
594 | 594 | /** |
595 | 595 | * If the page we've just displayed is in the "Image" namespace, |
— | — | @@ -605,7 +605,7 @@ |
606 | 606 | |
607 | 607 | # Exist check because we don't want to show this on pages where an image |
608 | 608 | # doesn't exist along with the noimage message, that would suck. -ævar |
609 | | - if( $this->img->exists() ) { |
| 609 | + if ( $this->img->exists() ) { |
610 | 610 | $this->uploadLinksBox(); |
611 | 611 | } |
612 | 612 | } |
— | — | @@ -622,10 +622,10 @@ |
623 | 623 | array( 'page_namespace', 'page_title' ), |
624 | 624 | array( 'il_to' => $this->mTitle->getDBkey(), 'il_from = page_id' ), |
625 | 625 | __METHOD__, |
626 | | - array( 'LIMIT' => $limit + 1) |
| 626 | + array( 'LIMIT' => $limit + 1 ) |
627 | 627 | ); |
628 | 628 | $count = $dbr->numRows( $res ); |
629 | | - if( $count == 0 ) { |
| 629 | + if ( $count == 0 ) { |
630 | 630 | $wgOut->addHTML( "<div id='mw-imagepage-nolinkstoimage'>\n" ); |
631 | 631 | $wgOut->addWikiMsg( 'nolinkstoimage' ); |
632 | 632 | $wgOut->addHTML( "</div>\n" ); |
— | — | @@ -633,7 +633,7 @@ |
634 | 634 | } |
635 | 635 | |
636 | 636 | $wgOut->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" ); |
637 | | - if( $count <= $limit - 1 ) { |
| 637 | + if ( $count <= $limit - 1 ) { |
638 | 638 | $wgOut->addWikiMsg( 'linkstoimage', $count ); |
639 | 639 | } else { |
640 | 640 | // More links than the limit. Add a link to [[Special:Whatlinkshere]] |
— | — | @@ -648,7 +648,7 @@ |
649 | 649 | $count = 0; |
650 | 650 | while ( $s = $res->fetchObject() ) { |
651 | 651 | $count++; |
652 | | - if( $count <= $limit ) { |
| 652 | + if ( $count <= $limit ) { |
653 | 653 | // We have not yet reached the extra one that tells us there is more to fetch |
654 | 654 | $link = $sk->link( |
655 | 655 | Title::makeTitle( $s->page_namespace, $s->page_title ), |
— | — | @@ -664,7 +664,7 @@ |
665 | 665 | $res->free(); |
666 | 666 | |
667 | 667 | // Add a links to [[Special:Whatlinkshere]] |
668 | | - if( $count > $limit ) |
| 668 | + if ( $count > $limit ) |
669 | 669 | $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() ); |
670 | 670 | $wgOut->addHTML( "</div>\n" ); |
671 | 671 | } |
— | — | @@ -673,7 +673,7 @@ |
674 | 674 | global $wgUser, $wgOut, $wgLang; |
675 | 675 | |
676 | 676 | $redirects = $this->getTitle()->getRedirectsHere( NS_FILE ); |
677 | | - if( count( $redirects ) == 0 ) return; |
| 677 | + if ( count( $redirects ) == 0 ) return; |
678 | 678 | |
679 | 679 | $wgOut->addHTML( "<div id='mw-imagepage-section-redirectstofile'>\n" ); |
680 | 680 | $wgOut->addWikiMsg( 'redirectstofile', |
— | — | @@ -702,7 +702,7 @@ |
703 | 703 | $this->loadFile(); |
704 | 704 | |
705 | 705 | $dupes = $this->getDuplicates(); |
706 | | - if( count( $dupes ) == 0 ) return; |
| 706 | + if ( count( $dupes ) == 0 ) return; |
707 | 707 | |
708 | 708 | $wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" ); |
709 | 709 | $wgOut->addWikiMsg( 'duplicatesoffile', |
— | — | @@ -713,7 +713,7 @@ |
714 | 714 | $sk = $wgUser->getSkin(); |
715 | 715 | foreach ( $dupes as $file ) { |
716 | 716 | $fromSrc = ''; |
717 | | - if( $file->isLocal() ) { |
| 717 | + if ( $file->isLocal() ) { |
718 | 718 | $link = $sk->link( |
719 | 719 | $file->getTitle(), |
720 | 720 | null, |
— | — | @@ -736,14 +736,14 @@ |
737 | 737 | */ |
738 | 738 | public function delete() { |
739 | 739 | global $wgUploadMaintenance; |
740 | | - if( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) { |
| 740 | + if ( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) { |
741 | 741 | global $wgOut; |
742 | 742 | $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n", array( 'filedelete-maintenance' ) ); |
743 | 743 | return; |
744 | 744 | } |
745 | 745 | |
746 | 746 | $this->loadFile(); |
747 | | - if( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) { |
| 747 | + if ( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) { |
748 | 748 | // Standard article deletion |
749 | 749 | Article::delete(); |
750 | 750 | return; |
— | — | @@ -766,7 +766,7 @@ |
767 | 767 | */ |
768 | 768 | public function doPurge() { |
769 | 769 | $this->loadFile(); |
770 | | - if( $this->img->exists() ) { |
| 770 | + if ( $this->img->exists() ) { |
771 | 771 | wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" ); |
772 | 772 | $update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ); |
773 | 773 | $update->doUpdate(); |
— | — | @@ -834,7 +834,7 @@ |
835 | 835 | . $navLinks . "\n" |
836 | 836 | . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n" |
837 | 837 | . '<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>' : '' ) |
839 | 839 | . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>' |
840 | 840 | . ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' ) |
841 | 841 | . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>' |
— | — | @@ -850,22 +850,22 @@ |
851 | 851 | public function imageHistoryLine( $iscur, $file ) { |
852 | 852 | global $wgUser, $wgLang, $wgContLang, $wgTitle; |
853 | 853 | |
854 | | - $timestamp = wfTimestamp(TS_MW, $file->getTimestamp()); |
| 854 | + $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() ); |
855 | 855 | $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' ); |
858 | 858 | $description = $file->getDescription(); |
859 | 859 | |
860 | 860 | $local = $this->current->isLocal(); |
861 | 861 | $row = $css = $selected = ''; |
862 | 862 | |
863 | 863 | // Deletion link |
864 | | - if( $local && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deletedhistory') ) ) { |
| 864 | + if ( $local && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ) { |
865 | 865 | $row .= '<td>'; |
866 | 866 | # Link to remove from history |
867 | | - if( $wgUser->isAllowed( 'delete' ) ) { |
| 867 | + if ( $wgUser->isAllowed( 'delete' ) ) { |
868 | 868 | $q = array( 'action' => 'delete' ); |
869 | | - if( !$iscur ) |
| 869 | + if ( !$iscur ) |
870 | 870 | $q['oldimage'] = $img; |
871 | 871 | $row .= $this->skin->link( |
872 | 872 | $this->title, |
— | — | @@ -875,22 +875,22 @@ |
876 | 876 | } |
877 | 877 | # Link to hide content. Don't show useless link to people who cannot hide revisions. |
878 | 878 | $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' ) ) { |
881 | 881 | $row .= '<br />'; |
882 | 882 | } |
883 | 883 | // 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 ) ) { |
885 | 885 | $del = $this->skin->revDeleteLinkDisabled( $canHide ); |
886 | 886 | } else { |
887 | 887 | list( $ts, $name ) = explode( '!', $img, 2 ); |
888 | 888 | $query = array( |
889 | 889 | 'type' => 'oldimage', |
890 | | - 'target' => $wgTitle->getPrefixedText(), |
| 890 | + 'target' => $wgTitle->getPrefixedText(), |
891 | 891 | 'ids' => $ts, |
892 | 892 | ); |
893 | 893 | $del = $this->skin->revDeleteLink( $query, |
894 | | - $file->isDeleted(File::DELETED_RESTRICTED), $canHide ); |
| 894 | + $file->isDeleted( File::DELETED_RESTRICTED ), $canHide ); |
895 | 895 | } |
896 | 896 | $row .= $del; |
897 | 897 | } |
— | — | @@ -899,11 +899,11 @@ |
900 | 900 | |
901 | 901 | // Reversion link/current indicator |
902 | 902 | $row .= '<td>'; |
903 | | - if( $iscur ) { |
| 903 | + if ( $iscur ) { |
904 | 904 | $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' ); |
908 | 908 | } else { |
909 | 909 | $row .= $this->skin->link( |
910 | 910 | $this->title, |
— | — | @@ -921,14 +921,14 @@ |
922 | 922 | $row .= '</td>'; |
923 | 923 | |
924 | 924 | // Date/time and image link |
925 | | - if( $file->getTimestamp() === $this->img->getTimestamp() ) { |
| 925 | + if ( $file->getTimestamp() === $this->img->getTimestamp() ) { |
926 | 926 | $selected = "class='filehistory-selected'"; |
927 | 927 | } |
928 | 928 | $row .= "<td $selected style='white-space: nowrap;'>"; |
929 | | - if( !$file->userCan(File::DELETED_FILE) ) { |
| 929 | + if ( !$file->userCan( File::DELETED_FILE ) ) { |
930 | 930 | # Don't link to unviewable files |
931 | 931 | $row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>'; |
932 | | - } elseif( $file->isDeleted(File::DELETED_FILE) ) { |
| 932 | + } elseif ( $file->isDeleted( File::DELETED_FILE ) ) { |
933 | 933 | $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); |
934 | 934 | # Make a link to review the image |
935 | 935 | $url = $this->skin->link( |
— | — | @@ -942,7 +942,7 @@ |
943 | 943 | ), |
944 | 944 | array( 'known', 'noclasses' ) |
945 | 945 | ); |
946 | | - $row .= '<span class="history-deleted">'.$url.'</span>'; |
| 946 | + $row .= '<span class="history-deleted">' . $url . '</span>'; |
947 | 947 | } else { |
948 | 948 | $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img ); |
949 | 949 | $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) ); |
— | — | @@ -962,12 +962,12 @@ |
963 | 963 | |
964 | 964 | // Uploading user |
965 | 965 | $row .= '<td>'; |
966 | | - if( $local ) { |
| 966 | + if ( $local ) { |
967 | 967 | // Hide deleted usernames |
968 | | - if( $file->isDeleted(File::DELETED_USER) ) { |
| 968 | + if ( $file->isDeleted( File::DELETED_USER ) ) { |
969 | 969 | $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>'; |
970 | 970 | } 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;'>" . |
972 | 972 | $this->skin->userToolLinks( $user, $usertext ) . "</span>"; |
973 | 973 | } |
974 | 974 | } else { |
— | — | @@ -976,8 +976,8 @@ |
977 | 977 | $row .= '</td><td>'; |
978 | 978 | |
979 | 979 | // 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>'; |
982 | 982 | } else { |
983 | 983 | $row .= $this->skin->commentBlock( $description, $this->title ); |
984 | 984 | } |
— | — | @@ -992,12 +992,12 @@ |
993 | 993 | protected function getThumbForLine( $file ) { |
994 | 994 | global $wgLang; |
995 | 995 | |
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 ) ) { |
997 | 997 | $params = array( |
998 | 998 | 'width' => '120', |
999 | 999 | 'height' => '120', |
1000 | 1000 | ); |
1001 | | - $timestamp = wfTimestamp(TS_MW, $file->getTimestamp()); |
| 1001 | + $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() ); |
1002 | 1002 | |
1003 | 1003 | $thumbnail = $file->transform( $params ); |
1004 | 1004 | $options = array( |
— | — | @@ -1021,7 +1021,7 @@ |
1022 | 1022 | function __construct( $imagePage ) { |
1023 | 1023 | parent::__construct(); |
1024 | 1024 | $this->mImagePage = $imagePage; |
1025 | | - $this->mTitle = clone( $imagePage->getTitle() ); |
| 1025 | + $this->mTitle = clone ( $imagePage->getTitle() ); |
1026 | 1026 | $this->mTitle->setFragment( '#filehistory' ); |
1027 | 1027 | $this->mImg = null; |
1028 | 1028 | $this->mHist = array(); |
— | — | @@ -1047,68 +1047,68 @@ |
1048 | 1048 | function getBody() { |
1049 | 1049 | $s = ''; |
1050 | 1050 | $this->doQuery(); |
1051 | | - if( count($this->mHist) ) { |
| 1051 | + if ( count( $this->mHist ) ) { |
1052 | 1052 | $list = new ImageHistoryList( $this->mImagePage ); |
1053 | 1053 | # Generate prev/next links |
1054 | 1054 | $navLink = $this->getNavigationBar(); |
1055 | | - $s = $list->beginImageHistoryList($navLink); |
| 1055 | + $s = $list->beginImageHistoryList( $navLink ); |
1056 | 1056 | // 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++ ) { |
1058 | 1058 | $file = $this->mHist[$i]; |
1059 | 1059 | $s .= $list->imageHistoryLine( !$file->isOld(), $file ); |
1060 | 1060 | } |
1061 | | - $s .= $list->endImageHistoryList($navLink); |
| 1061 | + $s .= $list->endImageHistoryList( $navLink ); |
1062 | 1062 | } |
1063 | 1063 | return $s; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | function doQuery() { |
1067 | | - if( $this->mQueryDone ) return; |
| 1067 | + if ( $this->mQueryDone ) return; |
1068 | 1068 | $this->mImg = $this->mImagePage->getFile(); // ensure loading |
1069 | | - if( !$this->mImg->exists() ) { |
| 1069 | + if ( !$this->mImg->exists() ) { |
1070 | 1070 | return; |
1071 | 1071 | } |
1072 | 1072 | $queryLimit = $this->mLimit + 1; // limit plus extra row |
1073 | | - if( $this->mIsBackwards ) { |
| 1073 | + if ( $this->mIsBackwards ) { |
1074 | 1074 | // 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 ); |
1076 | 1076 | // 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 ); |
1080 | 1080 | } |
1081 | 1081 | } else { |
1082 | 1082 | // 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 ) { |
1084 | 1084 | $this->mHist[] = $this->mImg; |
1085 | 1085 | } |
1086 | 1086 | // 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; |
1088 | 1088 | // Fetch the file history |
1089 | 1089 | $this->mHist = array_merge( $this->mHist, |
1090 | | - $this->mImg->getHistory($oiLimit,$this->mOffset,null,false) ); |
| 1090 | + $this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) ); |
1091 | 1091 | } |
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 ) { |
1094 | 1094 | # Index value of top item in the list |
1095 | 1095 | $firstIndex = $this->mIsBackwards ? |
1096 | | - $this->mHist[$numRows-1]->getTimestamp() : $this->mHist[0]->getTimestamp(); |
| 1096 | + $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp(); |
1097 | 1097 | # 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 ) { |
1100 | 1100 | # Index value of item past the index |
1101 | 1101 | $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp(); |
1102 | 1102 | # Index value of bottom item in the list |
1103 | 1103 | $lastIndex = $this->mHist[1]->getTimestamp(); |
1104 | 1104 | # Display range |
1105 | | - $this->mRange = array( 1, $numRows-1 ); |
| 1105 | + $this->mRange = array( 1, $numRows - 1 ); |
1106 | 1106 | } else { |
1107 | 1107 | # Index value of item past the index |
1108 | | - $this->mPastTheEndIndex = $this->mHist[$numRows-1]->getTimestamp(); |
| 1108 | + $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp(); |
1109 | 1109 | # Index value of bottom item in the list |
1110 | | - $lastIndex = $this->mHist[$numRows-2]->getTimestamp(); |
| 1110 | + $lastIndex = $this->mHist[$numRows - 2]->getTimestamp(); |
1111 | 1111 | # Display range |
1112 | | - $this->mRange = array( 0, $numRows-2 ); |
| 1112 | + $this->mRange = array( 0, $numRows - 2 ); |
1113 | 1113 | } |
1114 | 1114 | } else { |
1115 | 1115 | # Setting indexes to an empty string means that they will be |
— | — | @@ -1118,16 +1118,16 @@ |
1119 | 1119 | $this->mPastTheEndIndex = ''; |
1120 | 1120 | # Index value of bottom item in the list |
1121 | 1121 | $lastIndex = $this->mIsBackwards ? |
1122 | | - $this->mHist[0]->getTimestamp() : $this->mHist[$numRows-1]->getTimestamp(); |
| 1122 | + $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp(); |
1123 | 1123 | # Display range |
1124 | | - $this->mRange = array( 0, $numRows-1 ); |
| 1124 | + $this->mRange = array( 0, $numRows - 1 ); |
1125 | 1125 | } |
1126 | 1126 | } else { |
1127 | 1127 | $firstIndex = ''; |
1128 | 1128 | $lastIndex = ''; |
1129 | 1129 | $this->mPastTheEndIndex = ''; |
1130 | 1130 | } |
1131 | | - if( $this->mIsBackwards ) { |
| 1131 | + if ( $this->mIsBackwards ) { |
1132 | 1132 | $this->mIsFirst = ( $numRows < $queryLimit ); |
1133 | 1133 | $this->mIsLast = ( $this->mOffset == '' ); |
1134 | 1134 | $this->mLastShown = $firstIndex; |