class CreditsAction extends FormlessAction {
- public function getName(){
+ public function getName() {
return 'credits';
}
- public function getRestriction(){
- return null;
+ protected function getDescription() {
+ return $this->msg( 'creditspage' )->escaped();
}
/**
* This is largely cadged from PageHistory::history
+ *
+ * @return String HTML
*/
public function onView() {
wfProfileIn( __METHOD__ );
if ( $this->page->getID() == 0 ) {
- $s = wfMsg( 'nocredits' );
+ $s = $this->msg( 'nocredits' )->parse();
} else {
$s = $this->getCredits( -1 );
}
wfProfileOut( __METHOD__ );
- return $s;
+ return Html::rawElement( 'div', array( 'id' => 'mw-credits' ), $s );
}
/**
- * Get a list of contributors of $article
- * @param $article Article object
+ * Get a list of contributors
+ *
* @param $cnt Int: maximum list of contributors to show
* @param $showIfMax Bool: whether to contributors if there more than $cnt
* @return String: html
*/
- protected function getCredits( $cnt, $showIfMax = true ) {
+ public function getCredits( $cnt, $showIfMax = true ) {
wfProfileIn( __METHOD__ );
$s = '';
- if ( isset( $cnt ) && $cnt != 0 ) {
- $s = self::getAuthor( $this->page );
+ if ( $cnt != 0 ) {
+ $s = $this->getAuthor( $this->page );
if ( $cnt > 1 || $cnt < 0 ) {
$s .= ' ' . $this->getContributors( $cnt - 1, $showIfMax );
}
/**
* Get the last author with the last modification time
* @param $article Article object
+ * @return String HTML
*/
- protected static function getAuthor( Article $article ) {
- global $wgLang;
-
- $user = User::newFromId( $article->getUser() );
+ protected function getAuthor( Page $article ) {
+ $user = User::newFromName( $article->getUserText(), false );
$timestamp = $article->getTimestamp();
if ( $timestamp ) {
- $d = $wgLang->date( $article->getTimestamp(), true );
- $t = $wgLang->time( $article->getTimestamp(), true );
+ $lang = $this->getLanguage();
+ $d = $lang->date( $article->getTimestamp(), true );
+ $t = $lang->time( $article->getTimestamp(), true );
} else {
$d = '';
$t = '';
}
- return wfMsgExt( 'lastmodifiedatby', 'parsemag', $d, $t, self::userLink( $user ), $user->getName() );
+ return $this->msg( 'lastmodifiedatby', $d, $t )->rawParams(
+ $this->userLink( $user ) )->params( $user->getName() )->escaped();
}
/**
* Get a list of contributors of $article
- * @param $article Article object
* @param $cnt Int: maximum list of contributors to show
* @param $showIfMax Bool: whether to contributors if there more than $cnt
* @return String: html
*/
protected function getContributors( $cnt, $showIfMax ) {
- global $wgLang, $wgHiddenPrefs;
+ global $wgHiddenPrefs;
$contributors = $this->page->getContributors();
if ( $cnt > 0 && $contributors->count() > $cnt ) {
$others_link = $this->othersLink();
if ( !$showIfMax )
- return wfMsgExt( 'othercontribs', 'parsemag', $others_link, $contributors->count() );
+ return $this->msg( 'othercontribs' )->rawParams(
+ $others_link )->params( $contributors->count() )->escaped();
}
$real_names = array();
# Sift for real versus user names
foreach ( $contributors as $user ) {
- $cnt--;
+ $cnt--;
if ( $user->isLoggedIn() ) {
- $link = self::link( $user );
+ $link = $this->link( $user );
if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
$real_names[] = $link;
} else {
$user_names[] = $link;
}
} else {
- $anon_ips[] = self::link( $user );
+ $anon_ips[] = $this->link( $user );
}
if ( $cnt == 0 ) {
}
}
+ $lang = $this->getLanguage();
+
if ( count( $real_names ) ) {
- $real = $wgLang->listToText( $real_names );
+ $real = $lang->listToText( $real_names );
} else {
$real = false;
}
# "ThisSite user(s) A, B and C"
if ( count( $user_names ) ) {
- $user = wfMsgExt(
- 'siteusers',
- 'parsemag',
- $wgLang->listToText( $user_names ), count( $user_names )
- );
+ $user = $this->msg( 'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
+ count( $user_names ) )->escaped();
} else {
$user = false;
}
if ( count( $anon_ips ) ) {
- $anon = wfMsgExt(
- 'anonusers',
- 'parsemag',
- $wgLang->listToText( $anon_ips ), count( $anon_ips )
- );
+ $anon = $this->msg( 'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
+ count( $anon_ips ) )->escaped();
} else {
$anon = false;
}
# This is the big list, all mooshed together. We sift for blank strings
$fulllist = array();
foreach ( array( $real, $user, $anon, $others_link ) as $s ) {
- if ( $s ) {
+ if ( $s !== false ) {
array_push( $fulllist, $s );
}
}
- # Make the list into text...
- $creds = $wgLang->listToText( $fulllist );
-
+ $count = count( $fulllist );
# "Based on work by ..."
- return strlen( $creds )
- ? wfMsgExt( 'othercontribs', 'parsemag', $creds, count( $fulllist ) )
+ return $count
+ ? $this->msg( 'othercontribs' )->rawParams(
+ $lang->listToText( $fulllist ) )->params( $count )->escaped()
: '';
}
* @param $user User object
* @return String: html
*/
- protected static function link( User $user ) {
- global $wgUser, $wgHiddenPrefs;
+ protected function link( User $user ) {
+ global $wgHiddenPrefs;
if ( !in_array( 'realname', $wgHiddenPrefs ) && !$user->isAnon() ) {
$real = $user->getRealName();
} else {
* @param $user User object
* @return String: html
*/
- protected static function userLink( User $user ) {
- $link = self::link( $user );
+ protected function userLink( User $user ) {
+ $link = $this->link( $user );
if ( $user->isAnon() ) {
- return wfMsgExt( 'anonuser', array( 'parseinline', 'replaceafter' ), $link );
+ return $this->msg( 'anonuser' )->rawParams( $link )->parse();
} else {
global $wgHiddenPrefs;
if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->getRealName() ) {
return $link;
} else {
- return wfMsgExt( 'siteuser', 'parsemag', $link, $user->getName() );
+ return $this->msg( 'siteuser' )->rawParams( $link )->params( $user->getName() )->escaped();
}
}
}
/**
* Get a link to action=credits of $article page
- * @param $article Article object
- * @return String: html
+ * @return String: HTML link
*/
protected function othersLink() {
- global $wgUser;
- return Linker::link(
+ return Linker::linkKnown(
$this->getTitle(),
- wfMsgHtml( 'others' ),
+ $this->msg( 'others' )->escaped(),
array(),
- array( 'action' => 'credits' ),
- array( 'known' )
+ array( 'action' => 'credits' )
);
}
}