Merge "ImageListPager: Kill that annoying GROUP BY"
[lhc/web/wiklou.git] / includes / page / ImagePage.php
index bf3eaf4..cbc5966 100644 (file)
@@ -86,18 +86,15 @@ class ImagePage extends Article {
                $this->repo = $img->getRepo();
        }
 
-       /**
-        * Handler for action=render
-        * Include body text only; none of the image extras
-        */
-       public function render() {
-               $this->getContext()->getOutput()->setArticleBodyOnly( true );
-               parent::view();
-       }
-
        public function view() {
                global $wgShowEXIF;
 
+               // For action=render, include body text only; none of the image extras
+               if ( $this->viewIsRenderAction ) {
+                       parent::view();
+                       return;
+               }
+
                $out = $this->getContext()->getOutput();
                $request = $this->getContext()->getRequest();
                $diff = $request->getVal( 'diff' );
@@ -161,7 +158,7 @@ class ImagePage extends Article {
                if ( $this->mExtraDescription ) {
                        $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
                        if ( !$fol->isDisabled() ) {
-                               $out->addWikiText( $fol->plain() );
+                               $out->addWikiTextAsInterface( $fol->plain() );
                        }
                        $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
                }
@@ -190,7 +187,10 @@ class ImagePage extends Article {
                                'h2',
                                [ 'id' => 'metadata' ],
                                        $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
-                       $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
+                       $out->wrapWikiTextAsInterface(
+                               'mw-imagepage-section-metadata',
+                               $this->makeMetadataTable( $formattedMetadata )
+                       );
                        $out->addModules( [ 'mediawiki.action.view.metadata' ] );
                }
 
@@ -249,8 +249,7 @@ class ImagePage extends Article {
         * @return string The metadata table. This is treated as Wikitext (!)
         */
        protected function makeMetadataTable( $metadata ) {
-               $r = "<div class=\"mw-imagepage-section-metadata\">";
-               $r .= $this->getContext()->msg( 'metadata-help' )->plain();
+               $r = $this->getContext()->msg( 'metadata-help' )->plain();
                // Intial state is collapsed
                // see filepage.css and mediawiki.action.view.metadata module.
                $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
@@ -267,7 +266,7 @@ class ImagePage extends Article {
                                );
                        }
                }
-               $r .= "</table>\n</div>\n";
+               $r .= "</table>\n";
                return $r;
        }
 
@@ -282,7 +281,7 @@ class ImagePage extends Article {
         */
        public function getEmptyPageParserOutput( ParserOptions $options ) {
                $this->loadFile();
-               if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getId() ) {
+               if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && $this->getId() == 0 ) {
                        return new ParserOutput();
                }
                return parent::getEmptyPageParserOutput( $options );
@@ -542,16 +541,15 @@ class ImagePage extends Article {
                                // to the filename, because it can get copied with it.
                                // See T27277.
                                // phpcs:disable Generic.Files.LineLength
-                               $out->addWikiText( <<<EOT
-<div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
-<div class="mediaWarning">$warning</div>
+                               $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
+<span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span>
 EOT
                                );
                                // phpcs:enable
+                               $out->wrapWikiTextAsInterface( 'mediaWarning', $warning );
                        } else {
-                               $out->addWikiText( <<<EOT
-<div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
-</div>
+                               $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
+{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
 EOT
                                );
                        }
@@ -574,10 +572,7 @@ EOT
                                        'file-no-thumb-animation'
                                )->plain();
 
-                               $out->addWikiText( <<<EOT
-<div class="mw-noanimatethumb">{$noAnimMesg}</div>
-EOT
-                               );
+                               $out->wrapWikiTextAsInterface( 'mw-noanimatethumb', $noAnimMesg );
                        }
 
                        if ( !$this->displayImg->isLocal() ) {
@@ -1005,7 +1000,7 @@ EOT
                $out->setRobotPolicy( 'noindex,nofollow' );
                $out->setArticleRelated( false );
                $out->enableClientCache( false );
-               $out->addWikiText( $description );
+               $out->addWikiTextAsInterface( $description );
        }
 
        /**