From 8ebdf0242110aa83302563f59d173d8502c6353a Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Wed, 3 Oct 2018 09:12:37 -0400 Subject: [PATCH] Show copyright based on $output->hasCopyright() Introducing setCopyright/hasCopyright in OutputPage to make the showing of the copyright message controllable by pages other than articles. hasCopyright defaults to isArticle() to preserve the rule that all article should show the copyright. This is used by Flow to show the copyright on various pages that contain user-generated content. Bug: T184960 Change-Id: I3a50dbcedc6b119b9262c50cb3a84b0dd230fb3d --- includes/OutputPage.php | 26 ++++++++++++++++++++++++++ includes/skins/SkinTemplate.php | 20 ++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2bfccda265..dd2f5acf4a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -85,6 +85,9 @@ class OutputPage extends ContextSource { /** @var bool Stores "article flag" toggle. */ private $mIsArticleRelated = true; + /** @var bool Is the content subject to copyright */ + private $mHasCopyright = false; + /** * @var bool We have to set isPrintable(). Some pages should * never be printed (ex: redirections). @@ -1261,6 +1264,28 @@ class OutputPage extends ContextSource { return $this->mIsArticleRelated; } + /** + * Set whether the standard copyright should be shown for the current page. + * + * @param bool $hasCopyright + */ + public function setCopyright( $hasCopyright ) { + $this->mHasCopyright = $hasCopyright; + } + + /** + * Return whether the standard copyright should be shown for the current page. + * By default, it is true for all articles but other pages + * can signal it by using setCopyright( true ). + * + * Used by SkinTemplate to decided whether to show the copyright. + * + * @return bool + */ + public function showsCopyright() { + return $this->isArticle() || $this->mHasCopyright; + } + /** * Add new language links * @@ -3997,4 +4022,5 @@ class OutputPage extends ContextSource { } return $this->CSPNonce; } + } diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 564220c52c..c29c9963bf 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -385,16 +385,20 @@ class SkinTemplate extends Skin { $tpl->set( 'lastmod', false ); $tpl->set( 'credits', false ); $tpl->set( 'numberofwatchingusers', false ); - if ( $out->isArticle() && $title->exists() ) { - if ( $this->isRevisionCurrent() ) { - if ( $wgMaxCredits != 0 ) { - $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(), - $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); - } else { - $tpl->set( 'lastmod', $this->lastModified() ); + if ( $title->exists() ) { + if ( $out->isArticle() ) { + if ( $this->isRevisionCurrent() ) { + if ( $wgMaxCredits != 0 ) { + $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(), + $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) ); + } else { + $tpl->set( 'lastmod', $this->lastModified() ); + } } } - $tpl->set( 'copyright', $this->getCopyright() ); + if ( $out->showsCopyright() ) { + $tpl->set( 'copyright', $this->getCopyright() ); + } } $tpl->set( 'copyrightico', $this->getCopyrightIcon() ); -- 2.20.1