From fe3e7524dc79539e2e101e11b3249e7690babbce Mon Sep 17 00:00:00 2001 From: X! Date: Thu, 11 Sep 2008 22:30:27 +0000 Subject: [PATCH] Add new special page Wantedfiles. --- RELEASE-NOTES | 1 + includes/AutoLoader.php | 1 + includes/DefaultSettings.php | 1 + includes/QueryPage.php | 1 + includes/SpecialPage.php | 3 +- includes/specials/SpecialWantedfiles.php | 90 ++++++++++++++++++++++++ languages/messages/MessagesEn.php | 3 + maintenance/language/messageTypes.inc | 1 + maintenance/language/messages.inc | 2 + 9 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 includes/specials/SpecialWantedfiles.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6ce168efaf..dff4659e89 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index d134004a36..30ce952b30 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5b78496840..501a65885e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2770,6 +2770,7 @@ $wgSpecialPageGroups = array( 'Deadendpages' => 'maintenance', 'Wantedpages' => 'maintenance', 'Wantedcategories' => 'maintenance', + 'Wantedfiles' => 'maintenance', 'Unwatchedpages' => 'maintenance', 'Fewestrevisions' => 'maintenance', diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 16dc7c0469..c5cd03d43c 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -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' ), diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 0ff808978a..1f0807dc64 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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 index 0000000000..28f17ae1b8 --- /dev/null +++ b/includes/specials/SpecialWantedfiles.php @@ -0,0 +1,90 @@ + + * @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 ); +} diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 34c7d8f50f..d799828cac 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index b2ad195148..08adb712fb 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -128,6 +128,7 @@ $wgIgnoredMessages = array( 'uncategorizedtemplates-summary', 'popularpages-summary', 'wantedcategories-summary', + 'wantedfiles-summary', 'wantedpages-summary', 'mostlinked-summary', 'mostlinkedcategories-summary', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index e5de67d81c..efde6ade09 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1274,6 +1274,8 @@ $wgMessageStructure = array( 'wantedcategories-summary', 'wantedpages', 'wantedpages-summary', + 'wantedfiles', + 'wantedfiles-summary', 'missingfiles', 'missingfiles-summary', 'mostlinked', -- 2.20.1