8 * Querypage that lists the most wanted files - implements Special:Wantedfiles
10 * @ingroup SpecialPage
12 * @author Soxred93 <soxred93@gmail.com>
13 * @copyright Copyright © 2008, Soxred93
14 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
16 class WantedFilesPage extends QueryPage {
22 function isExpensive() {
26 function isSyndicated() {
31 $dbr = wfGetDB( DB_SLAVE );
32 list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
33 $name = $dbr->addQuotes( $this->getName() );
38 " . NS_FILE . " as namespace,
42 LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_FILE ."
43 WHERE page_title IS NULL
48 function sortDescending() { return true; }
51 * Fetch user page links and cache their existence
53 function preprocessResults( $db, $res ) {
54 $batch = new LinkBatch;
55 while ( $row = $db->fetchObject( $res ) )
56 $batch->add( $row->namespace, $row->title );
59 // Back to start for display
60 if ( $db->numRows( $res ) > 0 )
61 // If there are no rows we get an error seeking.
62 $db->dataSeek( $res, 0 );
65 function formatResult( $skin, $result ) {
66 global $wgLang, $wgContLang;
68 $nt = Title::makeTitle( $result->namespace, $result->title );
69 $text = $wgContLang->convert( $nt->getText() );
71 $plink = $this->isCached() ?
72 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
73 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
77 $this->makeWlhLink( $nt, $skin, $result )
82 * Make a "what links here" link for a given title
84 * @param Title $title Title to make the link for
85 * @param Skin $skin Skin to use
86 * @param object $result Result row
89 private function makeWlhLink( $title, $skin, $result ) {
91 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
92 $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
93 $wgLang->formatNum( $result->value ) );
94 return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
101 function wfSpecialWantedFiles() {
102 list( $limit, $offset ) = wfCheckLimits();
104 $wpp = new WantedFilesPage();
106 $wpp->doQuery( $offset, $limit );