From 2a93a292c7a372b213e30c769ffdc7daa3479c8c Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Mon, 12 Apr 2021 17:09:35 -0400 Subject: [PATCH] feat: add contextual tagline for different namespaces --- i18n/en.json | 8 +++++ i18n/qqq.json | 7 ++++ includes/Partials/Tagline.php | 64 +++++++++++++++++++++++++++++++---- 3 files changed, 73 insertions(+), 6 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 1fddaace..83cdaa7a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -28,6 +28,14 @@ "citizen-search-fulltext": "Search pages containing", + "citizen-tagline-ns-talk": "Discussion page of {{SUBJECTPAGENAME}}", + "citizen-tagline-ns-project": "Information about {{SITENAME}}", + "citizen-tagline-ns-file": "File on {{SITENAME}}", + "citizen-tagline-ns-mediawiki": "MediaWiki interface page", + "citizen-tagline-ns-template": "Template page", + "citizen-tagline-ns-help": "Help page", + "citizen-tagline-ns-category": "Category page", + "prefs-citizen-theme-label": "Theme", "prefs-citizen-theme-option-auto": "Auto", "prefs-citizen-theme-option-light": "Light", diff --git a/i18n/qqq.json b/i18n/qqq.json index bdac03a8..ce4bd145 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -22,6 +22,13 @@ "citizen-footer-desc": "Edit this text on MediaWiki:Citizen-footer-desc", "citizen-footer-tagline": "Edit this text on MediaWiki:Citizen-footer-tagline", "citizen-search-fulltext": "Fulltext search suggestion", + "citizen-tagline-ns-talk": "Tagline for pages in talk namespace", + "citizen-tagline-ns-project": "Tagline for pages in project namespace", + "citizen-tagline-ns-file": "Tagline for pages in file namespace", + "citizen-tagline-ns-mediawiki": "Tagline for pages in MediaWiki namespace", + "citizen-tagline-ns-template": "Tagline for pages in template namespace", + "citizen-tagline-ns-help": "Tagline for pages in help namespace", + "citizen-tagline-ns-category": "Tagline for pages in category namespace", "prefs-citizen-theme-label": "Tooltip for the theme dropdown in Special:Preferences", "prefs-citizen-theme-option-auto": "Label for the auto theme option", "prefs-citizen-theme-option-light": "Label for the light theme option", diff --git a/includes/Partials/Tagline.php b/includes/Partials/Tagline.php index edf4cba5..7511b28c 100644 --- a/includes/Partials/Tagline.php +++ b/includes/Partials/Tagline.php @@ -40,12 +40,64 @@ final class Tagline extends Partial { $title = $out->getTitle(); $shortdesc = $out->getProperty( 'shortdesc' ); - // Use short description if there is any - // from Extension:ShortDescription - if ( $shortdesc ) { - $tagline = $shortdesc; - } else { - $tagline = $this->skin->msg( 'tagline' )->text(); + if ( $title ) { + // Use short description if there is any + // from Extension:ShortDescription + if ( $shortdesc ) { + $tagline = $shortdesc; + } else { + switch ( $title->getNamespace() ) { + // Default MW namespaces + // Special + // Don't show tagline for special pages + case -1: + $tagline = ''; + break; + // Talk pages + case 1: + case 3: + case 5: + case 7: + case 9: + case 11: + case 13: + case 15: + $tagline = $this->skin->msg( 'citizen-tagline-ns-talk' )->text(); + break; + /* + // User pages + case 2: + $tagline = $this->buildUserTagline( $title ); + break; + */ + // Project pages + case 4: + $tagline = $this->skin->msg( 'citizen-tagline-ns-project' )->text(); + break; + // File pages + case 6: + $tagline = $this->skin->msg( 'citizen-tagline-ns-file' )->text(); + break; + // MediaWiki namespace + case 8: + $tagline = $this->skin->msg( 'citizen-tagline-ns-mediawiki' )->text(); + break; + // Template page + case 10: + $tagline = $this->skin->msg( 'citizen-tagline-ns-template' )->text(); + break; + // Help page + case 12: + $tagline = $this->skin->msg( 'citizen-tagline-ns-help' )->text(); + break; + // Category page + case 14: + $tagline = $this->skin->msg( 'citizen-tagline-ns-category' )->text(); + break; + default: + $tagline = $this->skin->msg( 'tagline' )->text(); + } + } } return $tagline;