39 private $linkRenderer;
56 parent::__construct( $article, $context );
57 $this->linkRenderer = $linkRenderer;
58 $this->userFactory = $userFactory;
66 return $this->
msg(
'creditspage' )->escaped();
76 'mediawiki.action.styles',
80 $s = $this->
msg(
'nocredits' )->parse();
85 return Html::rawElement(
'div', [
'id' =>
'mw-credits' ], $s );
99 $s = $this->getAuthor();
100 if ( $cnt > 1 || $cnt < 0 ) {
113 private function getAuthor() {
114 $page = $this->getWikiPage();
115 $user = $this->userFactory->newFromName( $page->getUserText(), UserRigorOptions::RIGOR_NONE );
117 $timestamp = $page->getTimestamp();
119 $lang = $this->getLanguage();
120 $d =
$lang->date( $page->getTimestamp(),
true );
121 $t =
$lang->time( $page->getTimestamp(),
true );
127 return $this->
msg(
'lastmodifiedatby', $d,
$t )->rawParams(
129 $this->
userLink( $user ) )->params( $user->getName() )->escaped();
139 $hiddenPrefs = $this->context->getConfig()->get( MainConfigNames::HiddenPrefs );
140 return !in_array(
'realname', $hiddenPrefs );
152 $others_link =
false;
154 # Hmm... too many to fit!
158 return $this->
msg(
'othercontribs' )->rawParams(
167 # Sift for real versus user names
171 if ( $user->isRegistered() ) {
172 $link = $this->
link( $user );
174 $real_names[] = $link;
176 $user_names[] = $link;
179 $anon_ips[] = $this->
link( $user );
189 if ( count( $real_names ) ) {
190 $real =
$lang->listToText( $real_names );
195 # "ThisSite user(s) A, B and C"
196 if ( count( $user_names ) ) {
197 $user = $this->
msg(
'siteusers' )->rawParams(
$lang->listToText( $user_names ) )->params(
198 count( $user_names ) )->escaped();
203 if ( count( $anon_ips ) ) {
204 $anon = $this->
msg(
'anonusers' )->rawParams(
$lang->listToText( $anon_ips ) )->params(
205 count( $anon_ips ) )->escaped();
210 # This is the big list, all mooshed together. We sift for blank strings
212 foreach ( [ $real, $user, $anon, $others_link ] as $s ) {
213 if ( $s !==
false ) {
218 $count = count( $fullList );
220 # "Based on work by ..."
222 ? $this->
msg(
'othercontribs' )->rawParams(
223 $lang->listToText( $fullList ) )->params( $count )->escaped()
235 if ( $real ===
'' ) {
242 return Linker::userLink( $user->
getId(), $user->
getName(), $real );
251 $link = $this->
link( $user );
253 return $this->
msg(
'anonuser' )->rawParams( $link )->parse();
257 return $this->
msg(
'siteuser' )->rawParams( $link )->params( $user->
getName() )->escaped();
266 return $this->linkRenderer->makeKnownLink(
268 $this->
msg(
'others' )->text(),
270 [
'action' =>
'credits' ]
getWikiPage()
Get a WikiPage object.
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getLanguage()
Shortcut to get the user Language being used for this instance.
Legacy class representing an editable page and handling UI for some page actions.
getCredits( $cnt, $showIfMax=true)
Get a list of contributors.
getName()
Return the name of the action this object responds to.
getContributors( $cnt, $showIfMax)
Get a list of contributors of $article.
canShowRealUserName()
Whether we can display the user's real name (not a hidden pref)
othersLink()
Get a link to action=credits of $article page.
getDescription()
Returns the description that goes below the <h1> element.
link(User $user)
Get a link to $user's user page.
__construct(Article $article, IContextSource $context, LinkRenderer $linkRenderer, UserFactory $userFactory)
onView()
This is largely cadged from PageHistory::history.
userLink(User $user)
Get a link to $user's user page.
A class containing constants representing the names of configuration variables.
getName()
Get the user name, or the IP of an anonymous user.
getRealName()
Get the user's real name.
getId( $wikiId=self::LOCAL)
Get the user's ID.
isAnon()
Get whether the user is anonymous.
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang