3 * A querypage to list the missing files - implements Special:Missingfiles
5 * @addtogroup SpecialPage
7 * @author Matěj Grabovský <65s.mg@atlas.cz>
8 * @copyright Copyright © 2008, Matěj Grabovský
9 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
11 class MissingFilesPage
extends QueryPage
{
13 return 'Missingfiles';
16 function isExpensive() {
20 function isSyndicated() {
25 $dbr = wfGetDB( DB_SLAVE
);
26 list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
27 $name = $dbr->addQuotes( $this->getName() );
29 return "SELECT $name as type,
30 " . NS_IMAGE
. " as namespace,
34 LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_IMAGE
."
35 WHERE page_title IS NULL
40 function sortDescending() {
45 * Fetch user page links and cache their existence
47 function preprocessResults( $db, $res ) {
48 $batch = new LinkBatch
;
50 while ( $row = $db->fetchObject( $res ) )
51 $batch->addObj( Title
::makeTitleSafe( $row->namespace, $row->title
) );
55 // Back to start for display
56 if ( $db->numRows( $res ) > 0 )
58 // If there are no rows we get an error seeking.
59 $db->dataSeek( $res, 0 );
62 public function formatResult( $skin, $result ) {
63 global $wgLang, $wgContLang;
65 $nt = Title
::makeTitle( $result->namespace, $result->title
);
66 $text = $wgContLang->convert( $nt->getText() );
68 $plink = $this->isCached()
69 ?
'<s>' . $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) . '</s>'
70 : $skin->makeBrokenImageLinkObj( $nt, htmlspecialchars( $text ) );
72 $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value
) );
73 $nlinks = $skin->makeKnownLinkObj( SpecialPage
::getTitleFor( 'Whatlinkshere' ), $label, 'target=' . $nt->getPrefixedUrl() );
74 return wfSpecialList( $plink, $nlinks );
81 function wfSpecialMissingFiles() {
82 list( $limit, $offset ) = wfCheckLimits();
84 $wpp = new MissingFilesPage();
86 $wpp->doQuery( $offset, $limit );