MediaWiki REL1_41
SpecialListFiles.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
33use RepoGroup;
34use UserCache;
36
38
39 private RepoGroup $repoGroup;
40 private IConnectionProvider $dbProvider;
41 private CommentStore $commentStore;
42 private UserNameUtils $userNameUtils;
43 private UserNamePrefixSearch $userNamePrefixSearch;
44 private UserCache $userCache;
45 private CommentFormatter $commentFormatter;
46
56 public function __construct(
57 RepoGroup $repoGroup,
58 IConnectionProvider $dbProvider,
59 CommentStore $commentStore,
60 UserNameUtils $userNameUtils,
61 UserNamePrefixSearch $userNamePrefixSearch,
62 UserCache $userCache,
63 CommentFormatter $commentFormatter
64 ) {
65 parent::__construct( 'Listfiles' );
66 $this->repoGroup = $repoGroup;
67 $this->dbProvider = $dbProvider;
68 $this->commentStore = $commentStore;
69 $this->userNameUtils = $userNameUtils;
70 $this->userNamePrefixSearch = $userNamePrefixSearch;
71 $this->userCache = $userCache;
72 $this->commentFormatter = $commentFormatter;
73 }
74
75 public function execute( $par ) {
76 $this->setHeaders();
77 $this->outputHeader();
78 $this->addHelpLink( 'Help:Managing_files' );
79
80 if ( $this->including() ) {
81 $userName = (string)$par;
82 $search = '';
83 $showAll = false;
84 } else {
85 $userName = $this->getRequest()->getText( 'user', $par ?? '' );
86 $search = $this->getRequest()->getText( 'ilsearch', '' );
87 $showAll = $this->getRequest()->getBool( 'ilshowall', false );
88 }
89 // Sanitize usernames to avoid symbols in the title of page.
90 $sanitizedUserName = $this->userNameUtils->getCanonical( $userName, UserRigorOptions::RIGOR_NONE );
91 if ( $sanitizedUserName ) {
92 $userName = $sanitizedUserName;
93 }
94
95 if ( $userName ) {
96 $pageTitle = $this->msg( 'listfiles_subpage' )->plaintextParams( $userName );
97 } else {
98 $pageTitle = $this->msg( 'listfiles' );
99 }
100
101 $pager = new ImageListPager(
102 $this->getContext(),
103 $this->commentStore,
104 $this->getLinkRenderer(),
105 $this->dbProvider,
106 $this->repoGroup,
107 $this->userCache,
108 $this->userNameUtils,
109 $this->commentFormatter,
110 $userName,
111 $search,
112 $this->including(),
113 $showAll
114 );
115
116 $out = $this->getOutput();
117 $out->setPageTitleMsg( $pageTitle );
118 $out->addModuleStyles( 'mediawiki.special' );
119 if ( $this->including() ) {
120 $out->addParserOutputContent( $pager->getBodyOutput() );
121 } else {
122 $user = $pager->getRelevantUser();
123 if ( $user ) {
124 $this->getSkin()->setRelevantUser( $user );
125 }
126 $pager->getForm();
127 $out->addParserOutputContent( $pager->getFullOutput() );
128 }
129 }
130
139 public function prefixSearchSubpages( $search, $limit, $offset ) {
140 $search = $this->userNameUtils->getCanonical( $search );
141 if ( !$search ) {
142 // No prefix suggestion for invalid user
143 return [];
144 }
145 // Autocomplete subpage as user list - public to allow caching
146 return $this->userNamePrefixSearch
147 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
148 }
149
150 protected function getGroupName() {
151 return 'media';
152 }
153}
154
158class_alias( SpecialListFiles::class, 'SpecialListFiles' );
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.
Shortcut to construct an includable special page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getSkin()
Shortcut to get the skin being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
getRequest()
Get the WebRequest being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
including( $x=null)
Whether the special page is being evaluated via transclusion.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
__construct(RepoGroup $repoGroup, IConnectionProvider $dbProvider, CommentStore $commentStore, UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserCache $userCache, CommentFormatter $commentFormatter)
execute( $par)
Default execute method Checks user permissions.
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...
Handles searching prefixes of user names.
UserNameUtils service.
Prioritized list of file repositories.
Definition RepoGroup.php:30
Shared interface for rigor levels when dealing with User methods.
Provide primary and replica IDatabase connections.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...