MediaWiki 1.40.4
SpecialListFiles.php
Go to the documentation of this file.
1<?php
30
32
34 private $repoGroup;
35
37 private $loadBalancer;
38
40 private $commentStore;
41
43 private $userNameUtils;
44
46 private $userNamePrefixSearch;
47
49 private $userCache;
50
52 private $commentFormatter;
53
63 public function __construct(
64 RepoGroup $repoGroup,
65 ILoadBalancer $loadBalancer,
66 CommentStore $commentStore,
67 UserNameUtils $userNameUtils,
68 UserNamePrefixSearch $userNamePrefixSearch,
69 UserCache $userCache,
70 CommentFormatter $commentFormatter
71 ) {
72 parent::__construct( 'Listfiles' );
73 $this->repoGroup = $repoGroup;
74 $this->loadBalancer = $loadBalancer;
75 $this->commentStore = $commentStore;
76 $this->userNameUtils = $userNameUtils;
77 $this->userNamePrefixSearch = $userNamePrefixSearch;
78 $this->userCache = $userCache;
79 $this->commentFormatter = $commentFormatter;
80 }
81
82 public function execute( $par ) {
83 $this->setHeaders();
84 $this->outputHeader();
85 $this->addHelpLink( 'Help:Managing_files' );
86
87 if ( $this->including() ) {
88 $userName = (string)$par;
89 $search = '';
90 $showAll = false;
91 } else {
92 $userName = $this->getRequest()->getText( 'user', $par ?? '' );
93 $search = $this->getRequest()->getText( 'ilsearch', '' );
94 $showAll = $this->getRequest()->getBool( 'ilshowall', false );
95 }
96 // Sanitize usernames to avoid symbols in the title of page.
97 $sanitizedUserName = $this->userNameUtils->getCanonical( $userName, UserRigorOptions::RIGOR_NONE );
98 if ( $sanitizedUserName ) {
99 $userName = $sanitizedUserName;
100 }
101
102 if ( $userName ) {
103 $pageTitle = $this->msg( 'listfiles_subpage', $userName );
104 } else {
105 $pageTitle = $this->msg( 'listfiles' );
106 }
107
108 $pager = new ImageListPager(
109 $this->getContext(),
110 $this->commentStore,
111 $this->getLinkRenderer(),
112 $this->loadBalancer,
113 $this->repoGroup,
114 $this->userCache,
115 $this->userNameUtils,
116 $this->commentFormatter,
117 $userName,
118 $search,
119 $this->including(),
120 $showAll
121 );
122
123 $out = $this->getOutput();
124 $out->setPageTitle( $pageTitle );
125 $out->addModuleStyles( 'mediawiki.special' );
126 if ( $this->including() ) {
127 $out->addParserOutputContent( $pager->getBodyOutput() );
128 } else {
129 $user = $pager->getRelevantUser();
130 if ( $user ) {
131 $this->getSkin()->setRelevantUser( $user );
132 }
133 $pager->getForm();
134 $out->addParserOutputContent( $pager->getFullOutput() );
135 }
136 }
137
146 public function prefixSearchSubpages( $search, $limit, $offset ) {
147 $search = $this->userNameUtils->getCanonical( $search );
148 if ( !$search ) {
149 // No prefix suggestion for invalid user
150 return [];
151 }
152 // Autocomplete subpage as user list - public to allow caching
153 return $this->userNamePrefixSearch
154 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
155 }
156
157 protected function getGroupName() {
158 return 'media';
159 }
160}
Shortcut to construct an includable special page.
This is the main service interface for converting single-line comments from various DB comment fields...
Handle database storage of comments such as edit summaries and log reasons.
Handles searching prefixes of user names.
UserNameUtils service.
Prioritized list of file repositories.
Definition RepoGroup.php:30
__construct(RepoGroup $repoGroup, ILoadBalancer $loadBalancer, CommentStore $commentStore, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserCache $userCache, CommentFormatter $commentFormatter)
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.
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.
This class is a delegate to ILBFactory for a given database cluster.