/**
* This is largely cadged from PageHistory::history
*
- * @return String HTML
+ * @return string HTML
*/
public function onView() {
wfProfileIn( __METHOD__ );
/**
* Get a list of contributors
*
- * @param int $cnt maximum list of contributors to show
- * @param bool $showIfMax whether to contributors if there more than $cnt
- * @return String: html
+ * @param int $cnt Maximum list of contributors to show
+ * @param bool $showIfMax Whether to contributors if there more than $cnt
+ * @return string Html
*/
public function getCredits( $cnt, $showIfMax = true ) {
wfProfileIn( __METHOD__ );
/**
* Get the last author with the last modification time
- * @param WikiPage $page
- * @return String HTML
+ * @param Page $page
+ * @return string HTML
*/
- protected function getAuthor( WikiPage $page ) {
+ protected function getAuthor( Page $page ) {
$user = User::newFromName( $page->getUserText(), false );
$timestamp = $page->getTimestamp();
$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
- * @param bool $showIfMax whether to contributors if there more than $cnt
- * @return String: html
+ * @param int $cnt Maximum list of contributors to show
+ * @param bool $showIfMax Whether to contributors if there more than $cnt
+ * @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;
/**
* Get a link to $user's user page
- * @param $user User object
- * @return String: html
+ * @param User $user
+ * @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;
/**
* Get a link to $user's user page
- * @param $user User object
- * @return String: html
+ * @param User $user
+ * @return string Html
*/
protected function userLink( User $user ) {
$link = $this->link( $user );
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();
/**
* Get a link to action=credits of $article page
- * @return String: HTML link
+ * @return string HTML link
*/
protected function othersLink() {
return Linker::linkKnown(