* @return string HTML
*/
public function onView() {
- wfProfileIn( __METHOD__ );
if ( $this->page->getID() == 0 ) {
$s = $this->msg( 'nocredits' )->parse();
$s = $this->getCredits( -1 );
}
- wfProfileOut( __METHOD__ );
-
return Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $s );
}
* @return string Html
*/
public function getCredits( $cnt, $showIfMax = true ) {
- wfProfileIn( __METHOD__ );
$s = '';
if ( $cnt != 0 ) {
}
}
- wfProfileOut( __METHOD__ );
-
return $s;
}
$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();