* (bug 5805) message nbytes can now use {{plural:}}
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Fri, 5 May 2006 12:21:12 +0000 (12:21 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Fri, 5 May 2006 12:21:12 +0000 (12:21 +0000)
* Cleaned up Special:Imagelist a bit

RELEASE-NOTES
includes/GlobalFunctions.php
includes/ImageGallery.php
includes/ImagePage.php
includes/SpecialImagelist.php
includes/SpecialMIMEsearch.php
includes/SpecialNewimages.php
includes/SpecialNewpages.php
includes/SpecialSearch.php
includes/SpecialShortpages.php
languages/Messages.php

index 54c3ae9..3df3aa4 100644 (file)
@@ -212,6 +212,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   Special:Wantedcategories and Special:Mostlinkedcategories.
 * (bug 3309) Allow comments when undeleting pages
 * Clean up Special:Undelete a bit
+* (bug 5805) message nbytes can now use {{plural:}}
+* Clean up Special:Imagelist a bit
 
 == Compatibility ==
 
index 59a8191..5d9627a 100644 (file)
@@ -554,7 +554,7 @@ function wfMsgWikiHtml( $key ) {
  *  <i>replaceafter<i>: parameters are substituted after parsing or escaping
  */
 function wfMsgExt( $key, $options ) {
-       global $wgOut;
+       global $wgOut, $wgMsgParserOptions, $wgParser;
 
        $args = func_get_args();
        array_shift( $args );
@@ -578,7 +578,11 @@ function wfMsgExt( $key, $options ) {
                if( preg_match( "~^<p>(.*)\n?</p>$~", $string, $m ) ) {
                        $string = $m[1];
                }
-       } elseif ( in_array('escape', $options) ) {
+       } elseif ( in_array('parsemag', $options) ) {
+               $string = $wgParser->transformMsg($string, $wgMsgParserOptions);
+       }
+
+       if ( in_array('escape', $options) ) {
                $string = htmlspecialchars ( $string );
        }
 
@@ -1623,7 +1627,7 @@ function in_string( $needle, $str ) {
 
 function wfSpecialList( $page, $details ) {
        global $wgContLang;
-       $details = $details ? $wgContLang->getDirMark() . " ($details)" : "";
+       $details = $details ? ' ' . $wgContLang->getDirMark() . "($details)" : "";
        return $page . $details;
 }
 
index 561cfb1..7e18464 100644 (file)
@@ -115,7 +115,8 @@ class ImageGallery
 
                        if( $this->mShowBytes ) {
                                if( $img->exists() ) {
-                                       $nb = wfMsgHtml( 'nbytes', $wgLang->formatNum( $img->getSize() ) );
+                                       $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
+                                               $wgLang->formatNum( $img->getSize() ) );
                                } else {
                                        $nb = wfMsgHtml( 'filemissing' );
                                }
index 98feeb4..9f1a480 100644 (file)
@@ -755,7 +755,8 @@ class ImageHistoryList {
                        $usertalk = $this->skin->makeLinkObj( Title::makeTitle( NS_USER_TALK, $usertext), $wgContLang->getNsText( NS_TALK ) );
                        $userdata = $userlink . ' (' . $usertalk . ')';
                }
-               $nbytes = wfMsg( 'nbytes', $size );
+               $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
+                       $wgLang->formatNum( $size ) );
                $widthheight = wfMsg( 'widthheight', $width, $height );
                $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
 
index 6438e9c..5ef203f 100644 (file)
@@ -18,10 +18,6 @@ function wfSpecialImagelist() {
        $sql = "SELECT img_size,img_name,img_user,img_user_text," .
          "img_description,img_timestamp FROM $image";
 
-       $byname = wfMsg( "byname" );
-       $bydate = wfMsg( "bydate" );
-       $bysize = wfMsg( "bysize" );
-
        if ( !$wgMiserMode && !empty( $wpIlMatch ) ) {
                $nt = Title::newFromUrl( $wpIlMatch );
                if($nt ) {
@@ -31,82 +27,65 @@ function wfSpecialImagelist() {
                        $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
                }
        }
+
        if ( "bysize" == $sort ) {
                $sql .= " ORDER BY img_size DESC";
-               $st = $bysize;
        } else if ( "byname" == $sort ) {
                $sql .= " ORDER BY img_name";
-               $st = $byname;
        } else {
                $sort = "bydate";
                $sql .= " ORDER BY img_timestamp DESC";
-               $st = $bydate;
        }
+
        list( $limit, $offset ) = wfCheckLimits( 50 );
-       if ( 0 == $limit ) {
-               $lt = wfMsg( 'imagelistall' );
-       } else {
-               $lt = $wgLang->formatNum( "${limit}" );
-               $sql .= " LIMIT {$limit}";
-       }
-       $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
+       $lt = $wgLang->formatNum( "${limit}" );
+       $sql .= " LIMIT {$limit}";
 
-       $text = wfMsg( "imagelisttext",
-               "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
-       $wgOut->addHTML( "<p>{$text}\n</p>" );
+       $wgOut->addWikiText( wfMsg( 'imglegend' ) );
+       $wgOut->addWikiText( wfMsg( 'imagelisttext', $lt, wfMsg( $sort ) ) );
 
        $sk = $wgUser->getSkin();
-       $sub = wfMsg( "ilsubmit" );
        $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
-       $action = $titleObj->escapeLocalURL(  "sort={$sort}&limit={$limit}" );
+       $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
 
        if ( !$wgMiserMode ) {
                $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
                  "{$action}\">" .
-                 "<input type='text' size='20' name=\"wpIlMatch\" value=\"" .
-                 htmlspecialchars( $wpIlMatch ) . "\" /> " .
-                 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
-       }
-       $nums = array( 50, 100, 250, 500 );
-       $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' );
-
-       $fill = "";
-       $first = true;
-       foreach ( $nums as $num ) {
-               if ( ! $first ) { $fill .= " | "; }
-               $first = false;
-
-               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
-                 "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
+                       wfElement( 'input',
+                               array(
+                                       'type' => 'text',
+                                       'size' => '20',
+                                       'name' => 'wpIlMatch',
+                                       'value' => $wpIlMatch, )) .
+                       wfElement( 'input',
+                               array(
+                                       'type' => 'submit',
+                                       'name' => 'wpIlSubmit',
+                                       'value' => wfMsg( 'ilsubmit'), )) .
+                       '</form>' );
        }
-       $text = wfMsg( "showlast", $fill, $byname );
-       $wgOut->addHTML( "<p>{$text}<br />\n" );
 
-       $fill = "";
-       $first = true;
-       foreach ( $nums as $num ) {
-               if ( ! $first ) { $fill .= " | "; }
-               $first = false;
-
-               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
-                 "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
-       }
-       $text = wfMsg( "showlast", $fill, $bysize );
-       $wgOut->addHTML( "{$text}<br />\n" );
-
-       $fill = "";
-       $first = true;
-       foreach ( $nums as $num ) {
-               if ( ! $first ) { $fill .= " | "; }
-               $first = false;
+       $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' );
 
-               $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
-                 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
+       foreach ( array( 'byname', 'bysize', 'bydate') as $sorttype ) {
+               $urls = null;
+               foreach ( array( 50, 100, 250, 500 ) as $num ) {
+                       $urls[] = $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
+                 "sort={$sorttype}&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
+               }
+               $sortlinks[] = wfMsgExt(
+                       'showlast',
+                       array( 'parseinline', 'replaceafter' ),
+                       implode($urls, ' | '),
+                       wfMsgExt( $sorttype, array('escape') )
+               );
        }
-       $text = wfMsg( "showlast", $fill, $bydate );
-       $wgOut->addHTML( "{$text}</p>\n<p>" );
+       $wgOut->addHTML( implode( $sortlinks, "<br />\n") . "\n\n<hr />" );
 
+       // lines
+       $wgOut->addHTML( '<p>' );
        $res = $dbr->query( $sql, "wfSpecialImagelist" );
+
        while ( $s = $dbr->fetchObject( $res ) ) {
                $name = $s->img_name;
                $ut = $s->img_user_text;
@@ -119,18 +98,21 @@ function wfSpecialImagelist() {
                $ilink = "<a href=\"" . htmlspecialchars( Image::imageUrl( $name ) ) .
                  "\">" . strtr(htmlspecialchars( $name ), '_', ' ') . "</a>";
 
-               $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
-               $l = "(" .
-                 $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
-                 wfMsg( "imgdesc" ) ) .
-                 ") {$ilink} . . {$nb} . . {$ul} . . " .
-                 $wgLang->timeanddate( $s->img_timestamp, true );
+               $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
+                       $wgLang->formatNum( $s->img_size ) );
+
+               $desc = $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
+                 wfMsg( 'imgdesc' ) );
 
-               $l .= $sk->commentBlock( $s->img_description );
-               $wgOut->addHTML( "{$l}<br />\n" );
+               $date = $wgLang->timeanddate( $s->img_timestamp, true );
+               $comment = $sk->commentBlock( $s->img_description );
+
+               $l = "({$desc}) {$ilink} . . {$nb} . . {$ul} . . {$date} {$comment}<br />\n";
+               $wgOut->addHTML( $l );
        }
-       $wgOut->addHTML( "</p>" );
+
        $dbr->freeResult( $res );
+       $wgOut->addHTML( '</p>' );
 }
 
 ?>
index 99c8ed3..6789b61 100644 (file)
@@ -70,12 +70,13 @@ class MIMEsearchPage extends QueryPage {
                $plink = $skin->makeLink( $nt->getPrefixedText(), $text );
 
                $download = $skin->makeMediaLink( $nt->getText(), 'fuck me!', wfMsgHtml( 'download' ) );
-               $bytes = wfMsg( 'nbytes', $wgLang->formatNum( $result->img_size ) );
+               $bytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
+                       $wgLang->formatNum( $result->img_size ) );
                $dimensions = wfMsg( 'widthheight', $result->img_width, $result->img_height );
                $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text );
                $time = $wgLang->timeanddate( $result->img_timestamp );
 
-               return "($download) $plink .. $dimensions .. $bytes .. $user .. $time";
+               return "($download) $plink . . $dimensions . . $bytes . . $user . . $time";
        }
 }
 
index 58d434b..1215f2a 100644 (file)
@@ -148,7 +148,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
        $bydate = wfMsg( 'bydate' );
        $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
        if ($shownav) {
-               $text = wfMsg( 'imagelisttext', "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
+               $text = wfMsg( 'imagelisttext', $lt, $bydate );
                $wgOut->addHTML( "<p>{$text}\n</p>" );
        }
 
index 40e22f1..c67a24b 100644 (file)
@@ -76,7 +76,8 @@ class NewPagesPage extends QueryPage {
                $u = $result->user;
                $ut = $result->user_text;
 
-               $length = wfMsgHtml( 'nbytes', htmlspecialchars( $wgLang->formatNum( $result->length ) ) );
+               $length = wfMsgExt( 'nbytes', array('parsemag', 'escape'),
+                       $wgLang->formatNum( $result->length ) );
                $d = $wgLang->timeanddate( $result->timestamp, true );
 
                # Since there is no diff link, we need to give users a way to
index f9a4c9b..1591b93 100644 (file)
@@ -316,7 +316,7 @@ class SpecialSearch {
        function showHit( $result, $terms ) {
                $fname = 'SpecialSearch::showHit';
                wfProfileIn( $fname );
-               global $wgUser, $wgContLang;
+               global $wgUser, $wgContLang, $wgLang;
 
                $t = $result->getTitle();
                if( is_null( $t ) ) {
@@ -333,7 +333,8 @@ class SpecialSearch {
                $link = $sk->makeKnownLinkObj( $t );
                $revision = Revision::newFromTitle( $t );
                $text = $revision->getText();
-               $size = wfMsg( 'nbytes', strlen( $text ) );
+               $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
+                       $wgLang->formatNum( strlen( $text ) ) );
 
                $lines = explode( "\n", $text );
 
index 5d3dc3a..6867b80 100644 (file)
@@ -54,7 +54,7 @@ class ShortPagesPage extends QueryPage {
 
        function formatResult( $skin, $result ) {
                global $wgLang, $wgContLang;
-               $nb = htmlspecialchars( wfMsg( 'nbytes', $wgLang->formatNum( $result->value ) ) );
+               $nb = wfMsgExt( 'nbytes', array('parsemag', 'escape'), $wgLang->formatNum( $result->value ) );
                $title = Title::makeTitle( $result->namespace, $result->title );
                $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
                $histlink = $skin->makeKnownLinkObj( $title, wfMsgHtml('hist'), 'action=history' );
index 7eb24dd..a67041a 100644 (file)
@@ -236,7 +236,7 @@ See $1.',
 'versionrequired' => 'Version $1 of MediaWiki required',
 'versionrequiredtext' => 'Version $1 of MediaWiki is required to use this page. See [[Special:Version]]',
 
-'nbytes'               => '$1 bytes',
+'nbytes'               => '$1 {{PLURAL:$1|byte|bytes}}',
 'ncategories'          => '$1 categories',
 'nrevisions'           => '$1 revisions',
 'widthheight'          => '$1x$2',
@@ -847,11 +847,11 @@ created and by whom, and anything else you may know about it. If this is an imag
 # Image list
 #
 'imagelist'            => 'File list',
-'imagelisttext'        => "Below is a list of $1 files sorted $2.",
+'imagelisttext'        => 'Below is a list of <strong>$1</strong> files sorted <strong>$2</strong>.',
 'imagelistforuser' => "This shows only images uploaded by $1.",
 'getimagelist' => 'fetching file list',
 'ilsubmit'             => 'Search',
-'showlast'             => "Show last $1 files sorted $2.",
+'showlast'             => 'Show last $1 files sorted $2.',
 'byname'               => 'by name',
 'bydate'               => 'by date',
 'bysize'               => 'by size',