2011-06-20 18:55:17 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
* Displays information about a page.
|
2011-06-20 18:55:17 +00:00
|
|
|
*
|
|
|
|
|
* Copyright © 2011 Alexandre Emsenhuber
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2016-04-15 16:29:05 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2017-02-07 04:49:57 +00:00
|
|
|
use Wikimedia\Rdbms\Database;
|
2016-04-15 16:29:05 +00:00
|
|
|
|
2013-03-05 15:39:35 +00:00
|
|
|
/**
|
|
|
|
|
* Displays information about a page.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Actions
|
|
|
|
|
*/
|
2011-06-20 18:55:17 +00:00
|
|
|
class InfoAction extends FormlessAction {
|
2015-09-30 18:24:31 +00:00
|
|
|
const VERSION = 1;
|
2013-03-17 04:39:40 +00:00
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the name of the action this object responds to.
|
|
|
|
|
*
|
2014-04-10 18:50:10 +00:00
|
|
|
* @return string Lowercase name
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
*/
|
2011-06-20 18:55:17 +00:00
|
|
|
public function getName() {
|
|
|
|
|
return 'info';
|
|
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
/**
|
|
|
|
|
* Whether this action can still be executed by a blocked user.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2011-06-20 18:55:17 +00:00
|
|
|
public function requiresUnblock() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
/**
|
|
|
|
|
* Whether this action requires the wiki not to be locked.
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function requiresWrite() {
|
|
|
|
|
return false;
|
2011-07-11 08:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-06 01:08:27 +00:00
|
|
|
/**
|
|
|
|
|
* Clear the info cache for a given Title.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.22
|
|
|
|
|
* @param Title $title Title to clear cache for
|
2015-07-29 07:42:56 +00:00
|
|
|
* @param int|null $revid Revision id to clear
|
2013-05-06 01:08:27 +00:00
|
|
|
*/
|
2015-07-29 07:42:56 +00:00
|
|
|
public static function invalidateCache( Title $title, $revid = null ) {
|
|
|
|
|
if ( !$revid ) {
|
|
|
|
|
$revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST );
|
|
|
|
|
$revid = $revision ? $revision->getId() : null;
|
|
|
|
|
}
|
|
|
|
|
if ( $revid !== null ) {
|
2017-05-24 03:36:53 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
|
|
|
|
$key = self::getCacheKey( $cache, $title, $revid );
|
|
|
|
|
$cache->delete( $key );
|
2013-05-06 01:08:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
/**
|
|
|
|
|
* Shows page information on GET request.
|
|
|
|
|
*
|
|
|
|
|
* @return string Page information that will be added to the output
|
|
|
|
|
*/
|
2011-06-20 18:55:17 +00:00
|
|
|
public function onView() {
|
2012-10-05 03:45:45 +00:00
|
|
|
$content = '';
|
|
|
|
|
|
2012-09-06 03:17:41 +00:00
|
|
|
// Validate revision
|
|
|
|
|
$oldid = $this->page->getOldID();
|
|
|
|
|
if ( $oldid ) {
|
|
|
|
|
$revision = $this->page->getRevisionFetched();
|
|
|
|
|
|
|
|
|
|
// Revision is missing
|
|
|
|
|
if ( $revision === null ) {
|
|
|
|
|
return $this->msg( 'missing-revision', $oldid )->parse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Revision is not current
|
|
|
|
|
if ( !$revision->isCurrent() ) {
|
|
|
|
|
return $this->msg( 'pageinfo-not-current' )->plain();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-05 03:45:45 +00:00
|
|
|
// Page header
|
|
|
|
|
if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
|
|
|
|
|
$content .= $this->msg( 'pageinfo-header' )->parse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hide "This page is a member of # hidden categories" explanation
|
2016-02-17 09:09:32 +00:00
|
|
|
$content .= Html::element( 'style', [],
|
2013-02-14 10:29:29 +00:00
|
|
|
'.mw-hiddenCategoriesExplanation { display: none; }' ) . "\n";
|
2012-10-05 03:45:45 +00:00
|
|
|
|
|
|
|
|
// Hide "Templates used on this page" explanation
|
2016-02-17 09:09:32 +00:00
|
|
|
$content .= Html::element( 'style', [],
|
2013-02-14 10:29:29 +00:00
|
|
|
'.mw-templatesUsedExplanation { display: none; }' ) . "\n";
|
2012-10-05 03:45:45 +00:00
|
|
|
|
|
|
|
|
// Get page information
|
2012-10-07 13:37:00 +00:00
|
|
|
$pageInfo = $this->pageInfo();
|
2012-10-05 03:45:45 +00:00
|
|
|
|
|
|
|
|
// Allow extensions to add additional information
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'InfoAction', [ $this->getContext(), &$pageInfo ] );
|
2012-10-05 03:45:45 +00:00
|
|
|
|
|
|
|
|
// Render page information
|
|
|
|
|
foreach ( $pageInfo as $header => $infoTable ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages:
|
2013-08-16 12:58:07 +00:00
|
|
|
// pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions,
|
|
|
|
|
// pageinfo-header-properties, pageinfo-category-info
|
2013-02-14 10:29:29 +00:00
|
|
|
$content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n";
|
|
|
|
|
$table = "\n";
|
2012-10-05 03:45:45 +00:00
|
|
|
foreach ( $infoTable as $infoRow ) {
|
|
|
|
|
$name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
|
|
|
|
|
$value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1];
|
2013-06-22 23:04:22 +00:00
|
|
|
$id = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->getKey() : null;
|
|
|
|
|
$table = $this->addRow( $table, $name, $value, $id ) . "\n";
|
2012-10-05 03:45:45 +00:00
|
|
|
}
|
2013-02-14 10:29:29 +00:00
|
|
|
$content = $this->addTable( $content, $table ) . "\n";
|
2012-10-05 03:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Page footer
|
|
|
|
|
if ( !$this->msg( 'pageinfo-footer' )->isDisabled() ) {
|
|
|
|
|
$content .= $this->msg( 'pageinfo-footer' )->parse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a header that can be added to the output.
|
|
|
|
|
*
|
2013-04-01 16:45:18 +00:00
|
|
|
* @param string $header The header text.
|
2012-10-05 03:45:45 +00:00
|
|
|
* @return string The HTML.
|
|
|
|
|
*/
|
|
|
|
|
protected function makeHeader( $header ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) ];
|
2013-11-14 11:18:26 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return Html::rawElement( 'h2', [], Html::element( 'span', $spanAttribs, $header ) );
|
2012-10-05 03:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a row to a table that will be added to the content.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $table The table that will be added to the content
|
|
|
|
|
* @param string $name The name of the row
|
|
|
|
|
* @param string $value The value of the row
|
2013-06-22 23:04:22 +00:00
|
|
|
* @param string $id The ID to use for the 'tr' element
|
2012-10-05 03:45:45 +00:00
|
|
|
* @return string The table with the row added
|
|
|
|
|
*/
|
2013-06-22 23:04:22 +00:00
|
|
|
protected function addRow( $table, $name, $value, $id ) {
|
2015-10-04 19:22:19 +00:00
|
|
|
return $table .
|
|
|
|
|
Html::rawElement(
|
|
|
|
|
'tr',
|
2016-02-17 09:09:32 +00:00
|
|
|
$id === null ? [] : [ 'id' => 'mw-' . $id ],
|
|
|
|
|
Html::rawElement( 'td', [ 'style' => 'vertical-align: top;' ], $name ) .
|
|
|
|
|
Html::rawElement( 'td', [], $value )
|
2015-10-04 19:22:19 +00:00
|
|
|
);
|
2012-10-05 03:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a table to the content that will be added to the output.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $content The content that will be added to the output
|
|
|
|
|
* @param string $table The table
|
2012-10-05 03:45:45 +00:00
|
|
|
* @return string The content with the table added
|
|
|
|
|
*/
|
|
|
|
|
protected function addTable( $content, $table ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return $content . Html::rawElement( 'table', [ 'class' => 'wikitable mw-page-info' ],
|
2012-10-05 03:45:45 +00:00
|
|
|
$table );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns page information in an easily-manipulated format. Array keys are used so extensions
|
|
|
|
|
* may add additional information in arbitrary positions. Array values are arrays with one
|
|
|
|
|
* element to be rendered as a header, arrays with two elements to be rendered as a table row.
|
2012-10-07 23:35:26 +00:00
|
|
|
*
|
|
|
|
|
* @return array
|
2012-10-05 03:45:45 +00:00
|
|
|
*/
|
2012-10-07 13:37:00 +00:00
|
|
|
protected function pageInfo() {
|
2015-04-27 22:49:11 +00:00
|
|
|
global $wgContLang;
|
2011-06-20 18:55:17 +00:00
|
|
|
|
2012-08-19 21:06:43 +00:00
|
|
|
$user = $this->getUser();
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$lang = $this->getLanguage();
|
|
|
|
|
$title = $this->getTitle();
|
|
|
|
|
$id = $title->getArticleID();
|
2014-08-13 02:45:55 +00:00
|
|
|
$config = $this->context->getConfig();
|
2016-09-09 00:08:21 +00:00
|
|
|
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
2011-06-20 18:55:17 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
$pageCounts = $this->pageCounts( $this->page );
|
2012-07-17 21:53:17 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageProperties = [];
|
2016-02-14 21:58:46 +00:00
|
|
|
$props = PageProps::getInstance()->getAllProperties( $title );
|
2016-01-12 04:29:48 +00:00
|
|
|
if ( isset( $props[$id] ) ) {
|
|
|
|
|
$pageProperties = $props[$id];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Basic information
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo = [];
|
|
|
|
|
$pageInfo['header-basic'] = [];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Display title
|
|
|
|
|
$displayTitle = $title->getPrefixedText();
|
2015-06-24 20:27:25 +00:00
|
|
|
if ( isset( $pageProperties['displaytitle'] ) ) {
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$displayTitle = $pageProperties['displaytitle'];
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2012-10-05 03:45:45 +00:00
|
|
|
$this->msg( 'pageinfo-display-title' ), $displayTitle
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-10-07 23:26:42 +00:00
|
|
|
// Is it a redirect? If so, where to?
|
|
|
|
|
if ( $title->isRedirect() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2012-10-07 23:26:42 +00:00
|
|
|
$this->msg( 'pageinfo-redirectsto' ),
|
2016-11-30 01:07:37 +00:00
|
|
|
$linkRenderer->makeLink( $this->page->getRedirectTarget() ) .
|
2015-01-30 17:08:10 +00:00
|
|
|
$this->msg( 'word-separator' )->escaped() .
|
2016-11-30 01:07:37 +00:00
|
|
|
$this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
|
2012-10-07 23:26:42 +00:00
|
|
|
$this->page->getRedirectTarget(),
|
2016-11-30 01:07:37 +00:00
|
|
|
$this->msg( 'pageinfo-redirectsto-info' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[ 'action' => 'info' ]
|
2015-01-30 17:08:10 +00:00
|
|
|
) )->escaped()
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-10-07 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Default sort key
|
2013-03-28 10:30:06 +00:00
|
|
|
$sortKey = $title->getCategorySortkey();
|
2015-06-24 20:27:25 +00:00
|
|
|
if ( isset( $pageProperties['defaultsort'] ) ) {
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$sortKey = $pageProperties['defaultsort'];
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 05:39:57 +00:00
|
|
|
$sortKey = htmlspecialchars( $sortKey );
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
|
2012-07-17 21:53:17 +00:00
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Page length (in bytes)
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2012-10-05 03:45:45 +00:00
|
|
|
$this->msg( 'pageinfo-length' ), $lang->formatNum( $title->getLength() )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-10-05 03:45:45 +00:00
|
|
|
// Page ID (number not localised, as it's a database ID)
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-article-id' ), $id ];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-10-25 23:07:42 +00:00
|
|
|
// Language in which the page content is (supposed to be) written
|
|
|
|
|
$pageLang = $title->getPageLanguage()->getCode();
|
2014-05-25 14:38:50 +00:00
|
|
|
|
2016-12-16 19:57:06 +00:00
|
|
|
$pageLangHtml = $pageLang . ' - ' .
|
|
|
|
|
Language::fetchLanguageName( $pageLang, $lang->getCode() );
|
|
|
|
|
// Link to Special:PageLanguage with pre-filled page title if user has permissions
|
2015-01-28 18:16:44 +00:00
|
|
|
if ( $config->get( 'PageLanguageUseDB' )
|
2016-10-29 18:06:15 +00:00
|
|
|
&& $title->userCan( 'pagelang', $user )
|
2015-01-28 18:16:44 +00:00
|
|
|
) {
|
2016-12-16 19:57:06 +00:00
|
|
|
$pageLangHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
|
|
|
|
|
SpecialPage::getTitleValueFor( 'PageLanguage', $title->getPrefixedText() ),
|
|
|
|
|
$this->msg( 'pageinfo-language-change' )->text()
|
|
|
|
|
) )->escaped();
|
2014-05-25 14:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 19:57:06 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
|
|
|
|
$this->msg( 'pageinfo-language' )->escaped(),
|
|
|
|
|
$pageLangHtml
|
|
|
|
|
];
|
2012-10-25 23:07:42 +00:00
|
|
|
|
2013-11-10 06:39:27 +00:00
|
|
|
// Content model of the page
|
2016-09-09 00:08:21 +00:00
|
|
|
$modelHtml = htmlspecialchars( ContentHandler::getLocalizedName( $title->getContentModel() ) );
|
|
|
|
|
// If the user can change it, add a link to Special:ChangeContentModel
|
2016-10-29 18:06:15 +00:00
|
|
|
if ( $config->get( 'ContentHandlerUseDB' )
|
|
|
|
|
&& $title->userCan( 'editcontentmodel', $user )
|
|
|
|
|
) {
|
2016-09-09 00:08:21 +00:00
|
|
|
$modelHtml .= ' ' . $this->msg( 'parentheses' )->rawParams( $linkRenderer->makeLink(
|
|
|
|
|
SpecialPage::getTitleValueFor( 'ChangeContentModel', $title->getPrefixedText() ),
|
|
|
|
|
$this->msg( 'pageinfo-content-model-change' )->text()
|
|
|
|
|
) )->escaped();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2013-11-10 06:39:27 +00:00
|
|
|
$this->msg( 'pageinfo-content-model' ),
|
2016-09-09 00:08:21 +00:00
|
|
|
$modelHtml
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2013-11-10 06:39:27 +00:00
|
|
|
|
2016-10-20 22:23:13 +00:00
|
|
|
if ( $title->inNamespace( NS_USER ) ) {
|
|
|
|
|
$pageUser = User::newFromName( $title->getRootText() );
|
|
|
|
|
if ( $pageUser && $pageUser->getId() && !$pageUser->isHidden() ) {
|
|
|
|
|
$pageInfo['header-basic'][] = [
|
|
|
|
|
$this->msg( 'pageinfo-user-id' ),
|
|
|
|
|
$pageUser->getId()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Search engine status
|
|
|
|
|
$pOutput = new ParserOutput();
|
|
|
|
|
if ( isset( $pageProperties['noindex'] ) ) {
|
|
|
|
|
$pOutput->setIndexPolicy( 'noindex' );
|
|
|
|
|
}
|
2014-02-14 14:21:12 +00:00
|
|
|
if ( isset( $pageProperties['index'] ) ) {
|
|
|
|
|
$pOutput->setIndexPolicy( 'index' );
|
|
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Use robot policy logic
|
2012-08-19 21:06:43 +00:00
|
|
|
$policy = $this->page->getRobotPolicy( 'view', $pOutput );
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: pageinfo-robot-index, pageinfo-robot-noindex
|
2015-10-04 19:22:19 +00:00
|
|
|
$this->msg( 'pageinfo-robot-policy' ),
|
|
|
|
|
$this->msg( "pageinfo-robot-${policy['index']}" )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2014-08-13 02:45:55 +00:00
|
|
|
$unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' );
|
2012-10-08 04:04:07 +00:00
|
|
|
if (
|
|
|
|
|
$user->isAllowed( 'unwatchedpages' ) ||
|
2014-08-13 02:45:55 +00:00
|
|
|
( $unwatchedPageThreshold !== false &&
|
|
|
|
|
$pageCounts['watchers'] >= $unwatchedPageThreshold )
|
2012-10-08 04:04:07 +00:00
|
|
|
) {
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Number of page watchers
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2015-03-02 16:16:58 +00:00
|
|
|
$this->msg( 'pageinfo-watchers' ),
|
|
|
|
|
$lang->formatNum( $pageCounts['watchers'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2015-07-01 12:27:55 +00:00
|
|
|
if (
|
|
|
|
|
$config->get( 'ShowUpdatedMarker' ) &&
|
|
|
|
|
isset( $pageCounts['visitingWatchers'] )
|
|
|
|
|
) {
|
2015-03-02 16:16:58 +00:00
|
|
|
$minToDisclose = $config->get( 'UnwatchedPageSecret' );
|
|
|
|
|
if ( $pageCounts['visitingWatchers'] > $minToDisclose ||
|
|
|
|
|
$user->isAllowed( 'unwatchedpages' ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2015-03-02 16:16:58 +00:00
|
|
|
$this->msg( 'pageinfo-visiting-watchers' ),
|
|
|
|
|
$lang->formatNum( $pageCounts['visitingWatchers'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2015-03-02 16:16:58 +00:00
|
|
|
} else {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2015-03-02 16:16:58 +00:00
|
|
|
$this->msg( 'pageinfo-visiting-watchers' ),
|
|
|
|
|
$this->msg( 'pageinfo-few-visiting-watchers' )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2015-03-02 16:16:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-08-13 02:45:55 +00:00
|
|
|
} elseif ( $unwatchedPageThreshold !== false ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2013-01-29 03:13:16 +00:00
|
|
|
$this->msg( 'pageinfo-watchers' ),
|
2014-08-13 02:45:55 +00:00
|
|
|
$this->msg( 'pageinfo-few-watchers' )->numParams( $unwatchedPageThreshold )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-07-17 21:53:17 +00:00
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Redirects to this page
|
2012-08-20 07:55:36 +00:00
|
|
|
$whatLinksHere = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2016-11-30 01:07:37 +00:00
|
|
|
$linkRenderer->makeLink(
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$whatLinksHere,
|
2016-11-30 01:07:37 +00:00
|
|
|
$this->msg( 'pageinfo-redirects-name' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2014-12-10 01:29:14 +00:00
|
|
|
'hidelinks' => 1,
|
|
|
|
|
'hidetrans' => 1,
|
|
|
|
|
'hideimages' => $title->getNamespace() == NS_FILE
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
),
|
2012-08-20 08:25:40 +00:00
|
|
|
$this->msg( 'pageinfo-redirects-value' )
|
2012-10-05 03:45:45 +00:00
|
|
|
->numParams( count( $title->getRedirectsHere() ) )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-10-07 23:26:42 +00:00
|
|
|
// Is it counted as a content page?
|
|
|
|
|
if ( $this->page->isCountable() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2012-10-07 23:26:42 +00:00
|
|
|
$this->msg( 'pageinfo-contentpage' ),
|
|
|
|
|
$this->msg( 'pageinfo-contentpage-yes' )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-10-07 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-15 00:02:16 +00:00
|
|
|
// Subpages of this page, if subpages are enabled for the current NS
|
|
|
|
|
if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
|
2015-10-04 19:22:19 +00:00
|
|
|
$prefixIndex = SpecialPage::getTitleFor(
|
|
|
|
|
'Prefixindex', $title->getPrefixedText() . '/' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-basic'][] = [
|
2017-06-17 19:37:04 +00:00
|
|
|
$linkRenderer->makeLink(
|
|
|
|
|
$prefixIndex,
|
|
|
|
|
$this->msg( 'pageinfo-subpages-name' )->text()
|
|
|
|
|
),
|
2012-09-15 00:02:16 +00:00
|
|
|
$this->msg( 'pageinfo-subpages-value' )
|
|
|
|
|
->numParams(
|
2012-10-05 03:45:45 +00:00
|
|
|
$pageCounts['subpages']['total'],
|
|
|
|
|
$pageCounts['subpages']['redirects'],
|
|
|
|
|
$pageCounts['subpages']['nonredirects'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-09-15 00:02:16 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-11-02 20:45:49 +00:00
|
|
|
if ( $title->inNamespace( NS_CATEGORY ) ) {
|
|
|
|
|
$category = Category::newFromTitle( $title );
|
2015-04-16 18:26:27 +00:00
|
|
|
|
|
|
|
|
// $allCount is the total number of cat members,
|
|
|
|
|
// not the count of how many members are normal pages.
|
|
|
|
|
$allCount = (int)$category->getPageCount();
|
|
|
|
|
$subcatCount = (int)$category->getSubcatCount();
|
|
|
|
|
$fileCount = (int)$category->getFileCount();
|
|
|
|
|
$pagesCount = $allCount - $subcatCount - $fileCount;
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['category-info'] = [
|
|
|
|
|
[
|
2015-04-16 18:26:27 +00:00
|
|
|
$this->msg( 'pageinfo-category-total' ),
|
|
|
|
|
$lang->formatNum( $allCount )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2012-11-02 20:45:49 +00:00
|
|
|
$this->msg( 'pageinfo-category-pages' ),
|
2015-04-16 18:26:27 +00:00
|
|
|
$lang->formatNum( $pagesCount )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2012-11-02 20:45:49 +00:00
|
|
|
$this->msg( 'pageinfo-category-subcats' ),
|
2015-04-16 18:26:27 +00:00
|
|
|
$lang->formatNum( $subcatCount )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2012-11-02 20:45:49 +00:00
|
|
|
$this->msg( 'pageinfo-category-files' ),
|
2015-04-16 18:26:27 +00:00
|
|
|
$lang->formatNum( $fileCount )
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
];
|
2012-11-02 20:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Page protection
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-restrictions'] = [];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2014-12-12 08:41:27 +00:00
|
|
|
// Is this page affected by the cascading protection of something which includes it?
|
2012-10-06 22:32:45 +00:00
|
|
|
if ( $title->isCascadeProtected() ) {
|
|
|
|
|
$cascadingFrom = '';
|
2016-02-11 14:57:48 +00:00
|
|
|
$sources = $title->getCascadeProtectionSources()[0];
|
2012-10-06 22:32:45 +00:00
|
|
|
|
2016-02-11 14:57:48 +00:00
|
|
|
foreach ( $sources as $sourceTitle ) {
|
2015-10-04 19:22:19 +00:00
|
|
|
$cascadingFrom .= Html::rawElement(
|
2016-11-30 01:07:37 +00:00
|
|
|
'li', [], $linkRenderer->makeKnownLink( $sourceTitle ) );
|
2012-10-06 22:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$cascadingFrom = Html::rawElement( 'ul', [], $cascadingFrom );
|
|
|
|
|
$pageInfo['header-restrictions'][] = [
|
2012-10-06 22:32:45 +00:00
|
|
|
$this->msg( 'pageinfo-protect-cascading-from' ),
|
|
|
|
|
$cascadingFrom
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-10-06 22:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Is out protection set to cascade to other pages?
|
|
|
|
|
if ( $title->areRestrictionsCascading() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-restrictions'][] = [
|
2012-10-06 22:32:45 +00:00
|
|
|
$this->msg( 'pageinfo-protect-cascading' ),
|
|
|
|
|
$this->msg( 'pageinfo-protect-cascading-yes' )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-10-06 22:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Page protection
|
2012-09-04 13:02:32 +00:00
|
|
|
foreach ( $title->getRestrictionTypes() as $restrictionType ) {
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
|
2012-09-04 13:02:32 +00:00
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
if ( $protectionLevel == '' ) {
|
|
|
|
|
// Allow all users
|
2012-08-20 08:25:40 +00:00
|
|
|
$message = $this->msg( 'protect-default' )->escaped();
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
} else {
|
|
|
|
|
// Administrators only
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: protect-level-autoconfirmed, protect-level-sysop
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
$message = $this->msg( "protect-level-$protectionLevel" );
|
2012-08-20 08:25:40 +00:00
|
|
|
if ( $message->isDisabled() ) {
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Require "$1" permission
|
2012-08-20 16:41:58 +00:00
|
|
|
$message = $this->msg( "protect-fallback", $protectionLevel )->parse();
|
2012-08-20 08:25:40 +00:00
|
|
|
} else {
|
|
|
|
|
$message = $message->escaped();
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-03-31 09:00:01 +00:00
|
|
|
$expiry = $title->getRestrictionExpiry( $restrictionType );
|
2015-06-26 05:32:28 +00:00
|
|
|
$formattedexpiry = $this->msg( 'parentheses',
|
2016-10-29 18:06:15 +00:00
|
|
|
$lang->formatExpiry( $expiry ) )->escaped();
|
2015-03-31 09:00:01 +00:00
|
|
|
$message .= $this->msg( 'word-separator' )->escaped() . $formattedexpiry;
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: restriction-edit, restriction-move, restriction-create,
|
|
|
|
|
// restriction-upload
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-restrictions'][] = [
|
2012-10-05 03:45:45 +00:00
|
|
|
$this->msg( "restriction-$restrictionType" ), $message
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-06 03:17:41 +00:00
|
|
|
if ( !$this->page->exists() ) {
|
|
|
|
|
return $pageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Edit history
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'] = [];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-09-18 00:10:48 +00:00
|
|
|
$firstRev = $this->page->getOldestRevision();
|
2013-01-21 06:52:43 +00:00
|
|
|
$lastRev = $this->page->getRevision();
|
|
|
|
|
$batch = new LinkBatch;
|
|
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
if ( $firstRev ) {
|
|
|
|
|
$firstRevUser = $firstRev->getUserText( Revision::FOR_THIS_USER );
|
|
|
|
|
if ( $firstRevUser !== '' ) {
|
2016-06-06 21:59:23 +00:00
|
|
|
$firstRevUserTitle = Title::makeTitle( NS_USER, $firstRevUser );
|
|
|
|
|
$batch->addObj( $firstRevUserTitle );
|
|
|
|
|
$batch->addObj( $firstRevUserTitle->getTalkPage() );
|
2013-02-14 10:08:57 +00:00
|
|
|
}
|
2013-01-21 06:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
if ( $lastRev ) {
|
|
|
|
|
$lastRevUser = $lastRev->getUserText( Revision::FOR_THIS_USER );
|
|
|
|
|
if ( $lastRevUser !== '' ) {
|
2016-06-06 21:59:23 +00:00
|
|
|
$lastRevUserTitle = Title::makeTitle( NS_USER, $lastRevUser );
|
|
|
|
|
$batch->addObj( $lastRevUserTitle );
|
|
|
|
|
$batch->addObj( $lastRevUserTitle->getTalkPage() );
|
2013-02-14 10:08:57 +00:00
|
|
|
}
|
2013-01-21 06:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$batch->execute();
|
2012-09-18 00:10:48 +00:00
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
if ( $firstRev ) {
|
|
|
|
|
// Page creator
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2013-02-14 10:08:57 +00:00
|
|
|
$this->msg( 'pageinfo-firstuser' ),
|
|
|
|
|
Linker::revUserTools( $firstRev )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
// Date of page creation
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2013-02-14 10:08:57 +00:00
|
|
|
$this->msg( 'pageinfo-firsttime' ),
|
2016-11-30 01:07:37 +00:00
|
|
|
$linkRenderer->makeKnownLink(
|
2013-02-14 10:08:57 +00:00
|
|
|
$title,
|
2016-11-30 01:07:37 +00:00
|
|
|
$lang->userTimeAndDate( $firstRev->getTimestamp(), $user ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[ 'oldid' => $firstRev->getId() ]
|
2013-02-14 10:08:57 +00:00
|
|
|
)
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2013-02-14 10:08:57 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
if ( $lastRev ) {
|
|
|
|
|
// Latest editor
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2013-02-14 10:08:57 +00:00
|
|
|
$this->msg( 'pageinfo-lastuser' ),
|
|
|
|
|
Linker::revUserTools( $lastRev )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2013-02-14 10:08:57 +00:00
|
|
|
// Date of latest edit
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2013-02-14 10:08:57 +00:00
|
|
|
$this->msg( 'pageinfo-lasttime' ),
|
2016-11-30 01:07:37 +00:00
|
|
|
$linkRenderer->makeKnownLink(
|
2013-02-14 10:08:57 +00:00
|
|
|
$title,
|
2016-11-30 01:07:37 +00:00
|
|
|
$lang->userTimeAndDate( $this->page->getTimestamp(), $user ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[ 'oldid' => $this->page->getLatest() ]
|
2013-02-14 10:08:57 +00:00
|
|
|
)
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2013-02-14 10:08:57 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Total number of edits
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2012-10-05 03:45:45 +00:00
|
|
|
$this->msg( 'pageinfo-edits' ), $lang->formatNum( $pageCounts['edits'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Total number of distinct authors
|
2015-09-25 06:55:16 +00:00
|
|
|
if ( $pageCounts['authors'] > 0 ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2015-09-25 06:55:16 +00:00
|
|
|
$this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2015-09-25 06:55:16 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Recent number of edits (within past 30 days)
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2015-10-04 19:22:19 +00:00
|
|
|
$this->msg( 'pageinfo-recent-edits',
|
|
|
|
|
$lang->formatDuration( $config->get( 'RCMaxAge' ) ) ),
|
2012-10-05 03:45:45 +00:00
|
|
|
$lang->formatNum( $pageCounts['recent_edits'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Recent number of distinct authors
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-edits'][] = [
|
2015-10-04 19:22:19 +00:00
|
|
|
$this->msg( 'pageinfo-recent-authors' ),
|
|
|
|
|
$lang->formatNum( $pageCounts['recent_authors'] )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Array of MagicWord objects
|
|
|
|
|
$magicWords = MagicWord::getDoubleUnderscoreArray();
|
|
|
|
|
|
|
|
|
|
// Array of magic word IDs
|
|
|
|
|
$wordIDs = $magicWords->names;
|
|
|
|
|
|
|
|
|
|
// Array of IDs => localized magic words
|
2012-08-20 16:56:51 +00:00
|
|
|
$localizedWords = $wgContLang->getMagicWords();
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$listItems = [];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
foreach ( $pageProperties as $property => $value ) {
|
|
|
|
|
if ( in_array( $property, $wordIDs ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$listItems[] = Html::element( 'li', [], $localizedWords[$property][1] );
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$localizedList = Html::rawElement( 'ul', [], implode( '', $listItems ) );
|
2012-08-19 21:06:43 +00:00
|
|
|
$hiddenCategories = $this->page->getHiddenCategories();
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-11-02 20:15:37 +00:00
|
|
|
if (
|
|
|
|
|
count( $listItems ) > 0 ||
|
|
|
|
|
count( $hiddenCategories ) > 0 ||
|
|
|
|
|
$pageCounts['transclusion']['from'] > 0 ||
|
|
|
|
|
$pageCounts['transclusion']['to'] > 0
|
|
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$options = [ 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ];
|
2012-11-02 20:15:37 +00:00
|
|
|
$transcludedTemplates = $title->getTemplateLinksFrom( $options );
|
2014-08-13 02:45:55 +00:00
|
|
|
if ( $config->get( 'MiserMode' ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$transcludedTargets = [];
|
2014-01-16 20:39:33 +00:00
|
|
|
} else {
|
|
|
|
|
$transcludedTargets = $title->getTemplateLinksTo( $options );
|
|
|
|
|
}
|
2012-11-02 20:15:37 +00:00
|
|
|
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
// Page properties
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-properties'] = [];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
// Magic words
|
|
|
|
|
if ( count( $listItems ) > 0 ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-properties'][] = [
|
2012-10-05 03:45:45 +00:00
|
|
|
$this->msg( 'pageinfo-magic-words' )->numParams( count( $listItems ) ),
|
2012-08-20 08:25:40 +00:00
|
|
|
$localizedList
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hidden categories
|
|
|
|
|
if ( count( $hiddenCategories ) > 0 ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-properties'][] = [
|
2012-08-20 08:25:40 +00:00
|
|
|
$this->msg( 'pageinfo-hidden-categories' )
|
2012-10-05 03:45:45 +00:00
|
|
|
->numParams( count( $hiddenCategories ) ),
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
Linker::formatHiddenCategories( $hiddenCategories )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Transcluded templates
|
2012-11-02 20:15:37 +00:00
|
|
|
if ( $pageCounts['transclusion']['from'] > 0 ) {
|
|
|
|
|
if ( $pageCounts['transclusion']['from'] > count( $transcludedTemplates ) ) {
|
|
|
|
|
$more = $this->msg( 'morenotlisted' )->escaped();
|
|
|
|
|
} else {
|
|
|
|
|
$more = null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 05:56:07 +00:00
|
|
|
$templateListFormatter = new TemplatesOnThisPageFormatter(
|
|
|
|
|
$this->getContext(),
|
|
|
|
|
$linkRenderer
|
|
|
|
|
);
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-properties'][] = [
|
2012-08-20 08:25:40 +00:00
|
|
|
$this->msg( 'pageinfo-templates' )
|
2012-11-02 20:15:37 +00:00
|
|
|
->numParams( $pageCounts['transclusion']['from'] ),
|
2016-09-09 05:56:07 +00:00
|
|
|
$templateListFormatter->format( $transcludedTemplates, false, $more )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-11-02 20:15:37 +00:00
|
|
|
}
|
|
|
|
|
|
2014-08-13 02:45:55 +00:00
|
|
|
if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
|
2012-11-02 20:15:37 +00:00
|
|
|
if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
|
2016-11-30 01:07:37 +00:00
|
|
|
$more = $linkRenderer->makeLink(
|
2012-11-02 20:15:37 +00:00
|
|
|
$whatLinksHere,
|
2016-11-30 01:07:37 +00:00
|
|
|
$this->msg( 'moredotdotdot' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[ 'hidelinks' => 1, 'hideredirs' => 1 ]
|
2012-11-02 20:15:37 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$more = null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 05:56:07 +00:00
|
|
|
$templateListFormatter = new TemplatesOnThisPageFormatter(
|
|
|
|
|
$this->getContext(),
|
|
|
|
|
$linkRenderer
|
|
|
|
|
);
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$pageInfo['header-properties'][] = [
|
2012-11-02 20:15:37 +00:00
|
|
|
$this->msg( 'pageinfo-transclusions' )
|
|
|
|
|
->numParams( $pageCounts['transclusion']['to'] ),
|
2016-09-09 05:56:07 +00:00
|
|
|
$templateListFormatter->format( $transcludedTargets, false, $more )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
}
|
2012-07-17 21:53:17 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2012-10-05 03:45:45 +00:00
|
|
|
return $pageInfo;
|
2012-09-04 13:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-20 18:55:17 +00:00
|
|
|
/**
|
2012-10-05 03:45:45 +00:00
|
|
|
* Returns page counts that would be too "expensive" to retrieve by normal means.
|
2011-06-20 18:55:17 +00:00
|
|
|
*
|
2015-09-30 18:24:31 +00:00
|
|
|
* @param WikiPage|Article|Page $page
|
2012-07-17 21:53:17 +00:00
|
|
|
* @return array
|
2011-06-20 18:55:17 +00:00
|
|
|
*/
|
2015-09-30 18:24:31 +00:00
|
|
|
protected function pageCounts( Page $page ) {
|
|
|
|
|
$fname = __METHOD__;
|
2014-08-13 02:45:55 +00:00
|
|
|
$config = $this->context->getConfig();
|
2017-05-24 03:36:53 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
2011-06-20 18:55:17 +00:00
|
|
|
|
2017-05-24 03:36:53 +00:00
|
|
|
return $cache->getWithSetCallback(
|
|
|
|
|
self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
|
2016-08-12 19:36:37 +00:00
|
|
|
WANObjectCache::TTL_WEEK,
|
2015-09-30 18:24:31 +00:00
|
|
|
function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
|
|
|
|
|
$title = $page->getTitle();
|
|
|
|
|
$id = $title->getArticleID();
|
|
|
|
|
|
2016-09-05 19:55:19 +00:00
|
|
|
$dbr = wfGetDB( DB_REPLICA );
|
|
|
|
|
$dbrWatchlist = wfGetDB( DB_REPLICA, 'watchlist' );
|
2015-10-06 05:06:46 +00:00
|
|
|
$setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist );
|
2015-10-01 02:40:09 +00:00
|
|
|
|
2016-04-15 16:29:05 +00:00
|
|
|
$watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
|
2016-02-05 12:04:58 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$result = [];
|
2016-02-05 12:04:58 +00:00
|
|
|
$result['watchers'] = $watchedItemStore->countWatchers( $title );
|
2015-09-30 18:24:31 +00:00
|
|
|
|
|
|
|
|
if ( $config->get( 'ShowUpdatedMarker' ) ) {
|
|
|
|
|
$updated = wfTimestamp( TS_UNIX, $page->getTimestamp() );
|
2016-02-05 12:04:58 +00:00
|
|
|
$result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
|
|
|
|
|
$title,
|
|
|
|
|
$updated - $config->get( 'WatchersMaxAge' )
|
2015-09-30 18:24:31 +00:00
|
|
|
);
|
|
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Total number of edits
|
|
|
|
|
$edits = (int)$dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'COUNT(*)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_page' => $id ],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
$result['edits'] = $edits;
|
2015-03-02 16:16:58 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Total number of distinct authors
|
|
|
|
|
if ( $config->get( 'MiserMode' ) ) {
|
|
|
|
|
$result['authors'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$result['authors'] = (int)$dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'COUNT(DISTINCT rev_user_text)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_page' => $id ],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
}
|
2011-06-20 18:55:17 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// "Recent" threshold defined by RCMaxAge setting
|
|
|
|
|
$threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
|
|
|
|
|
|
|
|
|
|
// Recent number of edits
|
|
|
|
|
$edits = (int)$dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'COUNT(rev_page)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-09-30 18:24:31 +00:00
|
|
|
'rev_page' => $id,
|
|
|
|
|
"rev_timestamp >= " . $dbr->addQuotes( $threshold )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
$result['recent_edits'] = $edits;
|
|
|
|
|
|
|
|
|
|
// Recent number of distinct authors
|
|
|
|
|
$result['recent_authors'] = (int)$dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'COUNT(DISTINCT rev_user_text)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-09-30 18:24:31 +00:00
|
|
|
'rev_page' => $id,
|
|
|
|
|
"rev_timestamp >= " . $dbr->addQuotes( $threshold )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
2011-06-20 18:55:17 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Subpages (if enabled)
|
|
|
|
|
if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$conds = [ 'page_namespace' => $title->getNamespace() ];
|
2015-09-30 18:24:31 +00:00
|
|
|
$conds[] = 'page_title ' .
|
|
|
|
|
$dbr->buildLike( $title->getDBkey() . '/', $dbr->anyString() );
|
|
|
|
|
|
|
|
|
|
// Subpages of this page (redirects)
|
|
|
|
|
$conds['page_is_redirect'] = 1;
|
|
|
|
|
$result['subpages']['redirects'] = (int)$dbr->selectField(
|
|
|
|
|
'page',
|
|
|
|
|
'COUNT(page_id)',
|
|
|
|
|
$conds,
|
|
|
|
|
$fname
|
|
|
|
|
);
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Subpages of this page (non-redirects)
|
|
|
|
|
$conds['page_is_redirect'] = 0;
|
|
|
|
|
$result['subpages']['nonredirects'] = (int)$dbr->selectField(
|
|
|
|
|
'page',
|
|
|
|
|
'COUNT(page_id)',
|
|
|
|
|
$conds,
|
|
|
|
|
$fname
|
|
|
|
|
);
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Subpages of this page (total)
|
|
|
|
|
$result['subpages']['total'] = $result['subpages']['redirects']
|
|
|
|
|
+ $result['subpages']['nonredirects'];
|
|
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
// Counts for the number of transclusion links (to/from)
|
|
|
|
|
if ( $config->get( 'MiserMode' ) ) {
|
|
|
|
|
$result['transclusion']['to'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$result['transclusion']['to'] = (int)$dbr->selectField(
|
|
|
|
|
'templatelinks',
|
|
|
|
|
'COUNT(tl_from)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-09-30 18:24:31 +00:00
|
|
|
'tl_namespace' => $title->getNamespace(),
|
|
|
|
|
'tl_title' => $title->getDBkey()
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
}
|
2012-09-15 00:02:16 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
$result['transclusion']['from'] = (int)$dbr->selectField(
|
|
|
|
|
'templatelinks',
|
|
|
|
|
'COUNT(*)',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'tl_from' => $title->getArticleID() ],
|
2015-09-30 18:24:31 +00:00
|
|
|
$fname
|
|
|
|
|
);
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
2015-09-30 18:24:31 +00:00
|
|
|
return $result;
|
2015-10-08 02:27:08 +00:00
|
|
|
}
|
2012-11-02 20:15:37 +00:00
|
|
|
);
|
2011-06-20 18:55:17 +00:00
|
|
|
}
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-10-22 10:29:52 +00:00
|
|
|
* Returns the name that goes in the "<h1>" page title.
|
Bug 38450 Reimplement MediaWiki's info action
Currently addresses: bug 38526, bug 38527, bug 38528, bug 38529, bug
38530, bug 38531, bug 38532, bug 38533, bug 38536, bug 38558, bug 38560,
bug 38561, bug 38562, bug 38563, bug 38564.
Change-Id: Ia1878588f718e99756caf23ae9c5a131eb70bf12
2012-08-03 23:19:01 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function getPageTitle() {
|
|
|
|
|
return $this->msg( 'pageinfo-title', $this->getTitle()->getPrefixedText() )->text();
|
|
|
|
|
}
|
2012-09-04 13:02:32 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a list of contributors of $article
|
2014-04-10 18:50:10 +00:00
|
|
|
* @return string Html
|
2012-09-04 13:02:32 +00:00
|
|
|
*/
|
|
|
|
|
protected function getContributors() {
|
|
|
|
|
$contributors = $this->page->getContributors();
|
2016-02-17 09:09:32 +00:00
|
|
|
$real_names = [];
|
|
|
|
|
$user_names = [];
|
|
|
|
|
$anon_ips = [];
|
2017-02-12 02:12:42 +00:00
|
|
|
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
2012-09-04 13:02:32 +00:00
|
|
|
|
|
|
|
|
# Sift for real versus user names
|
2013-11-14 12:08:14 +00:00
|
|
|
/** @var $user User */
|
2012-09-04 13:02:32 +00:00
|
|
|
foreach ( $contributors as $user ) {
|
|
|
|
|
$page = $user->isAnon()
|
|
|
|
|
? SpecialPage::getTitleFor( 'Contributions', $user->getName() )
|
|
|
|
|
: $user->getUserPage();
|
|
|
|
|
|
2014-08-13 02:45:55 +00:00
|
|
|
$hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' );
|
2016-03-19 00:08:06 +00:00
|
|
|
if ( $user->getId() == 0 ) {
|
2016-11-30 01:07:37 +00:00
|
|
|
$anon_ips[] = $linkRenderer->makeLink( $page, $user->getName() );
|
2014-08-13 02:45:55 +00:00
|
|
|
} elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) {
|
2016-11-30 01:07:37 +00:00
|
|
|
$real_names[] = $linkRenderer->makeLink( $page, $user->getRealName() );
|
2012-09-04 13:02:32 +00:00
|
|
|
} else {
|
2016-11-30 01:07:37 +00:00
|
|
|
$user_names[] = $linkRenderer->makeLink( $page, $user->getName() );
|
2012-09-04 13:02:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lang = $this->getLanguage();
|
|
|
|
|
|
|
|
|
|
$real = $lang->listToText( $real_names );
|
|
|
|
|
|
|
|
|
|
# "ThisSite user(s) A, B and C"
|
|
|
|
|
if ( count( $user_names ) ) {
|
2015-10-04 19:22:19 +00:00
|
|
|
$user = $this->msg( 'siteusers' )
|
|
|
|
|
->rawParams( $lang->listToText( $user_names ) )
|
|
|
|
|
->params( count( $user_names ) )->escaped();
|
2012-09-04 13:02:32 +00:00
|
|
|
} else {
|
|
|
|
|
$user = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( count( $anon_ips ) ) {
|
2015-10-04 19:22:19 +00:00
|
|
|
$anon = $this->msg( 'anonusers' )
|
|
|
|
|
->rawParams( $lang->listToText( $anon_ips ) )
|
|
|
|
|
->params( count( $anon_ips ) )->escaped();
|
2012-09-04 13:02:32 +00:00
|
|
|
} else {
|
|
|
|
|
$anon = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# This is the big list, all mooshed together. We sift for blank strings
|
2016-02-17 09:09:32 +00:00
|
|
|
$fulllist = [];
|
|
|
|
|
foreach ( [ $real, $user, $anon ] as $s ) {
|
2012-09-04 13:02:32 +00:00
|
|
|
if ( $s !== '' ) {
|
|
|
|
|
array_push( $fulllist, $s );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$count = count( $fulllist );
|
2013-11-14 11:18:26 +00:00
|
|
|
|
2012-09-04 13:02:32 +00:00
|
|
|
# "Based on work by ..."
|
|
|
|
|
return $count
|
|
|
|
|
? $this->msg( 'othercontribs' )->rawParams(
|
|
|
|
|
$lang->listToText( $fulllist ) )->params( $count )->escaped()
|
|
|
|
|
: '';
|
|
|
|
|
}
|
2012-10-05 03:45:45 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-10-22 10:29:52 +00:00
|
|
|
* Returns the description that goes below the "<h1>" tag.
|
2012-10-05 03:45:45 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function getDescription() {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2015-09-30 18:24:31 +00:00
|
|
|
|
|
|
|
|
/**
|
2017-05-24 03:36:53 +00:00
|
|
|
* @param WANObjectCache $cache
|
2015-09-30 18:24:31 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @param int $revId
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2017-05-24 03:36:53 +00:00
|
|
|
protected static function getCacheKey( WANObjectCache $cache, Title $title, $revId ) {
|
|
|
|
|
return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
|
2015-09-30 18:24:31 +00:00
|
|
|
}
|
2011-06-20 18:55:17 +00:00
|
|
|
}
|