From f6db98925c8c61867d5324f00ac59e19159f6084 Mon Sep 17 00:00:00 2001 From: Danny B Date: Sat, 18 Oct 2008 17:32:40 +0000 Subject: [PATCH] * A new special page to list wanted templates --- RELEASE-NOTES | 2 + includes/AutoLoader.php | 4 +- includes/DefaultSettings.php | 1 + includes/QueryPage.php | 1 + includes/SpecialPage.php | 1 + includes/specials/SpecialWantedTemplates.php | 110 +++++++++++++++++++ languages/messages/MessagesCs.php | 1 + languages/messages/MessagesEn.php | 1 + 8 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 includes/specials/SpecialWantedTemplates.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 80b0e8a3a1..ce12fadeaf 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -170,6 +170,8 @@ The following extensions are migrated into MediaWiki 1.14: $wgMaxShellTime (180 seconds by default) * (bug 1306) 'Email user' link no longer shown on user page when emailing is not available due to lack of confirmed address or disabled preference +* Special:Wanted templates special page added to display missing templates + linked from articles === Bug fixes in 1.14 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 029e1f67a1..573cb5f7a9 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -501,13 +501,11 @@ $wgAutoloadLocalClasses = array( 'WantedCategoriesPage' => 'includes/specials/SpecialWantedcategories.php', 'WantedFilesPage' => 'includes/specials/SpecialWantedfiles.php', 'WantedPagesPage' => 'includes/specials/SpecialWantedpages.php', + 'WantedTemplatesPage' => 'includes/specials/SpecialWantedtemplates.php', 'WhatLinksHerePage' => 'includes/specials/SpecialWhatlinkshere.php', 'WikiImporter' => 'includes/Import.php', 'WikiRevision' => 'includes/Import.php', 'WithoutInterwikiPage' => 'includes/specials/SpecialWithoutinterwiki.php', - - # UDP logging - 'UDP' => 'includes/UDP.php', # includes/templates 'UsercreateTemplate' => 'includes/templates/Userlogin.php', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6fc717a51a..b1e9fef98e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2799,6 +2799,7 @@ $wgSpecialPageGroups = array( 'Wantedpages' => 'maintenance', 'Wantedcategories' => 'maintenance', 'Wantedfiles' => 'maintenance', + 'Wantedtemplates' => 'maintenance', 'Unwatchedpages' => 'maintenance', 'Fewestrevisions' => 'maintenance', diff --git a/includes/QueryPage.php b/includes/QueryPage.php index f880abbabb..8ebd5637e7 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -42,6 +42,7 @@ $wgQueryPages = array( array( 'WantedCategoriesPage', 'Wantedcategories' ), array( 'WantedFilesPage', 'Wantedfiles' ), array( 'WantedPagesPage', 'Wantedpages' ), + array( 'WantedTemplatesPage', 'Wantedtemplates' ), array( 'UnwatchedPagesPage', 'Unwatchedpages' ), array( 'UnusedtemplatesPage', 'Unusedtemplates' ), array( 'WithoutInterwikiPage', 'Withoutinterwiki' ), diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 0a7fc3d43f..69d228d58a 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -109,6 +109,7 @@ class SpecialPage 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ), 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ), 'Wantedfiles' => array( 'SpecialPage', 'Wantedfiles' ), + 'Wantedtemplates' => array( 'SpecialPage', 'Wantedtemplates' ), 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ), 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ), 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ), diff --git a/includes/specials/SpecialWantedTemplates.php b/includes/specials/SpecialWantedTemplates.php new file mode 100644 index 0000000000..fa5affbd95 --- /dev/null +++ b/includes/specials/SpecialWantedTemplates.php @@ -0,0 +1,110 @@ + + * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church + * + * @ingroup SpecialPage + * + * @author Danny B. + * @copyright Copyright © 2008, Danny B. + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ +class WantedTemplatesPage extends QueryPage { + + function getName() { + return 'Wantedtemplates'; + } + + function isExpensive() { + return true; + } + + function isSyndicated() { + return false; + } + + function getSQL() { + $dbr = wfGetDB( DB_SLAVE ); + list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' ); + $name = $dbr->addQuotes( $this->getName() ); + return + " + SELECT $name as type," . + NS_TEMPLATE . " as namespace, + tl_title as title, + COUNT(*) as value + FROM $templatelinks LEFT JOIN + $page ON tl_title = page_title AND page_namespace = ". NS_TEMPLATE ." + WHERE page_title IS NULL + GROUP BY tl_title + "; + } + + 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, + $this->makeWlhLink( $nt, $skin, $result ) + ); + } + + /** + * Make a "what links here" link for a given title + * + * @param Title $title Title to make the link for + * @param Skin $skin Skin to use + * @param object $result Result row + * @return string + */ + private function makeWlhLink( $title, $skin, $result ) { + global $wgLang; + $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); + $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), + $wgLang->formatNum( $result->value ) ); + return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); + } +} + +/** + * constructor + */ +function wfSpecialWantedTemplates() { + list( $limit, $offset ) = wfCheckLimits(); + + $wpp = new WantedTemplatesPage(); + + $wpp->doQuery( $offset, $limit ); +} diff --git a/languages/messages/MessagesCs.php b/languages/messages/MessagesCs.php index 06e4fa6238..85e17ab942 100644 --- a/languages/messages/MessagesCs.php +++ b/languages/messages/MessagesCs.php @@ -1689,6 +1689,7 @@ Vstup: typ obsahu/podtyp, např. image/jpeg.', 'wantedcategories' => 'Žádané kategorie', 'wantedpages' => 'Požadované stránky', 'wantedfiles' => 'Chybějící soubory', +'wantedtemplates' => 'Chybějící šablony', 'mostlinked' => 'Nejodkazovanější stránky', 'mostlinkedcategories' => 'Nejpoužívanější kategorie', 'mostlinkedtemplates' => 'Nejvkládanější šablony', diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index bc319c68b8..b08f050df5 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -383,6 +383,7 @@ $specialPageAliases = array( 'Wantedpages' => array( 'WantedPages', 'BrokenLinks' ), 'Wantedcategories' => array( 'WantedCategories' ), 'Wantedfiles' => array( 'WantedFiles' ), + 'Wantedtemplates' => array( 'WantedTemplates' ), 'Mostlinked' => array( 'MostLinked' ), 'Mostlinkedcategories' => array( 'MostLinkedCategories', 'MostUsedCategories' ), 'Mostlinkedtemplates' => array( 'MostLinkedTemplates', 'MostUsedTemplates' ), -- 2.20.1