feat: add contextual tagline for different namespaces

This commit is contained in:
alistair3149 2021-04-12 17:09:35 -04:00
parent 8ef0e927f8
commit 2a93a292c7
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C
3 changed files with 73 additions and 6 deletions

View file

@ -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",

View file

@ -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",

View file

@ -40,13 +40,65 @@ final class Tagline extends Partial {
$title = $out->getTitle();
$shortdesc = $out->getProperty( 'shortdesc' );
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;
}