Mainframe98 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/351133 )
Change subject: First release of OrphanedTalkPages ...................................................................... First release of OrphanedTalkPages This adds the first version of OrphanedTalkPages Change-Id: I3f9d5eaa1aac16dfd7b634d3dae4b7c6b8a24bc0 --- A COPYING A OrphanedTalkPages.alias.php A README A extension.json A i18n/en.json A i18n/qqq.json A specials/SpecialOrphanedTalkPages.php 7 files changed, 193 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OrphanedTalkPages refs/changes/33/351133/1 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..31142cd --- /dev/null +++ b/COPYING @@ -0,0 +1,7 @@ +Copyright 2017 Klaas Skelte van der Werf + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/OrphanedTalkPages.alias.php b/OrphanedTalkPages.alias.php new file mode 100644 index 0000000..9d8f431 --- /dev/null +++ b/OrphanedTalkPages.alias.php @@ -0,0 +1,21 @@ +<?php +/** + * Aliases for NamespaceManager + * + * Created by PhpStorm. + * User: kswer + * Date: 26-4-2017 + * Time: 16:17 + */ + +$specialPageAliases = []; + +/** English (English) */ +$specialPageAliases['en'] = [ + 'OrphanedTalkPages' => [ 'OrphanedTalkPages' ], +]; + +/** Nederlands (Dutch) */ +$specialPageAliases['nl'] = [ + 'OrphanedTalkPages' => [ 'WeesOverlegPaginas' ], +]; \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..ad84cdc --- /dev/null +++ b/README @@ -0,0 +1,26 @@ +== About == +Orphaned talk pages adds a new Special page to MediaWiki: Special:OrphanedTalkPages. This special page lists all +talk pages that do not have an accompanying page. The namespaces that are exempt from these checks is the user talk +namespace by default, but this can be configured. + +== Installation instructions == +Note: you can also find these on https://www.mediawiki.org/wiki/Extension:OrphanedTalkPages + +To use this extension, add: +wfLoadExtension( 'OrphanedTalkPages' ); +to your LocalSettings.php file. + +== Configuration instructions == +This extension introduces two new configuration variables: +$wgOrphanedTalkPagesExemptedNamespaces and $wgOrphanedTalkPagesIgnoreUserTalk + +* $wgOrphanedTalkPagesExemptedNamespaces controls which talk namespaces should be ignored when looking for orphaned +talk pages. This variable is an array of namespace ids and is empty by default. +* $wgOrphanedTalkPagesIgnoreUserTalk determines if the user talk namespace (3, or NS_USER_TALK) should be ignored when +looking for orphaned talk pages. This variable is a boolean and set to true by default. + +== Other important notes == +* The query that this special page uses is considered expensive. This means that when $wgMiserMode is enabled, the +results will be served from cache. +* The special page may report talk pages as orphaned when they are not. The most common situation where this happens +is File talk pages when $wgUseInstantCommons or $wgForeignFileRepos is enabled. \ No newline at end of file diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..cef9ba6 --- /dev/null +++ b/extension.json @@ -0,0 +1,31 @@ +{ + "name": "OrphanedTalkPages", + "version": "1.0.0", + "author": [ + "Mainframe98" + ], + "url": "https://www.mediawiki.org/wiki/Extension:OrphanedTalkPages", + "descriptionmsg": "orphanedtalkpages-desc", + "namemsg": "orphanedtalkpages-extensionname", + "license-name": "MIT", + "type": "specialpage", + "AutoloadClasses": { + "SpecialOrphanedTalkPages": "specials/SpecialOrphanedTalkPages.php" + }, + "MessagesDirs": { + "OrphanedTalkPages": [ + "i18n" + ] + }, + "ExtensionMessagesFiles": { + "OrphanedTalkPagesAlias": "OrphanedTalkPages.alias.php" + }, + "SpecialPages": { + "OrphanedTalkPages": "SpecialOrphanedTalkPages" + }, + "config": { + "OrphanedTalkPagesExemptedNamespaces": [], + "OrphanedTalkPagesIgnoreUserTalk": true + }, + "manifest_version": 1 +} \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..bcc9aff --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,11 @@ +{ + "@metadata": { + "authors": [ + "Mainframe98" + ] + }, + "orphanedtalkpages": "Orphaned talk pages", + "orphanedtalkpages-desc": "Provides a list of orphaned talk pages.", + "orphanedtalkpages-extensionname": "Orphaned Talk Pages", + "orphanedtalkpages-text": "The following talk pages do not have an accompanying page." +} \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 0000000..627edb2 --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,11 @@ +{ + "@metadata": { + "authors": [ + "Mainframe98" + ] + }, + "orphanedtalkpages": "The name of the extension's entry in Special:SpecialPages", + "orphanedtalkpages-desc": "{{desc}}", + "orphanedtalkpages-extensionname": "Localized extension name", + "orphanedtalkpages-text": "Description appearing on top of Special:OrphanedTalkPages." +} \ No newline at end of file diff --git a/specials/SpecialOrphanedTalkPages.php b/specials/SpecialOrphanedTalkPages.php new file mode 100644 index 0000000..200043e --- /dev/null +++ b/specials/SpecialOrphanedTalkPages.php @@ -0,0 +1,86 @@ +<?php + +/** + * Created by PhpStorm. + * User: kswer + * Date: 26-2-2017 + * Time: 19:37 + */ +class SpecialOrphanedTalkPages extends PageQueryPage { + function __construct( $name = 'OrphanedTalkPages' ) { + parent::__construct( $name ); + } + + function getPageHeader() { + return $this->msg( 'orphanedtalkpages-text' )->parseAsBlock(); + } + + function sortDescending() { + return false; + } + + public function isExpensive() { + return true; + } + + function isSyndicated() { + return false; + } + + public function getQueryInfo() { + global $wgOrphanedTalkPagesExemptedNamespaces, $wgOrphanedTalkPagesIgnoreUserTalk; + + // Check if the configuration global is not empty and an array + if ( empty( $wgOrphanedTalkPagesExemptedNamespaces ) || + !is_array( $wgOrphanedTalkPagesExemptedNamespaces ) ) { + + // Check if it is an int if it isn't an array so single values still work + if ( is_int( $wgOrphanedTalkPagesExemptedNamespaces ) ) { + $wgOrphanedTalkPagesExemptedNamespaces = [ + $wgOrphanedTalkPagesExemptedNamespaces + ]; + } else { + $wgOrphanedTalkPagesExemptedNamespaces = []; + } + } + + // Check if the User talk namespace should be ignored. + if ( $wgOrphanedTalkPagesIgnoreUserTalk === true ) { + $wgOrphanedTalkPagesExemptedNamespaces[] = NS_USER_TALK; + } + + $query = [ + 'tables' => 'page AS p1', + 'fields' => [ + 'namespace' => 'p1.page_namespace', + 'title' =>'p1.page_title', + 'value' => 'page_title' // Sorting + ], + 'conds' => [ + 'p1.page_title NOT LIKE "%/%"', + 'p1.page_namespace % 2 != 0' + ] + ]; + + // Check if the configuration variable is still empty + if ( !empty( $wgOrphanedTalkPagesExemptedNamespaces ) ) { + // Loop through the exempted namespaces + foreach ( $wgOrphanedTalkPagesExemptedNamespaces as $namespace ) { + // Skip through non-numeric values + if ( !is_numeric( $namespace ) ) { + continue; + } + $query['conds'][] = "p1.page_namespace != $namespace"; + } + } + + // Add the final condition + $query['conds'][] = 'NOT EXISTS (SELECT 1 FROM page AS p2 WHERE p2.page_namespace = p1.page_namespace - 1 AND p1.page_title = p2.page_title)'; + + return $query; + } + + protected function getGroupName() { + return 'maintenance'; + } +} -- To view, visit https://gerrit.wikimedia.org/r/351133 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3f9d5eaa1aac16dfd7b634d3dae4b7c6b8a24bc0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OrphanedTalkPages Gerrit-Branch: master Gerrit-Owner: Mainframe98 <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
