From 11aad2ae2a8686a63a541d726452315e5130a1be Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 5 Jun 2008 19:42:47 +0000 Subject: [PATCH] And there it is. --- includes/SpecialMissingFiles.php | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 includes/SpecialMissingFiles.php diff --git a/includes/SpecialMissingFiles.php b/includes/SpecialMissingFiles.php new file mode 100644 index 0000000000..d2da51c741 --- /dev/null +++ b/includes/SpecialMissingFiles.php @@ -0,0 +1,87 @@ + + * @copyright Copyright © 2008, Matěj Grabovský + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ +class MissingFilesPage extends QueryPage { + function getName() { + return 'Missingfiles'; + } + + function isExpensive() { + return true; + } + + function isSyndicated() { + return false; + } + + function getSQL() { + $dbr = wfGetDB( DB_SLAVE ); + list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' ); + $name = $dbr->addQuotes( $this->getName() ); + + return "SELECT $name as type, + " . NS_IMAGE . " as namespace, + il_to as title, + COUNT(*) as value + FROM $imagelinks + LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_IMAGE ." + WHERE page_title IS NULL + GROUP BY 1,2,3 + "; + } + + function sortDescending() { + return true; + } + + /** + * Fetch user page links and cache their existence + */ + function preprocessResults( $db, $res ) { + $batch = new LinkBatch; + + while ( $row = $db->fetchObject( $res ) ) + $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); + + $batch->execute(); + + // Back to start for display + if ( $db->numRows( $res ) > 0 ) + + // If there are no rows we get an error seeking. + $db->dataSeek( $res, 0 ); + } + + public function formatResult( $skin, $result ) { + global $wgLang, $wgContLang; + + $nt = Title::makeTitle( $result->namespace, $result->title ); + $text = $wgContLang->convert( $nt->getText() ); + + $plink = $this->isCached() + ? '' . $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) . '' + : $skin->makeBrokenImageLinkObj( $nt, htmlspecialchars( $text ) ); + + $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) ); + $nlinks = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Whatlinkshere' ), $label, 'target=' . $nt->getPrefixedUrl() ); + return wfSpecialList( $plink, $nlinks ); + } +} + +/** + * Constructor + */ +function wfSpecialMissingFiles() { + list( $limit, $offset ) = wfCheckLimits(); + + $wpp = new MissingFilesPage(); + + $wpp->doQuery( $offset, $limit ); +} \ No newline at end of file -- 2.20.1