summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialWantedfiles.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/specials/SpecialWantedfiles.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/specials/SpecialWantedfiles.php')
-rw-r--r--includes/specials/SpecialWantedfiles.php90
1 files changed, 90 insertions, 0 deletions
diff --git a/includes/specials/SpecialWantedfiles.php b/includes/specials/SpecialWantedfiles.php
new file mode 100644
index 00000000..c2731fa9
--- /dev/null
+++ b/includes/specials/SpecialWantedfiles.php
@@ -0,0 +1,90 @@
+<?php
+/*
+ * @file
+ * @ingroup SpecialPage
+ */
+
+/**
+ * Querypage that lists the most wanted files - implements Special:Wantedfiles
+ *
+ * @ingroup SpecialPage
+ *
+ * @author Soxred93 <soxred93@gmail.com>
+ * @copyright Copyright © 2008, Soxred93
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ */
+class WantedFilesPage extends QueryPage {
+
+ function getName() {
+ return 'Wantedfiles';
+ }
+
+ 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_FILE . " as namespace,
+ il_to as title,
+ COUNT(*) as value
+ FROM $imagelinks
+ LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_FILE ."
+ WHERE page_title IS NULL
+ GROUP BY il_to
+ ";
+ }
+
+ 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->add( $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 );
+ }
+
+ 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->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
+
+ $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),
+ $wgLang->formatNum( $result->value ) );
+ return wfSpecialList($plink, $nlinks);
+ }
+}
+
+/**
+ * constructor
+ */
+function wfSpecialWantedFiles() {
+ list( $limit, $offset ) = wfCheckLimits();
+
+ $wpp = new WantedFilesPage();
+
+ $wpp->doQuery( $offset, $limit );
+}