MediaWiki  1.34.0
SpecialWantedfiles.php
Go to the documentation of this file.
1 <?php
28 
35 
36  function __construct( $name = 'Wantedfiles' ) {
37  parent::__construct( $name );
38  }
39 
40  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 RepoGroup::singleton()->hasForeignRepos();
83  }
84 
95  function forceExistenceCheck() {
96  return true;
97  }
98 
108  protected function existenceCheck( Title $title ) {
109  return (bool)MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
110  }
111 
112  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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:316
WantedFilesPage\__construct
__construct( $name='Wantedfiles')
Definition: SpecialWantedfiles.php:36
RepoGroup\singleton
static singleton()
Definition: RepoGroup.php:60
WantedFilesPage\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialWantedfiles.php:40
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
WantedFilesPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialWantedfiles.php:152
WantedFilesPage\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialWantedfiles.php:112
NS_FILE
const NS_FILE
Definition: Defines.php:66
NS_MAIN
const NS_MAIN
Definition: Defines.php:60
WantedFilesPage\likelyToHaveFalsePositives
likelyToHaveFalsePositives()
Whether foreign repos are likely to cause false positives.
Definition: SpecialWantedfiles.php:81
$title
$title
Definition: testCompression.php:34
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:74
WantedFilesPage\forceExistenceCheck
forceExistenceCheck()
KLUGE: The results may contain false positives for files that exist e.g.
Definition: SpecialWantedfiles.php:95
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:613
WantedFilesPage\existenceCheck
existenceCheck(Title $title)
Does the file exist?
Definition: SpecialWantedfiles.php:108
Title
Represents a title within MediaWiki.
Definition: Title.php:42
WantedFilesPage
Querypage that lists the most wanted files.
Definition: SpecialWantedfiles.php:34
WantedQueryPage
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
Definition: WantedQueryPage.php:32