X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/specials/SpecialMostinterwikis.php diff --git a/includes/specials/SpecialMostinterwikis.php b/includes/specials/SpecialMostinterwikis.php new file mode 100644 index 00000000..5e56694f --- /dev/null +++ b/includes/specials/SpecialMostinterwikis.php @@ -0,0 +1,115 @@ + [ + 'langlinks', + 'page' + ], 'fields' => [ + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'COUNT(*)' + ], 'conds' => [ + 'page_namespace' => MWNamespace::getContentNamespaces() + ], 'options' => [ + 'HAVING' => 'COUNT(*) > 1', + 'GROUP BY' => [ + 'page_namespace', + 'page_title' + ] + ], 'join_conds' => [ + 'page' => [ + 'LEFT JOIN', + 'page_id = ll_from' + ] + ] + ]; + } + + /** + * Pre-fill the link cache + * + * @param IDatabase $db + * @param ResultWrapper $res + */ + function preprocessResults( $db, $res ) { + $this->executeLBFromResultWrapper( $res ); + } + + /** + * @param Skin $skin + * @param object $result + * @return string + */ + function formatResult( $skin, $result ) { + $title = Title::makeTitleSafe( $result->namespace, $result->title ); + if ( !$title ) { + return Html::element( + 'span', + [ 'class' => 'mw-invalidtitle' ], + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title + ) + ); + } + + $linkRenderer = $this->getLinkRenderer(); + if ( $this->isCached() ) { + $link = $linkRenderer->makeLink( $title ); + } else { + $link = $linkRenderer->makeKnownLink( $title ); + } + + $count = $this->msg( 'ninterwikis' )->numParams( $result->value )->escaped(); + + return $this->getLanguage()->specialList( $link, $count ); + } + + protected function getGroupName() { + return 'highuse'; + } +}