* A new special page to list wanted templates
authorDanny B <danny_b@users.mediawiki.org>
Sat, 18 Oct 2008 17:32:40 +0000 (17:32 +0000)
committerDanny B <danny_b@users.mediawiki.org>
Sat, 18 Oct 2008 17:32:40 +0000 (17:32 +0000)
RELEASE-NOTES
includes/AutoLoader.php
includes/DefaultSettings.php
includes/QueryPage.php
includes/SpecialPage.php
includes/specials/SpecialWantedTemplates.php [new file with mode: 0644]
languages/messages/MessagesCs.php
languages/messages/MessagesEn.php

index 80b0e8a..ce12fad 100644 (file)
@@ -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 ===
 
index 029e1f6..573cb5f 100644 (file)
@@ -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',
index 6fc717a..b1e9fef 100644 (file)
@@ -2799,6 +2799,7 @@ $wgSpecialPageGroups = array(
        'Wantedpages'               => 'maintenance',
        'Wantedcategories'          => 'maintenance',
        'Wantedfiles'               => 'maintenance',
+       'Wantedtemplates'           => 'maintenance',
        'Unwatchedpages'            => 'maintenance',
        'Fewestrevisions'           => 'maintenance',
 
index f880abb..8ebd563 100644 (file)
@@ -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'                              ),
index 0a7fc3d..69d228d 100644 (file)
@@ -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 (file)
index 0000000..fa5affb
--- /dev/null
@@ -0,0 +1,110 @@
+<?php\r
+/**\r
+ * @file\r
+ * @ingroup SpecialPage\r
+ */\r
+\r
+/**\r
+ * A querypage to list the most wanted templates - implements Special:Wantedtemplates\r
+ * based on SpecialWantedcategories.php by Ævar Arnfjörð Bjarmason <avarab@gmail.com>\r
+ * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church <robchur@gmail.com>\r
+ *\r
+ * @ingroup SpecialPage\r
+ *\r
+ * @author Danny B.\r
+ * @copyright Copyright © 2008, Danny B.\r
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later\r
+ */\r
+class WantedTemplatesPage extends QueryPage {\r
+\r
+       function getName() {\r
+               return 'Wantedtemplates';\r
+       }\r
+\r
+       function isExpensive() {\r
+               return true;\r
+       }\r
+\r
+       function isSyndicated() {\r
+               return false;\r
+       }\r
+\r
+       function getSQL() {\r
+               $dbr = wfGetDB( DB_SLAVE );\r
+               list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' );\r
+               $name = $dbr->addQuotes( $this->getName() );\r
+               return\r
+                       "\r
+                         SELECT $name as type," . \r
+                                NS_TEMPLATE . " as namespace,\r
+                                tl_title as title,\r
+                                COUNT(*) as value\r
+                           FROM $templatelinks LEFT JOIN\r
+                                $page ON tl_title = page_title AND page_namespace = ". NS_TEMPLATE ."\r
+                          WHERE page_title IS NULL\r
+                       GROUP BY tl_title\r
+                       ";\r
+       }\r
+\r
+       function sortDescending() { return true; }\r
+\r
+       /**\r
+        * Fetch user page links and cache their existence\r
+        */\r
+       function preprocessResults( $db, $res ) {\r
+               $batch = new LinkBatch;\r
+               while ( $row = $db->fetchObject( $res ) )\r
+                       $batch->add( $row->namespace, $row->title );\r
+               $batch->execute();\r
+\r
+               // Back to start for display\r
+               if ( $db->numRows( $res ) > 0 )\r
+                       // If there are no rows we get an error seeking.\r
+                       $db->dataSeek( $res, 0 );\r
+       }\r
+\r
+       function formatResult( $skin, $result ) {\r
+               global $wgLang, $wgContLang;\r
+\r
+               $nt = Title::makeTitle( $result->namespace, $result->title );\r
+               $text = $wgContLang->convert( $nt->getText() );\r
+\r
+               $plink = $this->isCached() ?\r
+                       $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :\r
+                       $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );\r
+\r
+               $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'),\r
+                       $wgLang->formatNum( $result->value ) );\r
+               return wfSpecialList(\r
+                       $plink,\r
+                       $this->makeWlhLink( $nt, $skin, $result )\r
+               );\r
+       }\r
+\r
+       /**\r
+        * Make a "what links here" link for a given title\r
+        *\r
+        * @param Title $title Title to make the link for\r
+        * @param Skin $skin Skin to use\r
+        * @param object $result Result row\r
+        * @return string\r
+        */\r
+       private function makeWlhLink( $title, $skin, $result ) {\r
+               global $wgLang;\r
+               $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );\r
+               $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),\r
+               $wgLang->formatNum( $result->value ) );\r
+               return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );\r
+       }\r
+}\r
+\r
+/**\r
+ * constructor\r
+ */\r
+function wfSpecialWantedTemplates() {\r
+       list( $limit, $offset ) = wfCheckLimits();\r
+\r
+       $wpp = new WantedTemplatesPage();\r
+\r
+       $wpp->doQuery( $offset, $limit );\r
+}\r
index 06e4fa6..85e17ab 100644 (file)
@@ -1689,6 +1689,7 @@ Vstup: <code>typ obsahu/podtyp</code>, např. <code>image/jpeg</code>.',
 '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',
index bc319c6..b08f050 100644 (file)
@@ -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' ),