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?
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
__construct( $name='Wantedfiles')
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
static singleton()
Definition: RepoGroup.php:60
const NS_CATEGORY
Definition: Defines.php:74
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
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:618
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
msg( $key)
Wrapper around wfMessage that sets the current context.
Querypage that lists the most wanted files.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
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:320