From 8f96eb5e2a8335ecf7d76521eb7e2a4b428ee03a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 5 May 2005 02:39:21 +0000 Subject: [PATCH] * Don't display the metadata TOC link for pages where it's not applicable --- includes/ImagePage.php | 58 +++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 14679ebf60..4bb4d5b71c 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -20,14 +20,22 @@ class ImagePage extends Article { /* private */ var $img; // Image object this page is shown for function view() { - global $wgUseExternalEditor, $wgOut ; + global $wgUseExternalEditor, $wgOut, $wgShowEXIF; $this->img = new Image( $this->mTitle ); if( $this->mTitle->getNamespace() == NS_IMAGE ) { - if( $this->img->exists() ) { - $this->showTOC(); + if ($wgShowEXIF && $this->img->exists()) { + $exif = $this->img->getExifData(); + $showmeta = count($exif) ? true : false; + } else { + $exif = false; + $showmeta = false; } + + if ($this->img->exists()) + $wgOut->addHTML($this->showTOC($showmeta)); + $this->openShowImage(); # No need to display noarticletext, we use our own message, output in openShowImage() @@ -44,38 +52,42 @@ class ImagePage extends Article { $this->closeShowImage(); $this->imageHistory(); + if ($exif) + $wgOut->addHTML($this->makeMetadataTable($exif)); $this->imageLinks(); - if( $this->img->exists() ) { - $this->showEXIFdata(); - } } else { Article::view(); } } - function showTOC() { - global $wgOut, $wgShowEXIF, $wgLang; + /** + * Create the TOC + * + * @access private + * + * @param bool $metadata Whether or not to show the metadata link + * @return string + */ + function showTOC( $metadata ) { + global $wgLang; $r = ''; - $wgOut->addHTML( $r ); + return $r; } - - function showEXIFdata() { - global $wgOut, $wgShowEXIF; - if( !$wgShowEXIF ) { - return; - } - # Get the EXIF data - $exif = $this->img->getExifData(); - if( count ( $exif ) == 0 ) { - return; # No EXIF data available - } - + /** + * Make a table with metadata to be shown in the output page. + * + * @access private + * + * @param array $exif The array containing the EXIF data + * @return string + */ + function makeMetadataTable( $exif ) { # Create the table $r = '

'. htmlspecialchars( wfMsg( 'metadata' ) ) . "

\n"; $r .= "\n" ; @@ -97,7 +109,7 @@ class ImagePage extends Article { $r .= "\n"; } - $wgOut->addHTML( $r . "
\n" ); + return "$r\n"; } function openShowImage() -- 2.20.1