Index: trunk/phase3/includes/specials/SpecialListfiles.php |
— | — | @@ -28,19 +28,27 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function execute( $par ){ |
32 | | - global $wgOut; |
| 32 | + global $wgOut, $wgRequest; |
33 | 33 | $this->setHeaders(); |
34 | 34 | $this->outputHeader(); |
35 | 35 | |
36 | | - $pager = new ImageListPager( $par, $this->including() ); |
| 36 | + if ( $this->including() ) { |
| 37 | + $userName = $par; |
| 38 | + $search = ''; |
| 39 | + } else { |
| 40 | + $userName = $wgRequest->getText( 'user', $par ); |
| 41 | + $search = $wgRequest->getText( 'ilsearch', '' ); |
| 42 | + } |
37 | 43 | |
| 44 | + $pager = new ImageListPager( $userName, $search, $this->including() ); |
| 45 | + |
38 | 46 | if ( $this->including() ) { |
39 | 47 | $html = $pager->getBody(); |
40 | 48 | } else { |
41 | | - $limit = $pager->getForm(); |
| 49 | + $form = $pager->getForm(); |
42 | 50 | $body = $pager->getBody(); |
43 | 51 | $nav = $pager->getNavigationBar(); |
44 | | - $html = "$limit<br />\n$body<br />\n$nav"; |
| 52 | + $html = "$form<br />\n$body<br />\n$nav"; |
45 | 53 | } |
46 | 54 | $wgOut->addHTML( $html ); |
47 | 55 | } |
— | — | @@ -53,15 +61,14 @@ |
54 | 62 | var $mFieldNames = null; |
55 | 63 | var $mQueryConds = array(); |
56 | 64 | var $mUserName = null; |
| 65 | + var $mSearch = ''; |
57 | 66 | var $mIncluding = false; |
58 | 67 | |
59 | | - function __construct( $par = null, $including = false ) { |
| 68 | + function __construct( $userName = null, $search = '', $including = false ) { |
60 | 69 | global $wgRequest, $wgMiserMode; |
61 | 70 | |
62 | 71 | $this->mIncluding = $including; |
63 | 72 | |
64 | | - |
65 | | - $userName = $including ? $par : $wgRequest->getText( 'user', $par ); |
66 | 73 | if ( $userName ) { |
67 | 74 | $nt = Title::newFromText( $userName, NS_USER ); |
68 | 75 | if ( !is_null( $nt ) ) { |
— | — | @@ -70,22 +77,23 @@ |
71 | 78 | } |
72 | 79 | } |
73 | 80 | |
| 81 | + if ( $search != '' && !$wgMiserMode ) { |
| 82 | + $this->mSearch = $search; |
| 83 | + $nt = Title::newFromURL( $this->mSearch ); |
| 84 | + if ( $nt ) { |
| 85 | + $dbr = wfGetDB( DB_SLAVE ); |
| 86 | + $this->mQueryConds[] = 'LOWER(img_name)' . |
| 87 | + $dbr->buildLike( $dbr->anyString(), |
| 88 | + strtolower( $nt->getDBkey() ), $dbr->anyString() ); |
| 89 | + } |
| 90 | + } |
| 91 | + |
74 | 92 | if ( !$including ) { |
75 | 93 | if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) { |
76 | 94 | $this->mDefaultDirection = true; |
77 | 95 | } else { |
78 | 96 | $this->mDefaultDirection = false; |
79 | 97 | } |
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 | 98 | } else { |
91 | 99 | $this->mDefaultDirection = true; |
92 | 100 | } |
— | — | @@ -149,7 +157,8 @@ |
150 | 158 | if( $dbr->implicitGroupby() ) { |
151 | 159 | $options = array( 'GROUP BY' => 'img_name' ); |
152 | 160 | } else { |
153 | | - $columnlist = implode( ',', preg_grep( '/^img/', array_keys( $this->getFieldNames() ) ) ); |
| 161 | + $columnlist = implode( ',', |
| 162 | + preg_grep( '/^img/', array_keys( $this->getFieldNames() ) ) ); |
154 | 163 | $options = array( 'GROUP BY' => "img_user, $columnlist" ); |
155 | 164 | } |
156 | 165 | $join_conds = array( 'oldimage' => array( 'LEFT JOIN', 'oi_name = img_name' ) ); |
— | — | @@ -228,29 +237,29 @@ |
229 | 238 | } |
230 | 239 | |
231 | 240 | function getForm() { |
232 | | - global $wgRequest, $wgScript, $wgMiserMode; |
233 | | - $search = $wgRequest->getText( 'ilsearch' ); |
| 241 | + global $wgScript, $wgMiserMode; |
234 | 242 | $inputForm = array(); |
235 | 243 | $inputForm['table_pager_limit_label'] = $this->getLimitSelect(); |
236 | 244 | if ( !$wgMiserMode ) { |
237 | | - $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $search, 'text', array( |
238 | | - 'size' => '40', |
239 | | - 'maxlength' => '255', |
240 | | - 'id' => 'mw-ilsearch', |
| 245 | + $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text', |
| 246 | + array( |
| 247 | + 'size' => '40', |
| 248 | + 'maxlength' => '255', |
| 249 | + 'id' => 'mw-ilsearch', |
241 | 250 | ) ); |
242 | 251 | } |
243 | 252 | $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array( |
244 | | - 'size' => '40', |
245 | | - 'maxlength' => '255', |
246 | | - 'id' => 'mw-listfiles-user', |
| 253 | + 'size' => '40', |
| 254 | + 'maxlength' => '255', |
| 255 | + 'id' => 'mw-listfiles-user', |
247 | 256 | ) ); |
248 | | - $s = Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) . |
| 257 | + return Html::openElement( 'form', |
| 258 | + array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) . |
249 | 259 | Xml::fieldset( wfMsg( 'listfiles' ) ) . |
250 | 260 | Xml::buildForm( $inputForm, 'table_pager_limit_submit' ) . |
251 | 261 | $this->getHiddenFields( array( 'limit', 'ilsearch', 'user' ) ) . |
252 | 262 | Html::closeElement( 'fieldset' ) . |
253 | 263 | Html::closeElement( 'form' ) . "\n"; |
254 | | - return $s; |
255 | 264 | } |
256 | 265 | |
257 | 266 | function getTableClass() { |
— | — | @@ -278,9 +287,7 @@ |
279 | 288 | |
280 | 289 | function getDefaultQuery() { |
281 | 290 | $queries = parent::getDefaultQuery(); |
282 | | - if ( !isset( $queries['user'] ) |
283 | | - && !is_null( $this->mUserName ) ) |
284 | | - { |
| 291 | + if ( !isset( $queries['user'] ) && !is_null( $this->mUserName ) ) { |
285 | 292 | $queries['user'] = $this->mUserName; |
286 | 293 | } |
287 | 294 | return $queries; |