Add new special page Wantedfiles.
authorX! <soxred93@users.mediawiki.org>
Thu, 11 Sep 2008 22:30:27 +0000 (22:30 +0000)
committerX! <soxred93@users.mediawiki.org>
Thu, 11 Sep 2008 22:30:27 +0000 (22:30 +0000)
RELEASE-NOTES
includes/AutoLoader.php
includes/DefaultSettings.php
includes/QueryPage.php
includes/SpecialPage.php
includes/specials/SpecialWantedfiles.php [new file with mode: 0644]
languages/messages/MessagesEn.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc

index 6ce168e..dff4659 100644 (file)
@@ -123,6 +123,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   plaintext copyright notice. Patch by Juliano F. Ravasi.
 * (bug 15551) Deletion log excerpt is now shown whenever a user vists a 
   deleted page, even if they are unable to edit it.
+* Added Wantedfiles special pages, allowing users to find image links with no image.
 
 === Bug fixes in 1.14 ===
 
index d134004..30ce952 100644 (file)
@@ -489,6 +489,7 @@ $wgAutoloadLocalClasses = array(
        'UserrightsPage' => 'includes/specials/SpecialUserrights.php',
        'UsersPager' => 'includes/specials/SpecialListusers.php',
        'WantedCategoriesPage' => 'includes/specials/SpecialWantedcategories.php',
+       'WantedFilesPage' => 'includes/specials/SpecialWantedfiles.php',
        'WantedPagesPage' => 'includes/specials/SpecialWantedpages.php',
        'WhatLinksHerePage' => 'includes/specials/SpecialWhatlinkshere.php',
        'WikiImporter' => 'includes/specials/SpecialImport.php',
index 5b78496..501a658 100644 (file)
@@ -2770,6 +2770,7 @@ $wgSpecialPageGroups = array(
        'Deadendpages'              => 'maintenance',
        'Wantedpages'               => 'maintenance',
        'Wantedcategories'          => 'maintenance',
+       'Wantedfiles'               => 'maintenance',
        'Unwatchedpages'            => 'maintenance',
        'Fewestrevisions'           => 'maintenance',
 
index 16dc7c0..c5cd03d 100644 (file)
@@ -39,6 +39,7 @@ $wgQueryPages = array(
        array( 'UnusedCategoriesPage',          'Unusedcategories'              ),
        array( 'UnusedimagesPage',              'Unusedimages'                  ),
        array( 'WantedCategoriesPage',          'Wantedcategories'              ),
+       array( 'WantedFilesPage',               'Wantedfiles'                   ),
        array( 'WantedPagesPage',               'Wantedpages'                   ),
        array( 'UnwatchedPagesPage',            'Unwatchedpages'                ),
        array( 'UnusedtemplatesPage',           'Unusedtemplates'                               ),
index 0ff8089..1f0807d 100644 (file)
@@ -99,7 +99,7 @@ class SpecialPage
                'Statistics'                => array( 'SpecialPage', 'Statistics' ),
                'Randompage'                => 'Randompage',
                'Lonelypages'               => array( 'SpecialPage', 'Lonelypages' ),
-               'Uncategorizedpages'        => array( 'SpecialPage', 'Uncategorizedpages' ),
+               'Un7izedpages'        => array( 'SpecialPage', 'Uncategorizedpages' ),
                'Uncategorizedcategories'   => array( 'SpecialPage', 'Uncategorizedcategories' ),
                'Uncategorizedimages'       => array( 'SpecialPage', 'Uncategorizedimages' ),
                'Uncategorizedtemplates'    => array( 'SpecialPage', 'Uncategorizedtemplates' ),
@@ -107,6 +107,7 @@ class SpecialPage
                'Unusedimages'              => array( 'SpecialPage', 'Unusedimages' ),
                'Wantedpages'               => array( 'IncludableSpecialPage', 'Wantedpages' ),
                'Wantedcategories'          => array( 'SpecialPage', 'Wantedcategories' ),
+               'Wantedfiles'               => array( 'SpecialPage', 'Wantedfiles' ),
                'Mostlinked'                => array( 'SpecialPage', 'Mostlinked' ),
                'Mostlinkedcategories'      => array( 'SpecialPage', 'Mostlinkedcategories' ),
                'Mostlinkedtemplates'       => array( 'SpecialPage', 'Mostlinkedtemplates' ),
diff --git a/includes/specials/SpecialWantedfiles.php b/includes/specials/SpecialWantedfiles.php
new file mode 100644 (file)
index 0000000..28f17ae
--- /dev/null
@@ -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_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 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 );
+}
index 34c7d8f..d799828 100644 (file)
@@ -380,6 +380,7 @@ $specialPageAliases = array(
        'Unusedimages'              => array( 'UnusedImages' ),
        'Wantedpages'               => array( 'WantedPages', 'BrokenLinks' ),
        'Wantedcategories'          => array( 'WantedCategories' ),
+       'Wantedfiles'               => array( 'WantedFiles' ),
        'Missingfiles'              => array( 'MissingFiles', 'MissingImages' ),
        'Mostlinked'                => array( 'MostLinked' ),
        'Mostlinkedcategories'      => array( 'MostLinkedCategories', 'MostUsedCategories' ),
@@ -1990,6 +1991,8 @@ Each row contains links to the first and second redirect, as well as the target
 'popularpages-summary'            => '', # do not translate or duplicate this message to other languages
 'wantedcategories'                => 'Wanted categories',
 'wantedcategories-summary'        => '', # do not translate or duplicate this message to other languages
+'wantedfiles'                     => 'Wanted files',
+'wantedfiles-summary'             => '', # do not translate or duplicate this message to other languages
 'wantedpages'                     => 'Wanted pages',
 'wantedpages-summary'             => '', # do not translate or duplicate this message to other languages
 'missingfiles'                    => 'Missing files',
index b2ad195..08adb71 100644 (file)
@@ -128,6 +128,7 @@ $wgIgnoredMessages = array(
        'uncategorizedtemplates-summary',
        'popularpages-summary',
        'wantedcategories-summary',
+       'wantedfiles-summary',
        'wantedpages-summary',
        'mostlinked-summary',
        'mostlinkedcategories-summary',
index e5de67d..efde6ad 100644 (file)
@@ -1274,6 +1274,8 @@ $wgMessageStructure = array(
                'wantedcategories-summary',
                'wantedpages',
                'wantedpages-summary',
+               'wantedfiles',
+               'wantedfiles-summary',
                'missingfiles',
                'missingfiles-summary',
                'mostlinked',