00001 <?php
00002
00003
00004
00005
00006
00016 class WantedFilesPage extends QueryPage {
00017
00018 function getName() {
00019 return 'Wantedfiles';
00020 }
00021
00022 function isExpensive() {
00023 return true;
00024 }
00025
00026 function isSyndicated() {
00027 return false;
00028 }
00029
00030 function getSQL() {
00031 $dbr = wfGetDB( DB_SLAVE );
00032 list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
00033 $name = $dbr->addQuotes( $this->getName() );
00034 return
00035 "
00036 SELECT
00037 $name as type,
00038 " . NS_FILE . " as namespace,
00039 il_to as title,
00040 COUNT(*) as value
00041 FROM $imagelinks
00042 LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_FILE ."
00043 WHERE page_title IS NULL
00044 GROUP BY il_to
00045 ";
00046 }
00047
00048 function sortDescending() { return true; }
00049
00053 function preprocessResults( $db, $res ) {
00054 $batch = new LinkBatch;
00055 while ( $row = $db->fetchObject( $res ) )
00056 $batch->add( $row->namespace, $row->title );
00057 $batch->execute();
00058
00059
00060 if ( $db->numRows( $res ) > 0 )
00061
00062 $db->dataSeek( $res, 0 );
00063 }
00064
00065 function formatResult( $skin, $result ) {
00066 global $wgLang, $wgContLang;
00067
00068 $nt = Title::makeTitle( $result->namespace, $result->title );
00069 $text = $wgContLang->convert( $nt->getText() );
00070
00071 $plink = $this->isCached() ?
00072 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
00073 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
00074
00075 return wfSpecialList(
00076 $plink,
00077 $this->makeWlhLink( $nt, $skin, $result )
00078 );
00079 }
00080
00089 private function makeWlhLink( $title, $skin, $result ) {
00090 global $wgLang;
00091 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
00092 $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
00093 $wgLang->formatNum( $result->value ) );
00094 return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
00095 }
00096 }
00097
00101 function wfSpecialWantedFiles() {
00102 list( $limit, $offset ) = wfCheckLimits();
00103
00104 $wpp = new WantedFilesPage();
00105
00106 $wpp->doQuery( $offset, $limit );
00107 }