Update undelete.php to use short option aliases.
[lhc/web/wiklou.git] / includes / ImageGallery.php
index ce4404b..f490a38 100644 (file)
@@ -13,7 +13,6 @@ class ImageGallery
 {
        var $mImages, $mShowBytes, $mShowFilename;
        var $mCaption = false;
-       var $mSkin = false;
 
        /**
         * Hide blacklisted images?
@@ -22,6 +21,7 @@ class ImageGallery
 
        /**
         * Registered parser object for output callbacks
+        * @var Parser
         */
        var $mParser;
 
@@ -126,24 +126,10 @@ class ImageGallery
         * Instruct the class to use a specific skin for rendering
         *
         * @param $skin Skin object
+        * @deprecated Not used anymore
         */
        function useSkin( $skin ) {
-               $this->mSkin = $skin;
-       }
-
-       /**
-        * Return the skin that should be used
-        *
-        * @return Skin object
-        */
-       function getSkin() {
-               if( !$this->mSkin ) {
-                       global $wgUser;
-                       $skin = $wgUser->getSkin();
-               } else {
-                       $skin = $this->mSkin;
-               }
-               return $skin;
+               /* no op */
        }
 
        /**
@@ -229,8 +215,6 @@ class ImageGallery
        function toHTML() {
                global $wgLang;
 
-               $sk = $this->getSkin();
-
                if ( $this->mPerRow > 0 ) {
                        $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS );
                        $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ""; 
@@ -238,27 +222,32 @@ class ImageGallery
                }
 
                $attribs = Sanitizer::mergeAttributes(
-                       array(
-                               'class' => 'gallery'),
-                       $this->mAttribs );
+                       array( 'class' => 'gallery' ), $this->mAttribs );
+
                $s = Xml::openElement( 'ul', $attribs );
                if ( $this->mCaption ) {
                        $s .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
                }
 
                $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights );
-               $i = 0;
+               # Output each image...
                foreach ( $this->mImages as $pair ) {
                        $nt = $pair[0];
                        $text = $pair[1]; # "text" means "caption" here
 
+                       $descQuery = false;
                        if ( $nt->getNamespace() == NS_FILE ) {
-                               # Give extensions a chance to select the file revision for us
-                               $time = $sha1 = $descQuery = false;
-                               wfRunHooks( 'BeforeGalleryFindFile',
-                                       array( &$this, &$nt, &$time, &$descQuery, &$sha1 ) );
-                               # Fetch and register the file (file title may be different via hooks)
-                               list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
+                               # Get the file...
+                               if ( $this->mParser instanceof Parser ) {
+                                       # Give extensions a chance to select the file revision for us
+                                       $time = $sha1 = false;
+                                       wfRunHooks( 'BeforeParserFetchFileAndTitle',
+                                               array( $this->mParser, $nt, &$time, &$sha1, &$descQuery ) );
+                                       # Fetch and register the file (file title may be different via hooks)
+                                       list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
+                               } else {
+                                       $img = wfFindFile( $nt );
+                               }
                        } else {
                                $img = false;
                        }
@@ -270,7 +259,7 @@ class ImageGallery
                        } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
                                # The image is blacklisted, just show it as a text link.
                                $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' .
-                                       $sk->link(
+                                       Linker::link(
                                                $nt,
                                                htmlspecialchars( $nt->getText() ),
                                                array(),
@@ -315,7 +304,7 @@ class ImageGallery
 
                        //TODO
                        // $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
-                       // $ul = $sk->link( $linkTarget, $ut );
+                       // $ul = Linker::link( $linkTarget, $ut );
 
                        if( $this->mShowBytes ) {
                                if( $img ) {
@@ -330,7 +319,7 @@ class ImageGallery
                        }
 
                        $textlink = $this->mShowFilename ?
-                               $sk->link(
+                               Linker::link(
                                        $nt,
                                        htmlspecialchars( $wgLang->truncate( $nt->getText(), $this->mCaptionLength ) ),
                                        array(),
@@ -353,7 +342,6 @@ class ImageGallery
                                                . $textlink . $text . $nb
                                        . "\n\t\t\t</div>"
                                . "\n\t\t</div></li>";
-                       ++$i;
                }
                $s .= "\n</ul>";