Show copyright based on $output->hasCopyright()
authorStephane Bisson <sbisson@wikimedia.org>
Wed, 3 Oct 2018 13:12:37 +0000 (09:12 -0400)
committerStephane Bisson <sbisson@wikimedia.org>
Wed, 3 Oct 2018 15:54:16 +0000 (11:54 -0400)
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
includes/skins/SkinTemplate.php

index 2bfccda..dd2f5ac 100644 (file)
@@ -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;
        }
+
 }
index 564220c..c29c996 100644 (file)
@@ -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() );