* (bug 3358) Allow inclusion of Special:Newimages as {{Special:Newimages[/int]}}
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 8 Sep 2005 14:15:28 +0000 (14:15 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Thu, 8 Sep 2005 14:15:28 +0000 (14:15 +0000)
  where int is the number of images to show

includes/SpecialNewimages.php
includes/SpecialPage.php

index 8d42f4a..5d47ca9 100644 (file)
@@ -11,13 +11,14 @@ require_once( 'ImageGallery.php' );
 /**
  *
  */
-function wfSpecialNewimages() {
+function wfSpecialNewimages( $par, $specialPage ) {
        global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest,
               $wgGroupPermissions;
 
        $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
        $dbr =& wfGetDB( DB_SLAVE );
        $sk = $wgUser->getSkin();
+       $shownav = !$specialPage->including();
        $hidebots = $wgRequest->getBool('hidebots',1);
 
        if($hidebots) {
@@ -66,6 +67,10 @@ function wfSpecialNewimages() {
        /** Hardcode this for now. */
        $limit = 48;
 
+       if ( $parval = intval( $par ) )
+               if ( $parval <= $limit && $parval > 0 )
+                       $limit = $parval;
+
        $where = array();
        if ( $wpIlMatch != '' ) {
                $nt = Title::newFromUrl( $wpIlMatch );
@@ -141,9 +146,10 @@ function wfSpecialNewimages() {
 
        $bydate = wfMsg( 'bydate' );
        $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
-       $text = wfMsg( "imagelisttext",
-               "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
-       $wgOut->addHTML( "<p>{$text}\n</p>" );
+       if ($shownav) {
+               $text = wfMsg( 'imagelisttext', "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
+               $wgOut->addHTML( "<p>{$text}\n</p>" );
+       }
 
        $sub = wfMsg( 'ilsubmit' );
        $titleObj = Title::makeTitle( NS_SPECIAL, 'Newimages' );
@@ -151,11 +157,13 @@ function wfSpecialNewimages() {
        if(!$hidebots) {
                $action.='&hidebots=0';
        }
-       $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>" );
+       if ($shownav) {
+               $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>" );
+       }
        $here = $wgContLang->specialPage( 'Newimages' );
 
        /**
@@ -186,11 +194,13 @@ function wfSpecialNewimages() {
 
        $prevnext = '<p>' . $botLink . ' '. wfMsg( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'</p>';
 
-       $wgOut->addHTML( $prevnext );
+       if ($shownav)
+               $wgOut->addHTML( $prevnext );
 
        if( count( $images ) ) {
                $wgOut->addHTML( $gallery->toHTML() );
-               $wgOut->addHTML( $prevnext );
+               if ($shownav)
+                       $wgOut->addHTML( $prevnext );
        } else {
                $wgOut->addWikiText( wfMsg( 'noimages' ) );
        }
index 5bc4e51..cea0c5e 100644 (file)
@@ -32,7 +32,7 @@ $wgSpecialPages = array(
        'Recentchanges'     => new IncludableSpecialPage( 'Recentchanges' ),
        'Upload'            => new SpecialPage( 'Upload' ),
        'Imagelist'         => new SpecialPage( 'Imagelist' ),
-       'Newimages'         => new SpecialPage( 'Newimages' ),
+       'Newimages'         => new IncludableSpecialPage( 'Newimages' ),
        'Listusers'         => new SpecialPage( 'Listusers' ),
        'Statistics'        => new SpecialPage( 'Statistics' ),
        'Random'        => new SpecialPage( 'Randompage' ),