75 parent::__construct(
'FileDuplicateSearch' );
88 return $this->repoGroup->findBySha1( $this->hash );
96 $html[] =
"<ol class='special'>";
98 foreach ( $dupes as $dupe ) {
100 $html[] =
"<li>" .
$line .
"</li>";
104 $this->
getOutput()->addHTML( implode(
"\n", $html ) );
111 $this->filename = $par ?? $this->
getRequest()->getText(
'filename' );
116 $this->file = $this->repoGroup->findFile(
$title );
121 # Create the input form
125 'name' =>
'filename',
126 'label-message' =>
'fileduplicatesearch-filename',
135 $htmlForm = HTMLForm::factory(
'ooui', $formFields, $this->
getContext() );
136 $htmlForm->addHiddenFields( $hiddenFields );
138 $htmlForm->setMethod(
'get' );
139 $htmlForm->setSubmitTextMsg( $this->
msg(
'fileduplicatesearch-submit' ) );
143 $htmlForm->prepareForm()->displayForm(
false );
146 $this->hash = $this->file->getSha1();
147 } elseif ( $this->filename !==
'' ) {
149 "<p class='mw-fileduplicatesearch-noresults'>\n$1\n</p>",
154 if ( $this->hash !=
'' ) {
155 # Show a thumbnail of the file
158 $thumb = $img->
transform( [
'width' => 120,
'height' => 120 ] );
160 $out->addModuleStyles(
'mediawiki.special' );
161 $out->addHTML(
'<div id="mw-fileduplicatesearch-icon">' .
162 $thumb->toHtml( [
'desc-link' =>
false ] ) .
'<br />' .
163 $this->msg(
'fileduplicatesearch-info' )->numParams(
164 $img->getWidth(), $img->getHeight() )->params(
165 $this->getLanguage()->formatSize( $img->getSize() ),
166 $img->getMimeType() )->parseAsBlock() .
172 $numRows = count( $dupes );
174 # Show a short summary
175 if ( $numRows == 1 ) {
177 "<p class='mw-fileduplicatesearch-result-1'>\n$1\n</p>",
180 } elseif ( $numRows ) {
182 "<p class='mw-fileduplicatesearch-result-n'>\n$1\n</p>",
197 $batch = $this->linkBatchFactory->newLinkBatch();
198 foreach ( $list as
$file ) {
203 $batch->add(
NS_USER, $uploader->getName() );
218 $nt = $result->getTitle();
219 $text = $this->languageConverter->convert( $nt->getText() );
225 $uploader = $result->getUploader( File::FOR_THIS_USER, $this->
getAuthority() );
226 if ( $result->isLocal() && $uploader ) {
228 $user .=
'<span style="white-space: nowrap;">';
231 } elseif ( $uploader ) {
232 $user = htmlspecialchars( $uploader->getName() );
234 $user =
'<span class="history-deleted">'
235 . $this->
msg(
'rev-deleted-user' )->escaped() .
'</span>';
238 $time = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
239 $result->getTimestamp(), $this->getUser() ) );
241 return "$plink . . $user . . $time";
258 $searchEngine = $this->searchEngineFactory->create();
259 $searchEngine->setLimitOffset( $limit, $offset );
261 $searchEngine->setNamespaces( [
NS_FILE ] );
262 $result = $searchEngine->defaultPrefixSearch( $search );
264 return array_map(
static function (
Title $t ) {
266 return $t->getText();
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Implements some public methods and some protected utility functions which are required by multiple ch...
isLocal()
Returns true if the file comes from the local file repository.
getUploader(int $audience=self::FOR_PUBLIC, Authority $performer=null)
Get the identity of the file uploader.
getTitle()
Return the associated title object.
transform( $params, $flags=0)
Transform a media file.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
Prioritized list of file repositories.
Factory class for SearchEngine.
Searches the database for files of the requested hash, comparing this with the 'img_sha1' field in th...
string $hash
The form input hash.
SearchEngineFactory $searchEngineFactory
getDupes()
Fetch dupes from all connected file repositories.
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(LinkBatchFactory $linkBatchFactory, RepoGroup $repoGroup, SearchEngineFactory $searchEngineFactory, LanguageConverterFactory $languageConverterFactory)
string $filename
The form input filename.
LinkBatchFactory $linkBatchFactory
File $file
selected reference file, if present
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
ILanguageConverter $languageConverter
Parent class for all special pages.
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.
getContext()
Gets the context this SpecialPage is executed in.
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
getContentLanguage()
Shortcut to get content language.
Represents a title within MediaWiki.
The shared interface for all language converters.