From fcd6bb547f797fd23b929eb08c66262d0582fc95 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 16 Aug 2012 18:49:22 +0200 Subject: [PATCH] (bug 22749) Create Special:MostInterwikis This special pages counts all langlinks and shows the pages with the highest count. Update rate on WMF is every 3 days, like all other Most* special pages. Change-Id: Ia60aed7599e8b9d6dcbae2be9bc4f91f4f8d4e55 --- RELEASE-NOTES-1.20 | 1 + includes/AutoLoader.php | 1 + includes/DefaultSettings.php | 1 + includes/QueryPage.php | 1 + includes/SpecialPageFactory.php | 1 + includes/specials/SpecialMostinterwikis.php | 112 ++++++++++++++++++++ languages/messages/MessagesEn.php | 4 + languages/messages/MessagesQqq.php | 2 + maintenance/language/messageTypes.inc | 1 + maintenance/language/messages.inc | 3 + 10 files changed, 127 insertions(+) create mode 100644 includes/specials/SpecialMostinterwikis.php diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 5b4580ca3a..2fe2aa6695 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -126,6 +126,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * New hook 'ParserTestGlobals' allows to set globals before running parser tests. * Allow importing pages as subpage. * Add lang and hreflang attributes to language links on Login page. +* (bug 22749) Create Special:MostInterwikis. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 752f09c93a..1b46c6ae6b 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -892,6 +892,7 @@ $wgAutoloadLocalClasses = array( 'MIMEsearchPage' => 'includes/specials/SpecialMIMEsearch.php', 'MostcategoriesPage' => 'includes/specials/SpecialMostcategories.php', 'MostimagesPage' => 'includes/specials/SpecialMostimages.php', + 'MostinterwikisPage' => 'includes/specials/SpecialMostinterwikis.php', 'MostlinkedCategoriesPage' => 'includes/specials/SpecialMostlinkedcategories.php', 'MostlinkedPage' => 'includes/specials/SpecialMostlinked.php', 'MostlinkedTemplatesPage' => 'includes/specials/SpecialMostlinkedtemplates.php', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d77aed1023..20c97a03c2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5663,6 +5663,7 @@ $wgSpecialPageGroups = array( 'Mostlinkedtemplates' => 'highuse', 'Mostcategories' => 'highuse', 'Mostimages' => 'highuse', + 'Mostinterwikis' => 'highuse', 'Mostrevisions' => 'highuse', 'Allpages' => 'pages', diff --git a/includes/QueryPage.php b/includes/QueryPage.php index e188d3b8e9..ac559dc5fc 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -45,6 +45,7 @@ $wgQueryPages = array( array( 'MIMEsearchPage', 'MIMEsearch' ), array( 'MostcategoriesPage', 'Mostcategories' ), array( 'MostimagesPage', 'Mostimages' ), + array( 'MostinterwikisPage', 'Mostinterwikis' ), array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ), array( 'MostlinkedPage', 'Mostlinked' ), diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php index 1d62e8b754..95f75a8ef7 100644 --- a/includes/SpecialPageFactory.php +++ b/includes/SpecialPageFactory.php @@ -134,6 +134,7 @@ class SpecialPageFactory { // High use pages 'Mostlinkedcategories' => 'MostlinkedCategoriesPage', 'Mostimages' => 'MostimagesPage', + 'Mostinterwikis' => 'MostinterwikisPage', 'Mostlinked' => 'MostlinkedPage', 'Mostlinkedtemplates' => 'MostlinkedTemplatesPage', 'Mostcategories' => 'MostcategoriesPage', diff --git a/includes/specials/SpecialMostinterwikis.php b/includes/specials/SpecialMostinterwikis.php new file mode 100644 index 0000000000..894d697b3d --- /dev/null +++ b/includes/specials/SpecialMostinterwikis.php @@ -0,0 +1,112 @@ + array ( + 'langlinks', + 'page' + ), 'fields' => array ( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'COUNT(*)' + ), 'conds' => array ( + 'page_namespace' => MWNamespace::getContentNamespaces() + ), 'options' => array ( + 'HAVING' => 'COUNT(*) > 1', + 'GROUP BY' => array ( + 'page_namespace', + 'page_title' + ) + ), 'join_conds' => array ( + 'page' => array ( + 'LEFT JOIN', + 'page_id = ll_from' + ) + ) + ); + } + + /** + * Pre-fill the link cache + * + * @param $db DatabaseBase + * @param $res + */ + function preprocessResults( $db, $res ) { + # There's no point doing a batch check if we aren't caching results; + # the page must exist for it to have been pulled out of the table + if ( !$this->isCached() || !$res->numRows() ) { + return; + } + + $batch = new LinkBatch; + foreach ( $res as $row ) { + $batch->add( $row->namespace, $row->title ); + } + $batch->execute(); + + // Back to start for display + $res->seek( 0 ); + } + + /** + * @param $skin Skin + * @param $result + * @return string + */ + function formatResult( $skin, $result ) { + $title = Title::makeTitleSafe( $result->namespace, $result->title ); + if ( !$title ) { + return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + } + + if ( $this->isCached() ) { + $link = Linker::link( $title ); + } else { + $link = Linker::linkKnown( $title ); + } + + $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped(); + + return $this->getLanguage()->specialList( $link, $count ); + } +} diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 903bf83d8d..41312c5612 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -417,6 +417,7 @@ $specialPageAliases = array( 'MIMEsearch' => array( 'MIMESearch' ), 'Mostcategories' => array( 'MostCategories' ), 'Mostimages' => array( 'MostLinkedFiles', 'MostFiles', 'MostImages' ), + 'Mostinterwikis' => array( 'MostInterwikis' ), 'Mostlinked' => array( 'MostLinkedPages', 'MostLinked' ), 'Mostlinkedcategories' => array( 'MostLinkedCategories', 'MostUsedCategories' ), 'Mostlinkedtemplates' => array( 'MostLinkedTemplates', 'MostUsedTemplates' ), @@ -2576,6 +2577,7 @@ It now redirects to [[$2]].', # Miscellaneous special pages 'nbytes' => '$1 {{PLURAL:$1|byte|bytes}}', 'ncategories' => '$1 {{PLURAL:$1|category|categories}}', +'ninterwikis' => '$1 {{PLURAL:$1|interwiki|interwikis}}', 'nlinks' => '$1 {{PLURAL:$1|link|links}}', 'nmembers' => '$1 {{PLURAL:$1|member|members}}', 'nrevisions' => '$1 {{PLURAL:$1|revision|revisions}}', @@ -2621,6 +2623,8 @@ It now redirects to [[$2]].', 'mostcategories-summary' => '', # do not translate or duplicate this message to other languages 'mostimages' => 'Most linked-to files', 'mostimages-summary' => '', # do not translate or duplicate this message to other languages +'mostinterwikis' => 'Pages with the most interwikis', +'mostinterwikis-summary' => '', # do not translate or duplicate this message to other languages 'mostrevisions' => 'Pages with the most revisions', 'mostrevisions-summary' => '', # do not translate or duplicate this message to other languages 'prefixindex' => 'All pages with prefix', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index ef79c09f5c..b85992e616 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -2358,6 +2358,7 @@ Possible alternatives to the word 'content' are 'subject matter' or 'wiki subjec # Miscellaneous special pages 'nbytes' => 'Message used on the history page of a wiki page. Each version of a page consist of a number of bytes. $1 is the number of bytes that the page uses. Uses plural as configured for a language based on $1.', 'ncategories' => "Used in the special page '[[Special:MostCategories]]' in brackets after each entry on the list signifying how many categories a page is part of. $1 is the number of categories.", +'ninterwikis' => "Used in the special page '[[Special:MostInterwikis]]' in brackets after each entry on the list signifying how many interwikis a page is part of. $1 is the number of interwikis.", 'nlinks' => 'This appears in brackets after each entry on the special page [[Special:MostLinked]]. $1 is the number of wiki links.', 'nmembers' => 'Appears in brackets after each category listed on the special page [[Special:WantedCategories]]. $1 is the number of members of the category.', 'nrevisions' => 'Number of revisions.', @@ -2388,6 +2389,7 @@ $1 is a page title", 'mostlinkedtemplates' => 'Name of special page displayed in [[Special:SpecialPages]]', 'mostcategories' => 'Name of special page displayed in [[Special:SpecialPages]]', 'mostimages' => 'Name of special page displayed in [[Special:SpecialPages]]', +'mostinterwikis' => 'Name of special page displayed in [[Special:SpecialPages]]', 'mostrevisions' => 'Name of special page displayed in [[Special:SpecialPages]]', 'prefixindex' => 'The page title of [[Special:PrefixIndex]]. When the user limits the list to a certain namespace, {{msg-mw|allinnamespace}} is used instead.', 'prefixindex-namespace' => 'The page title of [[Special:PrefixIndex]] limited to a specific namespace. Similar to {{msg-mw|allinnamespace}}. $1 is the name of the namespace', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 230f61306d..4f5b071fda 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -169,6 +169,7 @@ $wgIgnoredMessages = array( 'mostlinkedtemplates-summary', 'mostcategories-summary', 'mostimages-summary', + 'mostinterwikis-summary', 'mostrevisions-summary', 'prefixindex-summary', 'shortpages-summary', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 16580b895a..bed7e5adcd 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1650,6 +1650,7 @@ $wgMessageStructure = array( 'specialpages' => array( 'nbytes', 'ncategories', + 'ninterwikis', 'nlinks', 'nmembers', 'nrevisions', @@ -1696,6 +1697,8 @@ $wgMessageStructure = array( 'mostcategories-summary', 'mostimages', 'mostimages-summary', + 'mostinterwikis', + 'mostinterwikis-summary', 'mostrevisions', 'mostrevisions-summary', 'prefixindex', -- 2.20.1