Suppress section edit links with action=render
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 7 Nov 2013 16:27:00 +0000 (17:27 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 9 Nov 2013 01:01:23 +0000 (02:01 +0100)
action=render is often used to pull the rendered HTML of an article
for inclusion in a different context. More often than not, the edit
links are not desired in that context.

Bug: 19415
Change-Id: Iab02cbd42f2f93f0f5264a74691ae1b84f296f12

RELEASE-NOTES-1.23
includes/Article.php
includes/OutputPage.php

index 7cf5c8e..156e7e9 100644 (file)
@@ -44,6 +44,7 @@ production.
   when the email address is already confirmed. Also, consistently use
   "confirmed", rather than "authenticated", when messaging whether or not the
   user has confirmed an email address.
+* (bug 19415) action=render no longer shows section edit links.
 
 === API changes in 1.23 ===
 * (bug 54884) action=parse&prop=categories now indicates hidden and missing
index a6afd8e..1619e09 100644 (file)
@@ -1473,6 +1473,7 @@ class Article implements Page {
         */
        public function render() {
                $this->getContext()->getOutput()->setArticleBodyOnly( true );
+               $this->getContext()->getOutput()->enableSectionEditLinks( false );
                $this->view();
        }
 
index b4fda13..5ffb802 100644 (file)
@@ -256,10 +256,15 @@ class OutputPage extends ContextSource {
        private $mTarget = null;
 
        /**
-        * @var bool: Whether output should contain table of contents
+        * @var bool: Whether parser output should contain table of contents
         */
        private $mEnableTOC = true;
 
+       /**
+        * @var bool: Whether parser output should contain section edit links
+        */
+       private $mEnableSectionEditLinks = true;
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -1612,6 +1617,7 @@ class OutputPage extends ContextSource {
        function addParserOutput( &$parserOutput ) {
                $this->addParserOutputNoText( $parserOutput );
                $parserOutput->setTOCEnabled( $this->mEnableTOC );
+               $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
                $text = $parserOutput->getText();
                wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
                $this->addHTML( $text );
@@ -3675,4 +3681,21 @@ $templates
        public function isTOCEnabled() {
                return $this->mEnableTOC;
        }
+
+       /**
+        * Enables/disables section edit links, doesn't override __NOEDITSECTION__
+        * @param bool $flag
+        * @since 1.23
+        */
+       public function enableSectionEditLinks( $flag = true ) {
+               $this->mEnableSectionEditLinks = $flag;
+       }
+
+       /**
+        * @return bool
+        * @since 1.23
+        */
+       public function sectionEditLinksEnabled() {
+               return $this->mEnableSectionEditLinks;
+       }
 }