From 326a00fa8bfb7ae0592265a8bde42c9f01c7ef65 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 8 Sep 2016 17:08:21 -0700 Subject: [PATCH] InfoAction: Add a link to Special:ChangeContentModel if allowed If the user is allowed to change the content model of the page, then add a link to it on ?action=info, next to the localized content model name. Change-Id: I084e8f390f90d29ed2e2d0f8ab43bcdfe8538ad1 --- includes/actions/InfoAction.php | 12 +++++++++++- languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 43bff876ee..abc7cb2f46 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -202,6 +202,7 @@ class InfoAction extends FormlessAction { $title = $this->getTitle(); $id = $title->getArticleID(); $config = $this->context->getConfig(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $pageCounts = $this->pageCounts( $this->page ); @@ -279,9 +280,18 @@ class InfoAction extends FormlessAction { . ' ' . $this->msg( 'parentheses', $pageLang )->escaped() ]; // Content model of the page + $modelHtml = htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) ); + // If the user can change it, add a link to Special:ChangeContentModel + if ( $title->quickUserCan( 'editcontentmodel' ) ) { + $modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink( + SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ), + $this->msg( 'pageinfo-content-model-change' )->text() + ) )->escaped(); + } + $pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-content-model' ), - htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) ) + $modelHtml ]; // Search engine status diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 020f058907..c8969a7cc2 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2810,6 +2810,7 @@ "pageinfo-article-id": "Page ID", "pageinfo-language": "Page content language", "pageinfo-content-model": "Page content model", + "pageinfo-content-model-change": "change", "pageinfo-robot-policy": "Indexing by robots", "pageinfo-robot-index": "Allowed", "pageinfo-robot-noindex": "Disallowed", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 4d38ce7110..562e3e5fcf 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2994,6 +2994,7 @@ "pageinfo-article-id": "The numeric identifier of the page.\n{{Identical|Page ID}}", "pageinfo-language": "Language in which the page content is written.", "pageinfo-content-model": "The model in which the page content is written.\n\nUsed as label at [{{fullurl:Main Page|action=info}} action=info]. Followed by one of the following messages:\n* {{msg-mw|Content-model-wikitext}}\n* {{msg-mw|Content-model-javascript}}\n* {{msg-mw|Content-model-css}}\n* {{msg-mw|Content-model-text}}", + "pageinfo-content-model-change": "Link text for a link to Special:ChangeContentModel. The link will be wrapped in parenthesis.", "pageinfo-robot-policy": "The search engine status of the page.\n\nUsed as label. Followed by any one of the following messages:\n*{{msg-mw|Pageinfo-robot-index}}\n*{{msg-mw|Pageinfo-robot-noindex}}", "pageinfo-robot-index": "An indication that the page is indexable by search engines, that is listed in their search results.\n\nPreceded by the label {{msg-mw|Pageinfo-robot-policy}}.\n{{Identical|Allowed}}", "pageinfo-robot-noindex": "An indication that the page is not indexable (that is, is not listed on the results page of a search engine).\n\nPreceded by the label {{msg-mw|Pageinfo-robot-policy}}.", -- 2.20.1