From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/actions/InfoAction.php | 97 +++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 32 deletions(-) (limited to 'includes/actions/InfoAction.php') diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 0a16f4a8..f932a405 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -33,7 +33,7 @@ class InfoAction extends FormlessAction { /** * Returns the name of the action this object responds to. * - * @return string lowercase + * @return string Lowercase name */ public function getName() { return 'info'; @@ -153,6 +153,7 @@ class InfoAction extends FormlessAction { */ protected function makeHeader( $header ) { $spanAttribs = array( 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) ); + return Html::rawElement( 'h2', array(), Html::element( 'span', $spanAttribs, $header ) ); } @@ -192,13 +193,13 @@ class InfoAction extends FormlessAction { * @return array */ protected function pageInfo() { - global $wgContLang, $wgRCMaxAge, $wgMemc, - $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit; + global $wgContLang, $wgMemc; $user = $this->getUser(); $lang = $this->getLanguage(); $title = $this->getTitle(); $id = $title->getArticleID(); + $config = $this->context->getConfig(); $memcKey = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $this->page->getLatest() ); @@ -206,7 +207,7 @@ class InfoAction extends FormlessAction { $version = isset( $pageCounts['cacheversion'] ) ? $pageCounts['cacheversion'] : false; if ( $pageCounts === false || $version !== self::CACHE_VERSION ) { // Get page information that would be too "expensive" to retrieve by normal means - $pageCounts = self::pageCounts( $title ); + $pageCounts = $this->pageCounts( $title ); $pageCounts['cacheversion'] = self::CACHE_VERSION; $wgMemc->set( $memcKey, $pageCounts ); @@ -274,15 +275,37 @@ class InfoAction extends FormlessAction { // Language in which the page content is (supposed to be) written $pageLang = $title->getPageLanguage()->getCode(); - $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-language' ), + + if ( $config->get( 'PageLanguageUseDB' ) && $this->getTitle()->userCan( 'pagelang' ) ) { + // Link to Special:PageLanguage with pre-filled page title if user has permissions + $titleObj = SpecialPage::getTitleFor( 'PageLanguage', $title->getPrefixedText() ); + $langDisp = Linker::link( + $titleObj, + $this->msg( 'pageinfo-language' )->escaped() + ); + } else { + // Display just the message + $langDisp = $this->msg( 'pageinfo-language' )->escaped(); + } + + $pageInfo['header-basic'][] = array( $langDisp, Language::fetchLanguageName( $pageLang, $lang->getCode() ) . ' ' . $this->msg( 'parentheses', $pageLang ) ); + // Content model of the page + $pageInfo['header-basic'][] = array( + $this->msg( 'pageinfo-content-model' ), + ContentHandler::getLocalizedName( $title->getContentModel() ) + ); + // Search engine status $pOutput = new ParserOutput(); if ( isset( $pageProperties['noindex'] ) ) { $pOutput->setIndexPolicy( 'noindex' ); } + if ( isset( $pageProperties['index'] ) ) { + $pOutput->setIndexPolicy( 'index' ); + } // Use robot policy logic $policy = $this->page->getRobotPolicy( 'view', $pOutput ); @@ -298,19 +321,20 @@ class InfoAction extends FormlessAction { ); } + $unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' ); if ( $user->isAllowed( 'unwatchedpages' ) || - ( $wgUnwatchedPageThreshold !== false && - $pageCounts['watchers'] >= $wgUnwatchedPageThreshold ) + ( $unwatchedPageThreshold !== false && + $pageCounts['watchers'] >= $unwatchedPageThreshold ) ) { // Number of page watchers $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] ) ); - } elseif ( $wgUnwatchedPageThreshold !== false ) { + } elseif ( $unwatchedPageThreshold !== false ) { $pageInfo['header-basic'][] = array( $this->msg( 'pageinfo-watchers' ), - $this->msg( 'pageinfo-few-watchers' )->numParams( $wgUnwatchedPageThreshold ) + $this->msg( 'pageinfo-few-watchers' )->numParams( $unwatchedPageThreshold ) ); } @@ -498,7 +522,7 @@ class InfoAction extends FormlessAction { // Recent number of edits (within past 30 days) $pageInfo['header-edits'][] = array( - $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $wgRCMaxAge ) ), + $this->msg( 'pageinfo-recent-edits', $lang->formatDuration( $config->get( 'RCMaxAge' ) ) ), $lang->formatNum( $pageCounts['recent_edits'] ) ); @@ -532,9 +556,13 @@ class InfoAction extends FormlessAction { $pageCounts['transclusion']['from'] > 0 || $pageCounts['transclusion']['to'] > 0 ) { - $options = array( 'LIMIT' => $wgPageInfoTransclusionLimit ); + $options = array( 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) ); $transcludedTemplates = $title->getTemplateLinksFrom( $options ); - $transcludedTargets = $title->getTemplateLinksTo( $options ); + if ( $config->get( 'MiserMode' ) ) { + $transcludedTargets = array(); + } else { + $transcludedTargets = $title->getTemplateLinksTo( $options ); + } // Page properties $pageInfo['header-properties'] = array(); @@ -575,7 +603,7 @@ class InfoAction extends FormlessAction { ); } - if ( $pageCounts['transclusion']['to'] > 0 ) { + if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) { if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) { $more = Linker::link( $whatLinksHere, @@ -608,16 +636,15 @@ class InfoAction extends FormlessAction { * @param Title $title Title to get counts for * @return array */ - protected static function pageCounts( Title $title ) { - global $wgRCMaxAge, $wgDisableCounters; - + protected function pageCounts( Title $title ) { wfProfileIn( __METHOD__ ); $id = $title->getArticleID(); + $config = $this->context->getConfig(); $dbr = wfGetDB( DB_SLAVE ); $result = array(); - if ( !$wgDisableCounters ) { + if ( !$config->get( 'DisableCounters' ) ) { // Number of views $views = (int)$dbr->selectField( 'page', @@ -658,8 +685,8 @@ class InfoAction extends FormlessAction { ); $result['authors'] = $authors; - // "Recent" threshold defined by $wgRCMaxAge - $threshold = $dbr->timestamp( time() - $wgRCMaxAge ); + // "Recent" threshold defined by RCMaxAge setting + $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) ); // Recent number of edits $edits = (int)$dbr->selectField( @@ -713,15 +740,19 @@ class InfoAction extends FormlessAction { } // Counts for the number of transclusion links (to/from) - $result['transclusion']['to'] = (int)$dbr->selectField( - 'templatelinks', - 'COUNT(tl_from)', - array( - 'tl_namespace' => $title->getNamespace(), - 'tl_title' => $title->getDBkey() - ), - __METHOD__ - ); + if ( $config->get( 'MiserMode' ) ) { + $result['transclusion']['to'] = 0; + } else { + $result['transclusion']['to'] = (int)$dbr->selectField( + 'templatelinks', + 'COUNT(tl_from)', + array( + 'tl_namespace' => $title->getNamespace(), + 'tl_title' => $title->getDBkey() + ), + __METHOD__ + ); + } $result['transclusion']['from'] = (int)$dbr->selectField( 'templatelinks', @@ -731,6 +762,7 @@ class InfoAction extends FormlessAction { ); wfProfileOut( __METHOD__ ); + return $result; } @@ -745,25 +777,25 @@ class InfoAction extends FormlessAction { /** * Get a list of contributors of $article - * @return string: html + * @return string Html */ protected function getContributors() { - global $wgHiddenPrefs; - $contributors = $this->page->getContributors(); $real_names = array(); $user_names = array(); $anon_ips = array(); # Sift for real versus user names + /** @var $user User */ foreach ( $contributors as $user ) { $page = $user->isAnon() ? SpecialPage::getTitleFor( 'Contributions', $user->getName() ) : $user->getUserPage(); + $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' ); if ( $user->getID() == 0 ) { $anon_ips[] = Linker::link( $page, htmlspecialchars( $user->getName() ) ); - } elseif ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) { + } elseif ( !in_array( 'realname', $hiddenPrefs ) && $user->getRealName() ) { $real_names[] = Linker::link( $page, htmlspecialchars( $user->getRealName() ) ); } else { $user_names[] = Linker::link( $page, htmlspecialchars( $user->getName() ) ); @@ -798,6 +830,7 @@ class InfoAction extends FormlessAction { } $count = count( $fulllist ); + # "Based on work by ..." return $count ? $this->msg( 'othercontribs' )->rawParams( -- cgit v1.2.3-54-g00ecf