copyediting comments
[lhc/web/wiklou.git] / includes / ImagePage.php
index c19e83f..c0b3d7f 100644 (file)
@@ -1,4 +1,25 @@
 <?php
+/**
+ * Special handling for file description pages.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
 /**
  * Class for viewing MediaWiki file description pages
  *
@@ -75,7 +96,7 @@ class ImagePage extends Article {
         * Include body text only; none of the image extras
         */
        public function render() {
-               $this->getContext()->setArticleBodyOnly( true );
+               $this->getContext()->getOutput()->setArticleBodyOnly( true );
                parent::view();
        }
 
@@ -136,8 +157,10 @@ class ImagePage extends Article {
                        $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
                                'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
                                'class' => 'mw-content-'.$pageLang->getDir() ) ) );
-                       parent::view();
-                       $out->addHTML( Xml::closeElement( 'div' ) );
+
+            parent::view(); #FIXME: use ContentHandler::makeArticle() !!
+
+                       $wgOut->addHTML( Xml::closeElement( 'div' ) );
                } else {
                        # Just need to set the right headers
                        $out->setArticleFlag( true );
@@ -247,20 +270,20 @@ class ImagePage extends Article {
                return $r;
        }
 
-       /**
-        * Overloading Article's getContent method.
-        *
-        * Omit noarticletext if sharedupload; text will be fetched from the
-        * shared upload server if possible.
-        * @return string
-        */
-       public function getContent() {
-               $this->loadFile();
-               if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
-                       return '';
-               }
-               return parent::getContent();
-       }
+    /**
+     * Overloading Article's getContentObject method.
+     *
+     * Omit noarticletext if sharedupload; text will be fetched from the
+     * shared upload server if possible.
+     * @return string
+     */
+    public function getContentObject() {
+        $this->loadFile();
+        if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
+            return null;
+        }
+        return parent::getContentObject();
+    }
 
        protected function openShowImage() {
                global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
@@ -325,18 +348,30 @@ class ImagePage extends Article {
                                                # Note that $height <= $maxHeight now, but might not be identical
                                                # because of rounding.
                                        }
-                                       $msgbig  = wfMsgHtml( 'show-big-image' );
+                                       $msgbig = wfMsgHtml( 'show-big-image' );
+                                       if ( $this->displayImg->getRepo()->canTransformVia404() ) {
+                                               $thumbSizes = $wgImageLimits;
+                                       } else {
+                                               # Creating thumb links triggers thumbnail generation.
+                                               # Just generate the thumb for the current users prefs.
+                                               $thumbOption = $user->getOption( 'thumbsize' );
+                                               $thumbSizes = array( isset( $wgImageLimits[$thumbOption] )
+                                                       ? $wgImageLimits[$thumbOption]
+                                                       : $wgImageLimits[User::getDefaultOption( 'thumbsize' )] );
+                                       }
+                                       # Generate thumbnails or thumbnail links as needed...
                                        $otherSizes = array();
-                                       foreach ( $wgImageLimits as $size ) {
-                                               if ( $size[0] < $width_orig && $size[1] < $height_orig &&
-                                                               $size[0] != $width && $size[1] != $height ) {
+                                       foreach ( $thumbSizes as $size ) {
+                                               if ( $size[0] < $width_orig && $size[1] < $height_orig
+                                                       && $size[0] != $width && $size[1] != $height )
+                                               {
                                                        $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] );
                                                }
                                        }
                                        $msgsmall = wfMessage( 'show-big-image-preview' )->
                                                rawParams( $this->makeSizeLink( $params, $width, $height ) )->
                                                parse();
-                                       if ( count( $otherSizes ) && $this->displayImg->getRepo()->canTransformVia404() ) {
+                                       if ( count( $otherSizes ) ) {
                                                $msgsmall .= ' ' .
                                                Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ),
                                                        wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->
@@ -1066,7 +1101,10 @@ class ImageHistoryList extends ContextSource {
                // Image dimensions + size
                $row .= '<td>';
                $row .= htmlspecialchars( $file->getDimensionsString() );
-               $row .= ' <span style="white-space: nowrap;">(' . Linker::formatSize( $file->getSize() ) . ')</span>';
+               $row .= $this->getContext()->msg( 'word-separator' )->plain();
+               $row .= '<span style="white-space: nowrap;">';
+               $row .= $this->getContext()->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
+               $row .= '</span>';
                $row .= '</td>';
 
                // Uploading user