MediaWiki REL1_39
SpecialListFiles.php
Go to the documentation of this file.
1<?php
28
30
32 private $repoGroup;
33
35 private $loadBalancer;
36
38 private $commentStore;
39
41 private $userNameUtils;
42
44 private $userNamePrefixSearch;
45
47 private $userCache;
48
57 public function __construct(
58 RepoGroup $repoGroup,
59 ILoadBalancer $loadBalancer,
60 CommentStore $commentStore,
61 UserNameUtils $userNameUtils,
62 UserNamePrefixSearch $userNamePrefixSearch,
63 UserCache $userCache
64 ) {
65 parent::__construct( 'Listfiles' );
66 $this->repoGroup = $repoGroup;
67 $this->loadBalancer = $loadBalancer;
68 $this->commentStore = $commentStore;
69 $this->userNameUtils = $userNameUtils;
70 $this->userNamePrefixSearch = $userNamePrefixSearch;
71 $this->userCache = $userCache;
72 }
73
74 public function execute( $par ) {
75 $this->setHeaders();
76 $this->outputHeader();
77 $this->addHelpLink( 'Help:Managing_files' );
78
79 if ( $this->including() ) {
80 $userName = (string)$par;
81 $search = '';
82 $showAll = false;
83 } else {
84 $userName = $this->getRequest()->getText( 'user', $par ?? '' );
85 $search = $this->getRequest()->getText( 'ilsearch', '' );
86 $showAll = $this->getRequest()->getBool( 'ilshowall', false );
87 }
88 // Sanitize usernames to avoid symbols in the title of page.
89 $sanitizedUserName = $this->userNameUtils->getCanonical( $userName, UserRigorOptions::RIGOR_NONE );
90 if ( $sanitizedUserName ) {
91 $userName = $sanitizedUserName;
92 }
93
94 if ( $userName ) {
95 $pageTitle = $this->msg( 'listfiles_subpage', $userName );
96 } else {
97 $pageTitle = $this->msg( 'listfiles' );
98 }
99
100 $pager = new ImageListPager(
101 $this->getContext(),
102 $this->commentStore,
103 $this->getLinkRenderer(),
104 $this->loadBalancer,
105 $this->repoGroup,
106 $this->userCache,
107 $this->userNameUtils,
108 $userName,
109 $search,
110 $this->including(),
111 $showAll
112 );
113
114 $out = $this->getOutput();
115 $out->setPageTitle( $pageTitle );
116 $out->addModuleStyles( 'mediawiki.special' );
117 if ( $this->including() ) {
118 $out->addParserOutputContent( $pager->getBodyOutput() );
119 } else {
120 $user = $pager->getRelevantUser();
121 if ( $user ) {
122 $this->getSkin()->setRelevantUser( $user );
123 }
124 $pager->getForm();
125 $out->addParserOutputContent( $pager->getFullOutput() );
126 }
127 }
128
137 public function prefixSearchSubpages( $search, $limit, $offset ) {
138 $search = $this->userNameUtils->getCanonical( $search );
139 if ( !$search ) {
140 // No prefix suggestion for invalid user
141 return [];
142 }
143 // Autocomplete subpage as user list - public to allow caching
144 return $this->userNamePrefixSearch
145 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
146 }
147
148 protected function getGroupName() {
149 return 'media';
150 }
151}
Handle database storage of comments such as edit summaries and log reasons.
Shortcut to construct an includable special page.
Handles searching prefixes of user names.
UserNameUtils service.
Prioritized list of file repositories.
Definition RepoGroup.php:29
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Default execute method Checks user permissions.
__construct(RepoGroup $repoGroup, ILoadBalancer $loadBalancer, CommentStore $commentStore, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserCache $userCache)
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getSkin()
Shortcut to get the skin being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
including( $x=null)
Whether the special page is being evaluated via transclusion.
Shared interface for rigor levels when dealing with User methods.
Create and track the database connections and transactions for a given database cluster.