Quick fix to make diffonly work properly on category and image pages. Should probabl...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 17 Jan 2007 05:01:54 +0000 (05:01 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 17 Jan 2007 05:01:54 +0000 (05:01 +0000)
includes/CategoryPage.php
includes/ImagePage.php

index 0086a2f..462558b 100644 (file)
@@ -14,6 +14,14 @@ if( !defined( 'MEDIAWIKI' ) )
  */
 class CategoryPage extends Article {
        function view() {
+               global $wgRequest, $wgUser;
+
+               $diff = $wgRequest->getVal( 'diff' );
+               $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
+
+               if ( isset( $diff ) && $diffOnly )
+                       return Article::view();
+
                if(!wfRunHooks('CategoryPageView', array(&$this))) return;
 
                if ( NS_CATEGORY == $this->mTitle->getNamespace() ) {
index 4503c4a..226bf26 100644 (file)
@@ -29,59 +29,62 @@ class ImagePage extends Article {
        }
 
        function view() {
-               global $wgOut, $wgShowEXIF;
+               global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
 
                $this->img = new Image( $this->mTitle );
 
-               if( $this->mTitle->getNamespace() == NS_IMAGE  ) {
-                       if ($wgShowEXIF && $this->img->exists()) {
-                               $exif = $this->img->getExifData();
-                               $showmeta = count($exif) ? true : false;
-                       } else {
-                               $exif = false;
-                               $showmeta = false;
-                       }
+               $diff = $wgRequest->getVal( 'diff' );
+               $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
 
-                       if ($this->img->exists())
-                               $wgOut->addHTML($this->showTOC($showmeta));
+               if ( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) )
+                       return Article::view();
 
-                       $this->openShowImage();
+               if ($wgShowEXIF && $this->img->exists()) {
+                       $exif = $this->img->getExifData();
+                       $showmeta = count($exif) ? true : false;
+               } else {
+                       $exif = false;
+                       $showmeta = false;
+               }
 
-                       # No need to display noarticletext, we use our own message, output in openShowImage()
-                       if( $this->getID() ) {
-                               Article::view();
-                       } else {
-                               # Just need to set the right headers
-                               $wgOut->setArticleFlag( true );
-                               $wgOut->setRobotpolicy( 'index,follow' );
-                               $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
-                               $this->viewUpdates();
-                       }
+               if ($this->img->exists())
+                       $wgOut->addHTML($this->showTOC($showmeta));
 
-                       # Show shared description, if needed
-                       if( $this->mExtraDescription ) {
-                               $fol = wfMsg( 'shareddescriptionfollows' );
-                               if( $fol != '-' ) {
-                                       $wgOut->addWikiText( $fol );
-                               }
-                               $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
-                       }
+               $this->openShowImage();
 
-                       $this->closeShowImage();
-                       $this->imageHistory();
-                       $this->imageLinks();
-                       if( $exif ) {
-                               global $wgStylePath, $wgStyleVersion;
-                               $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
-                               $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
-                               $wgOut->addHTML( "<h2 id=\"metadata\">" . wfMsgHtml( 'metadata' ) . "</h2>\n" );
-                               $wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
-                               $wgOut->addHTML(
-                                       "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?$wgStyleVersion\"></script>\n" .
-                                       "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
-                       }
-               } else {
+               # No need to display noarticletext, we use our own message, output in openShowImage()
+               if ( $this->getID() ) {
                        Article::view();
+               } else {
+                       # Just need to set the right headers
+                       $wgOut->setArticleFlag( true );
+                       $wgOut->setRobotpolicy( 'index,follow' );
+                       $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+                       $this->viewUpdates();
+               }
+
+               # Show shared description, if needed
+               if ( $this->mExtraDescription ) {
+                       $fol = wfMsg( 'shareddescriptionfollows' );
+                       if( $fol != '-' ) {
+                               $wgOut->addWikiText( $fol );
+                       }
+                       $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
+               }
+
+               $this->closeShowImage();
+               $this->imageHistory();
+               $this->imageLinks();
+
+               if ( $exif ) {
+                       global $wgStylePath, $wgStyleVersion;
+                       $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
+                       $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
+                       $wgOut->addHTML( "<h2 id=\"metadata\">" . wfMsgHtml( 'metadata' ) . "</h2>\n" );
+                       $wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
+                       $wgOut->addHTML(
+                               "<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?$wgStyleVersion\"></script>\n" .
+                               "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
                }
        }