Follow-up to r65013: Preserve username when clicking navigation links.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 14 Apr 2010 16:15:14 +0000 (16:15 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 14 Apr 2010 16:15:14 +0000 (16:15 +0000)
includes/specials/SpecialListfiles.php

index 227adaa..09e61e7 100644 (file)
@@ -24,6 +24,7 @@ function wfSpecialListfiles( $par = null ) {
 class ImageListPager extends TablePager {
        var $mFieldNames = null;
        var $mQueryConds = array();
+       var $mUserName = null;
        
        function __construct( $par = null ) {
                global $wgRequest, $wgMiserMode;
@@ -37,14 +38,15 @@ class ImageListPager extends TablePager {
                if ( $userName ) {
                        $nt = Title::newFromText( $userName, NS_USER );
                        if ( !is_null( $nt ) ) {
-                               $this->mQueryConds['img_user_text'] = $nt->getText();
+                               $this->mUserName = $nt->getText();
+                               $this->mQueryConds['img_user_text'] = $this->mUserName;
                        }
                } 
                
                $search = $wgRequest->getText( 'ilsearch' );
                if ( $search != '' && !$wgMiserMode ) {
                        $nt = Title::newFromURL( $search );
-                       if( $nt ) {
+                       if ( $nt ) {
                                $dbr = wfGetDB( DB_SLAVE );
                                $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), 
                                        strtolower( $nt->getDBkey() ), $dbr->anyString() );
@@ -200,4 +202,15 @@ class ImageListPager extends TablePager {
        function getSortHeaderClass() {
                return 'listfiles_sort ' . parent::getSortHeaderClass();
        }
+       
+       function getPagingQueries() {
+               $queries = parent::getPagingQueries();
+               if ( !is_null( $this->mUserName ) ) {
+                       # Append the username to the query string
+                       foreach ( $queries as $key => &$query ) {
+                               $query['username'] = $this->mUserName;
+                       }
+               }
+               return $queries;
+       }
 }