Do not insert page titles into querycache.qc_value
[lhc/web/wiklou.git] / includes / specials / SpecialListFiles.php
1 <?php
2 /**
3 * Implements Special:Listfiles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 class SpecialListFiles extends IncludableSpecialPage {
25 public function __construct() {
26 parent::__construct( 'Listfiles' );
27 }
28
29 public function execute( $par ) {
30 $this->setHeaders();
31 $this->outputHeader();
32 $this->addHelpLink( 'Help:Managing_files' );
33
34 if ( $this->including() ) {
35 $userName = $par;
36 $search = '';
37 $showAll = false;
38 } else {
39 $userName = $this->getRequest()->getText( 'user', $par );
40 $search = $this->getRequest()->getText( 'ilsearch', '' );
41 $showAll = $this->getRequest()->getBool( 'ilshowall', false );
42 }
43 if ( $userName ) {
44 $pageTitle = $this->msg( 'listfiles_subpage', $userName );
45 } else {
46 $pageTitle = $this->msg( 'listfiles' );
47 }
48
49 $pager = new ImageListPager(
50 $this->getContext(),
51 $userName,
52 $search,
53 $this->including(),
54 $showAll,
55 $this->getLinkRenderer()
56 );
57
58 $out = $this->getOutput();
59 $out->setPageTitle( $pageTitle );
60 $out->addModuleStyles( 'mediawiki.special' );
61 if ( $this->including() ) {
62 $out->addParserOutputContent( $pager->getBodyOutput() );
63 } else {
64 $user = $pager->getRelevantUser();
65 $this->getSkin()->setRelevantUser( $user );
66 $pager->getForm();
67 $out->addParserOutputContent( $pager->getFullOutput() );
68 }
69 }
70
71 /**
72 * Return an array of subpages beginning with $search that this special page will accept.
73 *
74 * @param string $search Prefix to search for
75 * @param int $limit Maximum number of results to return (usually 10)
76 * @param int $offset Number of results to skip (usually 0)
77 * @return string[] Matching subpages
78 */
79 public function prefixSearchSubpages( $search, $limit, $offset ) {
80 $user = User::newFromName( $search );
81 if ( !$user ) {
82 // No prefix suggestion for invalid user
83 return [];
84 }
85 // Autocomplete subpage as user list - public to allow caching
86 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
87 }
88
89 protected function getGroupName() {
90 return 'media';
91 }
92 }