MediaWiki REL1_35
SpecialWantedfiles.php
Go to the documentation of this file.
1<?php
28
35
36 public function __construct( $name = 'Wantedfiles' ) {
37 parent::__construct( $name );
38 }
39
40 protected function getPageHeader() {
41 # Specifically setting to use "Wanted Files" (NS_MAIN) as title, so as to get what
42 # category would be used on main namespace pages, for those tricky wikipedia
43 # admins who like to do {{#ifeq:{{NAMESPACE}}|foo|bar|....}}.
44 $catMessage = $this->msg( 'broken-file-category' )
45 ->title( Title::newFromText( "Wanted Files", NS_MAIN ) )
46 ->inContentLanguage();
47
48 if ( !$catMessage->isDisabled() ) {
49 $category = Title::makeTitleSafe( NS_CATEGORY, $catMessage->text() );
50 } else {
51 $category = false;
52 }
53
54 $noForeign = '';
55 if ( !$this->likelyToHaveFalsePositives() ) {
56 // Additional messages for grep:
57 // wantedfiletext-cat-noforeign, wantedfiletext-nocat-noforeign
58 $noForeign = '-noforeign';
59 }
60
61 if ( $category ) {
62 return $this
63 ->msg( 'wantedfiletext-cat' . $noForeign )
64 ->params( $category->getFullText() )
65 ->parseAsBlock();
66 } else {
67 return $this
68 ->msg( 'wantedfiletext-nocat' . $noForeign )
69 ->parseAsBlock();
70 }
71 }
72
81 protected function likelyToHaveFalsePositives() {
82 return MediaWikiServices::getInstance()->getRepoGroup()->hasForeignRepos();
83 }
84
95 protected function forceExistenceCheck() {
96 return true;
97 }
98
108 protected function existenceCheck( Title $title ) {
109 return (bool)MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
110 }
111
112 public function getQueryInfo() {
113 return [
114 'tables' => [
115 'imagelinks',
116 'page',
117 'redirect',
118 'img1' => 'image',
119 'img2' => 'image',
120 ],
121 'fields' => [
122 'namespace' => NS_FILE,
123 'title' => 'il_to',
124 'value' => 'COUNT(*)'
125 ],
126 'conds' => [
127 'img1.img_name' => null,
128 // We also need to exclude file redirects
129 'img2.img_name' => null,
130 ],
131 'options' => [ 'GROUP BY' => 'il_to' ],
132 'join_conds' => [
133 'img1' => [ 'LEFT JOIN',
134 'il_to = img1.img_name'
135 ],
136 'page' => [ 'LEFT JOIN', [
137 'il_to = page_title',
138 'page_namespace' => NS_FILE,
139 ] ],
140 'redirect' => [ 'LEFT JOIN', [
141 'page_id = rd_from',
142 'rd_namespace' => NS_FILE,
143 'rd_interwiki' => ''
144 ] ],
145 'img2' => [ 'LEFT JOIN',
146 'rd_title = img2.img_name'
147 ]
148 ]
149 ];
150 }
151
152 protected function getGroupName() {
153 return 'maintenance';
154 }
155}
MediaWikiServices is the service locator for the application scope of MediaWiki.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Represents a title within MediaWiki.
Definition Title.php:42
Querypage that lists the most wanted files.
__construct( $name='Wantedfiles')
existenceCheck(Title $title)
Does the file exist?
getPageHeader()
The content returned by this function will be output before any result.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
likelyToHaveFalsePositives()
Whether foreign repos are likely to cause false positives.
forceExistenceCheck()
KLUGE: The results may contain false positives for files that exist e.g.
Class definition for a wanted query page like WantedPages, WantedTemplates, etc Stable to extend.
const NS_FILE
Definition Defines.php:76
const NS_MAIN
Definition Defines.php:70
const NS_CATEGORY
Definition Defines.php:84