Remove single-item HTML list for re-upload link
authorSam Wilson <sam@samwilson.id.au>
Wed, 7 Aug 2019 21:09:57 +0000 (05:09 +0800)
committerSam Wilson <sam@samwilson.id.au>
Wed, 7 Aug 2019 21:22:46 +0000 (05:22 +0800)
The 'upload links box' only contains a single link (or message),
so there's no need for it to be a list. This also adds a top-level
class to this box, for easier CSS/JS selecting.

Change-Id: I3967eea82dcd63a3e161daa13e49204e4d6dde97

includes/page/ImagePage.php

index 16b83d1..4f08995 100644 (file)
@@ -736,13 +736,10 @@ EOT
        }
 
        /**
-        * Print out the various links at the bottom of the image page, e.g. reupload,
-        * external editing (and instructions link) etc.
+        * Add the re-upload link (or message about not being able to re-upload) to the output.
         */
        protected function uploadLinksBox() {
-               global $wgEnableUploads;
-
-               if ( !$wgEnableUploads ) {
+               if ( !$this->getContext()->getConfig()->get( 'EnableUploads' ) ) {
                        return;
                }
 
@@ -751,27 +748,27 @@ EOT
                        return;
                }
 
-               $out = $this->getContext()->getOutput();
-               $out->addHTML( "<ul>\n" );
-
-               # "Upload a new version of this file" link
                $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
                if ( $canUpload && UploadBase::userCanReUpload(
                                $this->getContext()->getUser(),
                                $this->mPage->getFile() )
                ) {
+                       // "Upload a new version of this file" link
                        $ulink = Linker::makeExternalLink(
                                $this->getUploadUrl(),
                                $this->getContext()->msg( 'uploadnewversion-linktext' )->text()
                        );
-                       $out->addHTML( "<li id=\"mw-imagepage-reupload-link\">"
-                               . "<div class=\"plainlinks\">{$ulink}</div></li>\n" );
+                       $attrs = [ 'class' => 'plainlinks', 'id' => 'mw-imagepage-reupload-link' ];
+                       $linkPara = Html::rawElement( 'p', $attrs, $ulink );
                } else {
-                       $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">"
-                               . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
+                       // "You cannot overwrite this file." message
+                       $attrs = [ 'id' => 'mw-imagepage-upload-disallowed' ];
+                       $msg = $this->getContext()->msg( 'upload-disallowed-here' )->text();
+                       $linkPara = Html::element( 'p', $attrs, $msg );
                }
 
-               $out->addHTML( "</ul>\n" );
+               $uploadLinks = Html::rawElement( 'div', [ 'class' => 'mw-imagepage-upload-links' ], $linkPara );
+               $this->getContext()->getOutput()->addHTML( $uploadLinks );
        }
 
        /**