Merge "Add tracking categories when magic links are used"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 4 Nov 2016 02:29:54 +0000 (02:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Nov 2016 02:29:54 +0000 (02:29 +0000)
includes/parser/Parser.php
includes/specials/SpecialTrackingCategories.php
languages/i18n/en.json
languages/i18n/qqq.json

index 27c9535..eafccd9 100644 (file)
@@ -1446,6 +1446,7 @@ class Parser {
                                $keyword = 'RFC';
                                $urlmsg = 'rfcurl';
                                $cssClass = 'mw-magiclink-rfc';
+                               $trackingCat = 'magiclink-tracking-rfc';
                                $id = $m[5];
                        } elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
                                if ( !$this->mOptions->getMagicPMIDLinks() ) {
@@ -1454,12 +1455,14 @@ class Parser {
                                $keyword = 'PMID';
                                $urlmsg = 'pubmedurl';
                                $cssClass = 'mw-magiclink-pmid';
+                               $trackingCat = 'magiclink-tracking-pmid';
                                $id = $m[5];
                        } else {
                                throw new MWException( __METHOD__ . ': unrecognised match type "' .
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
                        $url = wfMessage( $urlmsg, $id )->inContentLanguage()->text();
+                       $this->addTrackingCategory( $trackingCat );
                        return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $cssClass, [], $this->mTitle );
                } elseif ( isset( $m[6] ) && $m[6] !== ''
                        && $this->mOptions->getMagicISBNLinks()
@@ -1473,6 +1476,7 @@ class Parser {
                                ' ' => '',
                                'x' => 'X',
                        ] );
+                       $this->addTrackingCategory( 'magiclink-tracking-isbn' );
                        return $this->getLinkRenderer()->makeKnownLink(
                                SpecialPage::getTitleFor( 'Booksources', $num ),
                                "ISBN $isbn",
index 4c892b2..3b502f8 100644 (file)
@@ -145,6 +145,19 @@ class SpecialTrackingCategories extends SpecialPage {
                        ExtensionRegistry::getInstance()->getAttribute( 'TrackingCategories' ),
                        $this->getConfig()->get( 'TrackingCategories' ) // deprecated
                );
+
+               // Only show magic link tracking categories if they are enabled
+               $enableMagicLinks = $this->getConfig()->get( 'EnableMagicLinks' );
+               if ( $enableMagicLinks['ISBN'] ) {
+                       $categories[] = 'magiclink-tracking-isbn';
+               }
+               if ( $enableMagicLinks['RFC'] ) {
+                       $categories[] = 'magiclink-tracking-rfc';
+               }
+               if ( $enableMagicLinks['PMID'] ) {
+                       $categories[] = 'magiclink-tracking-pmid';
+               }
+
                $trackingCategories = [];
                foreach ( $categories as $catMsg ) {
                        /*
index 5e06612..a59622d 100644 (file)
        "booksources-search": "Search",
        "booksources-text": "Below is a list of links to other sites that sell new and used books, and may also have further information about books you are looking for:",
        "booksources-invalid-isbn": "The given ISBN does not appear to be valid; check for errors copying from the original source.",
+       "magiclink-tracking-rfc": "Pages using RFC magic links",
+       "magiclink-tracking-rfc-desc": "This page uses RFC magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
+       "magiclink-tracking-pmid": "Pages using PMID magic links",
+       "magiclink-tracking-pmid-desc": "This page uses PMID magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
+       "magiclink-tracking-isbn": "Pages using ISBN magic links",
+       "magiclink-tracking-isbn-desc": "This page uses ISBN magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
        "rfcurl": "//tools.ietf.org/html/rfc$1",
        "pubmedurl": "//www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract",
        "specialloguserlabel": "Performer:",
index bcc9005..c8548ba 100644 (file)
        "booksources-search": "Search button in [[Special:BookSources]]\n\n{{Identical|Search}}",
        "booksources-text": "Used in [[Special:BookSources/1]].\n\nThis message is followed by a list of links to other sites.\n\nSee also:\n* {{msg-mw|Booksources|title}}\n* {{msg-mw|Booksources-text|text}}",
        "booksources-invalid-isbn": "This message is displayed after an invalid ISBN is entered on [[Special:Booksources]].",
+       "magiclink-tracking-rfc": "Name of the [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages that use RFC magic links will be added.",
+       "magiclink-tracking-rfc-desc": "Description of the tracking category {{mw-msg|magiclink-tracking-rfc}}",
+       "magiclink-tracking-pmid": "Name of the [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages that use PMID magic links will be added.",
+       "magiclink-tracking-pmid-desc": "Description of the tracking category {{mw-msg|magiclink-tracking-pmid}}",
+       "magiclink-tracking-isbn": "Name of the [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages that use ISBN magic links will be added.",
+       "magiclink-tracking-isbn-desc": "Description of the tracking category {{mw-msg|magiclink-tracking-isbn}}",
        "rfcurl": "{{notranslate}}\nParameters:\n* $1 - RFC number\nSee also:\n* {{msg-mw|Pubmedurl}}",
        "pubmedurl": "{{notranslate}}\nParameters:\n* $1 - Pubmed number\nSee also:\n* {{msg-mw|Rfcurl}}",
        "specialloguserlabel": "Used in [[Special:Log]] as a label for an input field with which the log can be filtered for entries describing actions ''performed'' by the specified user.  \"Carried out\" and \"done\" are possible alternatives for \"performed\".",