Bug 13702 - Add Special:MissingFiles to list pages where an [[Image:]] link exists...
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 5 Jun 2008 16:19:29 +0000 (16:19 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 5 Jun 2008 16:19:29 +0000 (16:19 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/SpecialMissingfiles.php [new file with mode: 0644]
includes/SpecialPage.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 234ce89..3ae945a 100644 (file)
@@ -143,6 +143,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * The User class now contains a public function called isActiveEditor. Figures
   out if a user is active based on at least $wgActiveUserEditCount number of
   edits in the last $wgActiveUserDays days.
+* (bug 13702) Add Special:MissingFiles to list places where an image link is 
+  used but no such file exists.
 
 === Bug fixes in 1.13 ===
 
index 7f9bab9..42effd5 100644 (file)
@@ -2627,6 +2627,7 @@ $wgSpecialPageGroups = array(
        'Wantedcategories'          => 'maintenance',
        'Unwatchedpages'            => 'maintenance',
        'Fewestrevisions'           => 'maintenance',
+       'MissingFiles'                          => 'maintenance',
 
        'Userlogin'                 => 'login',
        'Userlogout'                => 'login',
diff --git a/includes/SpecialMissingfiles.php b/includes/SpecialMissingfiles.php
new file mode 100644 (file)
index 0000000..d2da51c
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * A querypage to list the missing files - implements Special:Missingfiles
+ *
+ * @addtogroup SpecialPage
+ *
+ * @author Matěj Grabovský <65s.mg@atlas.cz>
+ * @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() 
+                       ? '<s>' . $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) . '</s>'
+                       : $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
index fe41c42..d04fd65 100644 (file)
@@ -107,6 +107,7 @@ class SpecialPage
                'Unusedimages'              => array( 'SpecialPage', 'Unusedimages' ),
                'Wantedpages'               => array( 'IncludableSpecialPage', 'Wantedpages' ),
                'Wantedcategories'          => array( 'SpecialPage', 'Wantedcategories' ),
+               'Missingfiles'              => array( 'SpecialPage', 'MissingFiles' ),
                'Mostlinked'                => array( 'SpecialPage', 'Mostlinked' ),
                'Mostlinkedcategories'      => array( 'SpecialPage', 'Mostlinkedcategories' ),
                'Mostlinkedtemplates'       => array( 'SpecialPage', 'Mostlinkedtemplates' ),
index fb66e83..70c195b 100644 (file)
@@ -376,6 +376,7 @@ $specialPageAliases = array(
        'Unusedimages'              => array( 'UnusedImages' ),
        'Wantedpages'               => array( 'WantedPages', 'BrokenLinks' ),
        'Wantedcategories'          => array( 'WantedCategories' ),
+       'Missingfiles'              => array( 'MissingFiles', 'MissingImages' ),
        'Mostlinked'                => array( 'MostLinked' ),
        'Mostlinkedcategories'      => array( 'MostLinkedCategories', 'MostUsedCategories' ),
        'Mostlinkedtemplates'       => array( 'MostLinkedTemplates', 'MostUsedTemplates' ),
@@ -1875,6 +1876,8 @@ A page is treated as disambiguation page if it uses a template which is linked f
 'wantedcategories-summary'        => '', # only translate this message to other languages if you have to change it
 'wantedpages'                     => 'Wanted pages',
 'wantedpages-summary'             => '', # only translate this message to other languages if you have to change it
+'missingfiles'                    => 'Missing files',
+'missingfiles-summary'            => '', # only translate this message to other languages if you have to change it
 'mostlinked'                      => 'Most linked-to pages',
 'mostlinked-summary'              => '', # only translate this message to other languages if you have to change it
 'mostlinkedcategories'            => 'Most linked-to categories',
index dc512ba..5b22545 100644 (file)
@@ -1203,6 +1203,10 @@ $wgMessageStructure = array(
                'wantedcategories-summary',
                'wantedpages',
                'wantedpages-summary',
+               'missingfiles',
+               'missingfiles-summary',
+               'missingimages',
+               'missingimages-summary',
                'mostlinked',
                'mostlinked-summary',
                'mostlinkedcategories',