$this->userLink( $user ) )->params( $user->getName() )->escaped();
}
+ /**
+ * Whether we can display the user's real name (not a hidden pref)
+ *
+ * @since 1.24
+ * @return bool
+ */
+ protected function canShowRealUserName() {
+ $hiddenPrefs = $this->context->getConfig()->get( 'HiddenPrefs' );
+ return !in_array( 'realname', $hiddenPrefs );
+ }
+
/**
* Get a list of contributors of $article
* @param int $cnt Maximum list of contributors to show
* @return string Html
*/
protected function getContributors( $cnt, $showIfMax ) {
- global $wgHiddenPrefs;
-
$contributors = $this->page->getContributors();
$others_link = false;
$cnt--;
if ( $user->isLoggedIn() ) {
$link = $this->link( $user );
- if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
+ if ( $this->canShowRealUserName() && $user->getRealName() ) {
$real_names[] = $link;
} else {
$user_names[] = $link;
* @return string Html
*/
protected function link( User $user ) {
- global $wgHiddenPrefs;
- if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) {
+ if ( $this->canShowRealUserName() && !$user->isAnon() ) {
$real = $user->getRealName();
} else {
$real = false;
if ( $user->isAnon() ) {
return $this->msg( 'anonuser' )->rawParams( $link )->parse();
} else {
- global $wgHiddenPrefs;
- if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
+ if ( $this->canShowRealUserName() && $user->getRealName() ) {
return $link;
} else {
return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
* Print the history page for an article.
*/
function onView() {
- global $wgScript, $wgUseFileCache;
-
$out = $this->getOutput();
$request = $this->getRequest();
$this->preCacheMessages();
# Fill in the file cache if not set already
- if ( $wgUseFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
+ $useFileCache = $this->context->getConfig()->get( 'UseFileCache' );
+ if ( $useFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
$cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' );
if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
ob_start( array( &$cache, 'saveToFileCache' ) );
}
// Add the general form
- $action = htmlspecialchars( $wgScript );
+ $action = htmlspecialchars( wfScript() );
$out->addHTML(
"<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
Xml::fieldset(
* @param string $type Feed type
*/
function feed( $type ) {
- global $wgFeedClasses, $wgFeedLimit;
if ( !FeedUtils::checkFeedOutput( $type ) ) {
return;
}
$request = $this->getRequest();
+ $feedClasses = $this->context->getConfig()->get( 'FeedClasses' );
/** @var RSSFeed|AtomFeed $feed */
- $feed = new $wgFeedClasses[$type](
+ $feed = new $feedClasses[$type](
$this->getTitle()->getPrefixedText() . ' - ' .
$this->msg( 'history-feed-title' )->inContentLanguage()->text(),
$this->msg( 'history-feed-description' )->inContentLanguage()->text(),
// Get a limit on number of feed entries. Provide a sane default
// of 10 if none is defined (but limit to $wgFeedLimit max)
$limit = $request->getInt( 'limit', 10 );
- $limit = min( max( $limit, 1 ), $wgFeedLimit );
+ $limit = min(
+ max( $limit, 1 ),
+ $this->context->getConfig()->get( 'FeedLimit' )
+ );
$items = $this->fetchRevisions( $limit, 0, self::DIR_NEXT );
* @return string HTML output
*/
function getStartBody() {
- global $wgScript;
$this->lastRow = false;
$this->counter = 1;
$this->oldIdChecked = 0;
$this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
- $s = Html::openElement( 'form', array( 'action' => $wgScript,
+ $s = Html::openElement( 'form', array( 'action' => wfScript(),
'id' => 'mw-history-compare' ) ) . "\n";
$s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
$s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
* @return array
*/
protected function pageInfo() {
- global $wgContLang, $wgRCMaxAge, $wgMemc, $wgMiserMode,
- $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit, $wgPageLanguageUseDB;
+ 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() );
$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 );
// Language in which the page content is (supposed to be) written
$pageLang = $title->getPageLanguage()->getCode();
- if ( $wgPageLanguageUseDB && $this->getTitle()->userCan( 'pagelang' ) ) {
+ 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(
);
}
+ $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 )
);
}
// 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'] )
);
$pageCounts['transclusion']['from'] > 0 ||
$pageCounts['transclusion']['to'] > 0
) {
- $options = array( 'LIMIT' => $wgPageInfoTransclusionLimit );
+ $options = array( 'LIMIT' => $config->get( 'PageInfoTransclusionLimit' ) );
$transcludedTemplates = $title->getTemplateLinksFrom( $options );
- if ( $wgMiserMode ) {
+ if ( $config->get( 'MiserMode' ) ) {
$transcludedTargets = array();
} else {
$transcludedTargets = $title->getTemplateLinksTo( $options );
);
}
- if ( !$wgMiserMode && $pageCounts['transclusion']['to'] > 0 ) {
+ if ( !$config->get( 'MiserMode' ) && $pageCounts['transclusion']['to'] > 0 ) {
if ( $pageCounts['transclusion']['to'] > count( $transcludedTargets ) ) {
$more = Linker::link(
$whatLinksHere,
* @param Title $title Title to get counts for
* @return array
*/
- protected static function pageCounts( Title $title ) {
- global $wgRCMaxAge, $wgDisableCounters, $wgMiserMode;
-
+ 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',
);
$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(
}
// Counts for the number of transclusion links (to/from)
- if ( $wgMiserMode ) {
+ if ( $config->get( 'MiserMode' ) ) {
$result['transclusion']['to'] = 0;
} else {
$result['transclusion']['to'] = (int)$dbr->selectField(
* @return string Html
*/
protected function getContributors() {
- global $wgHiddenPrefs;
-
$contributors = $this->page->getContributors();
$real_names = array();
$user_names = array();
? 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() ) );