Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94150
Change subject: Suppress section edit links with action=render
......................................................................
Suppress section edit links with action=render
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
---
M includes/Article.php
M includes/OutputPage.php
2 files changed, 25 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/50/94150/1
diff --git a/includes/Article.php b/includes/Article.php
index 928fda0..214e966 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -1472,6 +1472,7 @@
*/
public function render() {
$this->getContext()->getOutput()->setArticleBodyOnly( true );
+ $this->getContext()->getOutput()->enableSectionEditLinks( false
);
$this->view();
}
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index b4fda13..5ffb802 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -256,9 +256,14 @@
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.
@@ -1612,6 +1617,7 @@
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 @@
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;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/94150
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab02cbd42f2f93f0f5264a74691ae1b84f296f12
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits