From 91147749b0e98e8b17622928e6fdb0981afc5c49 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 6 Apr 2011 16:45:46 +0000 Subject: [PATCH] Made Special:ListFiles transcludable --- RELEASE-NOTES | 1 + includes/specials/SpecialListfiles.php | 57 +++++++++++++++++--------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d19bbeb594..052b315bfb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -125,6 +125,7 @@ PHP if you have not done so prior to upgrading MediaWiki. 'AbortNewAccount' triggered by explicit account creations. (They are separate to avoid loops and confusion; auth plugins like CentralAuth need to handle AbortNewAccount separately. +* Special:ListFiles is now transcludable. === Bug fixes in 1.18 === diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 7879f88b0e..9bc38cdf73 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -21,7 +21,7 @@ * @ingroup SpecialPage */ -class SpecialListFiles extends SpecialPage { +class SpecialListFiles extends IncludableSpecialPage { public function __construct(){ parent::__construct( 'Listfiles' ); @@ -32,12 +32,17 @@ class SpecialListFiles extends SpecialPage { $this->setHeaders(); $this->outputHeader(); - $pager = new ImageListPager( $par ); + $pager = new ImageListPager( $par, $this->including() ); - $limit = $pager->getForm(); - $body = $pager->getBody(); - $nav = $pager->getNavigationBar(); - $wgOut->addHTML( "$limit
\n$body
\n$nav" ); + if ( $this->including() ) { + $html = $pager->getBody(); + } else { + $limit = $pager->getForm(); + $body = $pager->getBody(); + $nav = $pager->getNavigationBar(); + $html = "$limit
\n$body
\n$nav"; + } + $wgOut->addHTML( $html ); } } @@ -48,16 +53,15 @@ class ImageListPager extends TablePager { var $mFieldNames = null; var $mQueryConds = array(); var $mUserName = null; + var $mIncluding = false; - function __construct( $par = null ) { + function __construct( $par = null, $including = false ) { global $wgRequest, $wgMiserMode; - if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) { - $this->mDefaultDirection = true; - } else { - $this->mDefaultDirection = false; - } - $userName = $wgRequest->getText( 'user', $par ); + $this->mIncluding = $including; + + + $userName = $including ? $par : $wgRequest->getText( 'user', $par ); if ( $userName ) { $nt = Title::newFromText( $userName, NS_USER ); if ( !is_null( $nt ) ) { @@ -66,14 +70,24 @@ class ImageListPager extends TablePager { } } - $search = $wgRequest->getText( 'ilsearch' ); - if ( $search != '' && !$wgMiserMode ) { - $nt = Title::newFromURL( $search ); - if ( $nt ) { - $dbr = wfGetDB( DB_SLAVE ); - $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), - strtolower( $nt->getDBkey() ), $dbr->anyString() ); + if ( !$including ) { + if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) { + $this->mDefaultDirection = true; + } else { + $this->mDefaultDirection = false; + } + + $search = $wgRequest->getText( 'ilsearch' ); + if ( $search != '' && !$wgMiserMode ) { + $nt = Title::newFromURL( $search ); + if ( $nt ) { + $dbr = wfGetDB( DB_SLAVE ); + $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), + strtolower( $nt->getDBkey() ), $dbr->anyString() ); + } } + } else { + $this->mDefaultDirection = true; } parent::__construct(); @@ -101,6 +115,9 @@ class ImageListPager extends TablePager { } function isFieldSortable( $field ) { + if ( $this->mIncluding ) { + return false; + } static $sortable = array( 'img_timestamp', 'img_name' ); if ( $field == 'img_size' ) { # No index for both img_size and img_user_text -- 2.20.1