r85548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85547‎ | r85548 | r85549 >
Date:16:45, 6 April 2011
Author:maxsem
Status:ok
Tags:
Comment:
Made Special:ListFiles transcludable
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListfiles.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialListfiles.php
@@ -21,7 +21,7 @@
2222 * @ingroup SpecialPage
2323 */
2424
25 -class SpecialListFiles extends SpecialPage {
 25+class SpecialListFiles extends IncludableSpecialPage {
2626
2727 public function __construct(){
2828 parent::__construct( 'Listfiles' );
@@ -32,12 +32,17 @@
3333 $this->setHeaders();
3434 $this->outputHeader();
3535
36 - $pager = new ImageListPager( $par );
 36+ $pager = new ImageListPager( $par, $this->including() );
3737
38 - $limit = $pager->getForm();
39 - $body = $pager->getBody();
40 - $nav = $pager->getNavigationBar();
41 - $wgOut->addHTML( "$limit<br />\n$body<br />\n$nav" );
 38+ if ( $this->including() ) {
 39+ $html = $pager->getBody();
 40+ } else {
 41+ $limit = $pager->getForm();
 42+ $body = $pager->getBody();
 43+ $nav = $pager->getNavigationBar();
 44+ $html = "$limit<br />\n$body<br />\n$nav";
 45+ }
 46+ $wgOut->addHTML( $html );
4247 }
4348 }
4449
@@ -48,16 +53,15 @@
4954 var $mFieldNames = null;
5055 var $mQueryConds = array();
5156 var $mUserName = null;
 57+ var $mIncluding = false;
5258
53 - function __construct( $par = null ) {
 59+ function __construct( $par = null, $including = false ) {
5460 global $wgRequest, $wgMiserMode;
55 - if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
56 - $this->mDefaultDirection = true;
57 - } else {
58 - $this->mDefaultDirection = false;
59 - }
6061
61 - $userName = $wgRequest->getText( 'user', $par );
 62+ $this->mIncluding = $including;
 63+
 64+
 65+ $userName = $including ? $par : $wgRequest->getText( 'user', $par );
6266 if ( $userName ) {
6367 $nt = Title::newFromText( $userName, NS_USER );
6468 if ( !is_null( $nt ) ) {
@@ -66,14 +70,24 @@
6771 }
6872 }
6973
70 - $search = $wgRequest->getText( 'ilsearch' );
71 - if ( $search != '' && !$wgMiserMode ) {
72 - $nt = Title::newFromURL( $search );
73 - if ( $nt ) {
74 - $dbr = wfGetDB( DB_SLAVE );
75 - $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(),
76 - strtolower( $nt->getDBkey() ), $dbr->anyString() );
 74+ if ( !$including ) {
 75+ if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
 76+ $this->mDefaultDirection = true;
 77+ } else {
 78+ $this->mDefaultDirection = false;
7779 }
 80+
 81+ $search = $wgRequest->getText( 'ilsearch' );
 82+ if ( $search != '' && !$wgMiserMode ) {
 83+ $nt = Title::newFromURL( $search );
 84+ if ( $nt ) {
 85+ $dbr = wfGetDB( DB_SLAVE );
 86+ $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(),
 87+ strtolower( $nt->getDBkey() ), $dbr->anyString() );
 88+ }
 89+ }
 90+ } else {
 91+ $this->mDefaultDirection = true;
7892 }
7993
8094 parent::__construct();
@@ -101,6 +115,9 @@
102116 }
103117
104118 function isFieldSortable( $field ) {
 119+ if ( $this->mIncluding ) {
 120+ return false;
 121+ }
105122 static $sortable = array( 'img_timestamp', 'img_name' );
106123 if ( $field == 'img_size' ) {
107124 # No index for both img_size and img_user_text
Index: trunk/phase3/RELEASE-NOTES
@@ -125,6 +125,7 @@
126126 'AbortNewAccount' triggered by explicit account creations. (They are separate
127127 to avoid loops and confusion; auth plugins like CentralAuth need to handle
128128 AbortNewAccount separately.
 129+* Special:ListFiles is now transcludable.
129130
130131
131132 === Bug fixes in 1.18 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r90485Code cleanups to ListFiles including r85548aaron21:13, 20 June 2011

Status & tagging log