MediaWiki REL1_37
SpecialListFiles.php
Go to the documentation of this file.
1<?php
27
29
31 private $repoGroup;
32
35
38
41
44
46 private $userCache;
47
56 public function __construct(
63 ) {
64 parent::__construct( 'Listfiles' );
65 $this->repoGroup = $repoGroup;
66 $this->loadBalancer = $loadBalancer;
67 $this->commentStore = $commentStore;
68 $this->userNameUtils = $userNameUtils;
69 $this->userNamePrefixSearch = $userNamePrefixSearch;
70 $this->userCache = $userCache;
71 }
72
73 public function execute( $par ) {
74 $this->setHeaders();
75 $this->outputHeader();
76 $this->addHelpLink( 'Help:Managing_files' );
77
78 if ( $this->including() ) {
79 $userName = (string)$par;
80 $search = '';
81 $showAll = false;
82 } else {
83 $userName = $this->getRequest()->getText( 'user', $par ?? '' );
84 $search = $this->getRequest()->getText( 'ilsearch', '' );
85 $showAll = $this->getRequest()->getBool( 'ilshowall', false );
86 }
87 // Sanitize usernames to avoid symbols in the title of page.
88 $sanitizedUserName = $this->userNameUtils->getCanonical( $userName, UserNameUtils::RIGOR_NONE );
89 if ( $sanitizedUserName ) {
90 $userName = $sanitizedUserName;
91 }
92
93 if ( $userName ) {
94 $pageTitle = $this->msg( 'listfiles_subpage', $userName );
95 } else {
96 $pageTitle = $this->msg( 'listfiles' );
97 }
98
99 $pager = new ImageListPager(
100 $this->getContext(),
101 $userName,
102 $search,
103 $this->including(),
104 $showAll,
105 $this->getLinkRenderer(),
106 $this->repoGroup,
107 $this->loadBalancer,
108 $this->commentStore,
109 $this->userCache,
110 $this->userNameUtils
111 );
112
113 $out = $this->getOutput();
114 $out->setPageTitle( $pageTitle );
115 $out->addModuleStyles( 'mediawiki.special' );
116 if ( $this->including() ) {
117 $out->addParserOutputContent( $pager->getBodyOutput() );
118 } else {
119 $user = $pager->getRelevantUser();
120 if ( $user ) {
121 $this->getSkin()->setRelevantUser( $user );
122 }
123 $pager->getForm();
124 $out->addParserOutputContent( $pager->getFullOutput() );
125 }
126 }
127
136 public function prefixSearchSubpages( $search, $limit, $offset ) {
137 $search = $this->userNameUtils->getCanonical( $search );
138 if ( !$search ) {
139 // No prefix suggestion for invalid user
140 return [];
141 }
142 // Autocomplete subpage as user list - public to allow caching
143 return $this->userNamePrefixSearch
144 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
145 }
146
147 protected function getGroupName() {
148 return 'media';
149 }
150}
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:33
UserNamePrefixSearch $userNamePrefixSearch
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
UserNameUtils $userNameUtils
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Default execute method Checks user permissions.
ILoadBalancer $loadBalancer
__construct(RepoGroup $repoGroup, ILoadBalancer $loadBalancer, CommentStore $commentStore, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserCache $userCache)
CommentStore $commentStore
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.
Database cluster connection, tracking, load balancing, and transaction manager interface.