r60875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60874‎ | r60875 | r60876 >
Date:20:17, 9 January 2010
Author:btongminh
Status:ok
Tags:
Comment:
Fix use of an array for no apparent reason.
SpecialUpload::getExistsWarning now no longer encapsulates its results in <li>
Further minor cleanup
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -315,7 +315,7 @@
316316 foreach( $warnings as $warning => $args ) {
317317 $msg = '';
318318 if( $warning == 'exists' ) {
319 - $msg = self::getExistsWarning( $args );
 319+ $msg = "\t<li>" . self::getExistsWarning( $args ) . "</li>\n";
320320 } elseif( $warning == 'duplicate' ) {
321321 $msg = self::getDupeWarning( $args );
322322 } elseif( $warning == 'duplicate-archive' ) {
@@ -323,7 +323,7 @@
324324 array( Title::makeTitle( NS_FILE, $args )->getPrefixedText() ) )
325325 . "</li>\n";
326326 } else {
327 - if ( is_bool( $args ) )
 327+ if ( $args === true )
328328 $args = array();
329329 elseif ( !is_array( $args ) )
330330 $args = array( $args );
@@ -569,7 +569,6 @@
570570 *
571571 * @param array $exists The result of UploadBase::getExistsWarning
572572 * @return string Empty string if there is no warning or an HTML fragment
573 - * consisting of one or more <li> elements if there is a warning.
574573 */
575574 public static function getExistsWarning( $exists ) {
576575 global $wgUser, $wgContLang;
@@ -579,30 +578,30 @@
580579
581580 $file = $exists['file'];
582581 $filename = $file->getTitle()->getPrefixedText();
583 - $warning = array();
 582+ $warning = '';
584583
585584 $sk = $wgUser->getSkin();
586585
587586 if( $exists['warning'] == 'exists' ) {
588587 // Exact match
589 - $warning[] = '<li>' . wfMsgExt( 'fileexists', 'parseinline', $filename ) . '</li>';
 588+ $warning = wfMsgExt( 'fileexists', 'parseinline', $filename );
590589 } elseif( $exists['warning'] == 'page-exists' ) {
591590 // Page exists but file does not
592 - $warning[] = '<li>' . wfMsgExt( 'filepageexists', 'parseinline', $filename ) . '</li>';
 591+ $warning = wfMsgExt( 'filepageexists', 'parseinline', $filename );
593592 } elseif ( $exists['warning'] == 'exists-normalized' ) {
594 - $warning[] = '<li>' . wfMsgExt( 'fileexists-extension', 'parseinline', $filename,
595 - $exists['normalizedFile']->getTitle()->getPrefixedText() ) . '</li>';
 593+ $warning = wfMsgExt( 'fileexists-extension', 'parseinline', $filename,
 594+ $exists['normalizedFile']->getTitle()->getPrefixedText() );
596595 } elseif ( $exists['warning'] == 'thumb' ) {
597596 // Swapped argument order compared with other messages for backwards compatibility
598 - $warning[] = '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline',
599 - $exists['thumbFile']->getTitle()->getPrefixedText(), $filename ) . '</li>';
 597+ $warning = wfMsgExt( 'fileexists-thumbnail-yes', 'parseinline',
 598+ $exists['thumbFile']->getTitle()->getPrefixedText(), $filename );
600599 } elseif ( $exists['warning'] == 'thumb-name' ) {
601600 // Image w/o '180px-' does not exists, but we do not like these filenames
602601 $name = $file->getName();
603602 $badPart = substr( $name, 0, strpos( $name, '-' ) + 1 );
604 - $warning[] = '<li>' . wfMsgExt( 'file-thumbnail-no', 'parseinline', $badPart ) . '</li>';
 603+ $warning = wfMsgExt( 'file-thumbnail-no', 'parseinline', $badPart );
605604 } elseif ( $exists['warning'] == 'bad-prefix' ) {
606 - $warning[] = '<li>' . wfMsgExt( 'filename-bad-prefix', 'parseinline', $exists['prefix'] ) . '</li>';
 605+ $warning = wfMsgExt( 'filename-bad-prefix', 'parseinline', $exists['prefix'] );
607606 } elseif ( $exists['warning'] == 'was-deleted' ) {
608607 # If the file existed before and was deleted, warn the user of this
609608 $ltitle = SpecialPage::getTitleFor( 'Log' );
@@ -615,10 +614,10 @@
616615 'page' => $filename
617616 )
618617 );
619 - $warning[] = '<li>' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '</li>';
 618+ $warning = wfMsgWikiHtml( 'filewasdeleted', $llink );
620619 }
621620
622 - return implode( "\n", $warning );
 621+ return $warning;
623622 }
624623
625624 /**
@@ -639,7 +638,7 @@
640639 $exists = UploadBase::getExistsWarning( $file );
641640 $warning = self::getExistsWarning( $exists );
642641 if ( $warning !== '' ) {
643 - $s = "<ul>$warning</ul>";
 642+ $s = "<div>$warning</div>";
644643 }
645644 }
646645 return $s;

Status & tagging log