From 63fcc1911bc1245381a5b84ca21d3632ff244434 Mon Sep 17 00:00:00 2001 From: Greg Maxwell Date: Fri, 2 Nov 2007 03:53:51 +0000 Subject: [PATCH] *Proper handling of default/current settings in link URLs. --- includes/SpecialNewpages.php | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index eb9cb4d5e7..17f3974da8 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -11,15 +11,17 @@ class NewPagesPage extends QueryPage { var $namespace; - var $username = ''; + var $username; var $hideliu; var $hidepatrolled; - - function NewPagesPage( $namespace = NS_MAIN, $username = '', $hideliu = false, $hidepatrolled = false ) { + var $defaults; + + function NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults) { $this->namespace = $namespace; $this->username = $username; $this->hideliu = $hideliu; $this->hidepatrolled = $hidepatrolled; + $this->defaults = $defaults; } function getName() { @@ -156,6 +158,15 @@ class NewPagesPage extends QueryPage { // show/hide links $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' )); + + $nondefaults = array(); + wfAppendToArrayIfNotDefault( 'hidepatrolled', $this->hidepatrolled, $this->defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'hideliu', $this->hideliu, $this->defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'namespace', $this->namespace, $this->defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'limit', $this->limit , $this->defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'offset', $this->offset , $this->defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'username', $this->username , $this->defaults, $nondefaults); + $liuLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ), htmlspecialchars( $showhide[1-$this->hideliu] ), wfArrayToCGI( array( 'hideliu' => 1-$this->hideliu ), $nondefaults ) ); $patrLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ), @@ -215,11 +226,19 @@ class NewPagesPage extends QueryPage { function wfSpecialNewpages($par, $specialPage) { global $wgRequest, $wgContLang; + list( $limit, $offset ) = wfCheckLimits(); - $namespace = NS_MAIN; - $username = ''; - $hideliu = false; - $hidepatrolled = false; + + $defaults = array( + /* bool */ 'hideliu' => false, + /* bool */ 'hidepatrolled' => false, + /* text */ 'namespace' => NS_MAIN, + /* text */ 'username' => '', + /* int */ 'offset' => $offset, + /* int */ 'limit' => $limit, + ); + + extract($defaults); if ( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); @@ -260,7 +279,7 @@ function wfSpecialNewpages($par, $specialPage) { if ( ! isset( $shownavigation ) ) $shownavigation = ! $specialPage->including(); - $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled ); + $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults ); if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) ) $npp->doQuery( $offset, $limit, $shownavigation ); -- 2.20.1