public function onView() {
$content = '';
+ // 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();
+ }
+ }
+
// Page header
if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) {
$content .= $this->msg( 'pageinfo-header' )->parse();
$pageInfo = $this->pageInfo();
// Allow extensions to add additional information
- wfRunHooks( 'InfoAction', array( &$pageInfo ) );
+ wfRunHooks( 'InfoAction', array( $this->getContext(), &$pageInfo ) );
// Render page information
foreach ( $pageInfo as $header => $infoTable ) {
* @return array
*/
protected function pageInfo() {
- global $wgContLang, $wgDisableCounters, $wgRCMaxAge;
+ global $wgContLang, $wgRCMaxAge;
$user = $this->getUser();
$lang = $this->getLanguage();
$id = $title->getArticleID();
// Get page information that would be too "expensive" to retrieve by normal means
- $userCanViewUnwatchedPages = $user->isAllowed( 'unwatchedpages' );
- $pageCounts = self::pageCounts( $title, $userCanViewUnwatchedPages, $wgDisableCounters );
+ $pageCounts = self::pageCounts( $title, $user );
// Get page properties
$dbr = wfGetDB( DB_SLAVE );
$this->msg( 'pageinfo-display-title' ), $displayTitle
);
+ // Is it a redirect? If so, where to?
+ if ( $title->isRedirect() ) {
+ $pageInfo['header-basic'][] = array(
+ $this->msg( 'pageinfo-redirectsto' ),
+ Linker::link( $this->page->getRedirectTarget() ) .
+ $this->msg( 'word-separator' )->text() .
+ $this->msg( 'parentheses', Linker::link(
+ $this->page->getRedirectTarget(),
+ $this->msg( 'pageinfo-redirectsto-info' )->escaped(),
+ array(),
+ array( 'action' => 'info' )
+ ) )->text()
+ );
+ }
+
// Default sort key
$sortKey = $title->getCategorySortKey();
if ( !empty( $pageProperties['defaultsort'] ) ) {
$this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
);
- if ( !$wgDisableCounters ) {
+ if ( isset( $pageCounts['views'] ) ) {
// Number of views
$pageInfo['header-basic'][] = array(
$this->msg( 'pageinfo-views' ), $lang->formatNum( $pageCounts['views'] )
);
}
- if ( $userCanViewUnwatchedPages ) {
+ if ( isset( $pageCounts['watchers'] ) ) {
// Number of page watchers
$pageInfo['header-basic'][] = array(
$this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] )
->numParams( count( $title->getRedirectsHere() ) )
);
+ // Is it counted as a content page?
+ if ( $this->page->isCountable() ) {
+ $pageInfo['header-basic'][] = array(
+ $this->msg( 'pageinfo-contentpage' ),
+ $this->msg( 'pageinfo-contentpage-yes' )
+ );
+ }
+
// Subpages of this page, if subpages are enabled for the current NS
if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {
$prefixIndex = SpecialPage::getTitleFor( 'Prefixindex', $title->getPrefixedText() . '/' );
// Page protection
$pageInfo['header-restrictions'] = array();
+ // Is this page effected by the cascading protection of something which includes it?
+ if ( $title->isCascadeProtected() ) {
+ $cascadingFrom = '';
+ $sources = $title->getCascadeProtectionSources(); // Array deferencing is in PHP 5.4 :(
+
+ foreach ( $sources[0] as $sourceTitle ) {
+ $cascadingFrom .= Html::rawElement( 'li', array(), Linker::linkKnown( $sourceTitle ) );
+ }
+
+ $cascadingFrom = Html::rawElement( 'ul', array(), $cascadingFrom );
+ $pageInfo['header-restrictions'][] = array(
+ $this->msg( 'pageinfo-protect-cascading-from' ),
+ $cascadingFrom
+ );
+ }
+
+ // Is out protection set to cascade to other pages?
+ if ( $title->areRestrictionsCascading() ) {
+ $pageInfo['header-restrictions'][] = array(
+ $this->msg( 'pageinfo-protect-cascading' ),
+ $this->msg( 'pageinfo-protect-cascading-yes' )
+ );
+ }
+
// Page protection
foreach ( $title->getRestrictionTypes() as $restrictionType ) {
$protectionLevel = implode( ', ', $title->getRestrictions( $restrictionType ) );
);
}
+ if ( !$this->page->exists() ) {
+ return $pageInfo;
+ }
+
// Edit history
$pageInfo['header-edits'] = array();
* Returns page counts that would be too "expensive" to retrieve by normal means.
*
* @param $title Title object
- * @param $canViewUnwatched bool
- * @param $disableCounter bool
+ * @param $user User object
* @return array
*/
- protected static function pageCounts( $title, $canViewUnwatched, $disableCounter ) {
- global $wgRCMaxAge;
+ protected static function pageCounts( $title, $user ) {
+ global $wgRCMaxAge, $wgDisableCounters;
wfProfileIn( __METHOD__ );
$id = $title->getArticleID();
$dbr = wfGetDB( DB_SLAVE );
$result = array();
- if ( !$disableCounter ) {
+ if ( !$wgDisableCounters ) {
// Number of views
$views = (int) $dbr->selectField(
'page',
$result['views'] = $views;
}
- if ( $canViewUnwatched ) {
+ if ( $user->isAllowed( 'unwatchedpages' ) ) {
// Number of page watchers
$watchers = (int) $dbr->selectField(
'watchlist',
}
/**
- * Returns the name that goes in the <h1> page title.
+ * Returns the name that goes in the "<h1>" page title.
*
* @return string
*/
}
/**
- * Returns the description that goes below the <h1> tag.
+ * Returns the description that goes below the "<h1>" tag.
*
* @return string
*/