MediaWiki  master
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 }
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
forceExistenceCheck()
KLUGE: The results may contain false positives for files that exist e.g.
const NS_MAIN
Definition: Defines.php:60
existenceCheck(Title $title)
Does the file exist?
__construct( $name='Wantedfiles')
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static singleton()
Definition: RepoGroup.php:60
const NS_CATEGORY
Definition: Defines.php:74
const NS_FILE
Definition: Defines.php:66
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
Querypage that lists the most wanted files.
likelyToHaveFalsePositives()
Whether foreign repos are likely to cause false positives.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319