MediaWiki  REL1_24
SpecialWantedfiles.php
Go to the documentation of this file.
00001 <?php
00032 class WantedFilesPage extends WantedQueryPage {
00033 
00034     function __construct( $name = 'Wantedfiles' ) {
00035         parent::__construct( $name );
00036     }
00037 
00038     function getPageHeader() {
00039         # Specifically setting to use "Wanted Files" (NS_MAIN) as title, so as to get what
00040         # category would be used on main namespace pages, for those tricky wikipedia
00041         # admins who like to do {{#ifeq:{{NAMESPACE}}|foo|bar|....}}.
00042         $catMessage = $this->msg( 'broken-file-category' )
00043             ->title( Title::newFromText( "Wanted Files", NS_MAIN ) )
00044             ->inContentLanguage();
00045 
00046         if ( !$catMessage->isDisabled() ) {
00047             $category = Title::makeTitleSafe( NS_CATEGORY, $catMessage->text() );
00048         } else {
00049             $category = false;
00050         }
00051 
00052         $noForeign = '';
00053         if ( !$this->likelyToHaveFalsePositives() ) {
00054             // Additional messages for grep:
00055             // wantedfiletext-cat-noforeign, wantedfiletext-nocat
00056             $noForeign = '-noforeign';
00057         }
00058 
00059         if ( $category ) {
00060             return $this
00061                 ->msg( 'wantedfiletext-cat' . $noForeign )
00062                 ->params( $category->getFullText() )
00063                 ->parseAsBlock();
00064         } else {
00065             return $this
00066                 ->msg( 'wantedfiletext-nocat' . $noForeign )
00067                 ->parseAsBlock();
00068         }
00069     }
00070 
00078     protected function likelyToHaveFalsePositives() {
00079         return RepoGroup::singleton()->hasForeignRepos();
00080     }
00081 
00092     function forceExistenceCheck() {
00093         return true;
00094     }
00095 
00104     protected function existenceCheck( Title $title ) {
00105         return (bool) wfFindFile( $title );
00106     }
00107 
00108     function getQueryInfo() {
00109         return array(
00110             'tables' => array(
00111                 'imagelinks',
00112                 'page',
00113                 'redirect',
00114                 'img1' => 'image',
00115                 'img2' => 'image',
00116             ),
00117             'fields' => array(
00118                 'namespace' => NS_FILE,
00119                 'title' => 'il_to',
00120                 'value' => 'COUNT(*)'
00121             ),
00122             'conds' => array(
00123                 'img1.img_name' => null,
00124                 // We also need to exclude file redirects
00125                 'img2.img_name' => null,
00126             ),
00127             'options' => array( 'GROUP BY' => 'il_to' ),
00128             'join_conds' => array(
00129                 'img1' => array( 'LEFT JOIN',
00130                     'il_to = img1.img_name'
00131                 ),
00132                 'page' => array( 'LEFT JOIN', array(
00133                     'il_to = page_title',
00134                     'page_namespace' => NS_FILE,
00135                 ) ),
00136                 'redirect' => array( 'LEFT JOIN', array(
00137                     'page_id = rd_from',
00138                     'rd_namespace' => NS_FILE,
00139                     'rd_interwiki' => ''
00140                 ) ),
00141                 'img2' => array( 'LEFT JOIN',
00142                     'rd_title = img2.img_name'
00143                 )
00144             )
00145         );
00146     }
00147 
00148     protected function getGroupName() {
00149         return 'maintenance';
00150     }
00151 }