MediaWiki  1.34.0
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  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 
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
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:719
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:515
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:739
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:79
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:828
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:537
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:692
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:709
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
SpecialListFiles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialListFiles.php:89
ImageListPager
Definition: ImageListPager.php:30
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:639
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:230