MediaWiki  master
SpecialListFiles.php
Go to the documentation of this file.
1 <?php
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  // Sanitize usernames to avoid symbols in the title of page.
44  $sanitizedUserName = User::getCanonicalName( $userName, false );
45  if ( $sanitizedUserName ) {
46  $userName = $sanitizedUserName;
47  }
48 
49  if ( $userName ) {
50  $pageTitle = $this->msg( 'listfiles_subpage', $userName );
51  } else {
52  $pageTitle = $this->msg( 'listfiles' );
53  }
54 
55  $pager = new ImageListPager(
56  $this->getContext(),
57  $userName,
58  $search,
59  $this->including(),
60  $showAll,
61  $this->getLinkRenderer()
62  );
63 
64  $out = $this->getOutput();
65  $out->setPageTitle( $pageTitle );
66  $out->addModuleStyles( 'mediawiki.special' );
67  if ( $this->including() ) {
68  $out->addParserOutputContent( $pager->getBodyOutput() );
69  } else {
70  $user = $pager->getRelevantUser();
71  $this->getSkin()->setRelevantUser( $user );
72  $pager->getForm();
73  $out->addParserOutputContent( $pager->getFullOutput() );
74  }
75  }
76 
85  public function prefixSearchSubpages( $search, $limit, $offset ) {
86  $user = User::newFromName( $search );
87  if ( !$user ) {
88  // No prefix suggestion for invalid user
89  return [];
90  }
91  // Autocomplete subpage as user list - public to allow caching
92  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
93  }
94 
95  protected function getGroupName() {
96  return 'media';
97  }
98 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
SpecialListFiles\__construct
__construct()
Definition: SpecialListFiles.php:25
SpecialListFiles\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialListFiles.php:29
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:744
UserNamePrefixSearch\search
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
Definition: UserNamePrefixSearch.php:41
SpecialListFiles
Definition: SpecialListFiles.php:24
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:538
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:764
IncludableSpecialPage
Shortcut to construct an includable special page.
Definition: IncludableSpecialPage.php:29
SpecialListFiles\prefixSearchSubpages
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Definition: SpecialListFiles.php:85
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:864
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!...
Definition: SpecialPage.php:571
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:734
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialListFiles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialListFiles.php:95
ImageListPager
Definition: ImageListPager.php:30
User\getCanonicalName
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition: User.php:1127
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:662
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:251