55 parent::__construct( $article, $context );
56 $this->linkRenderer = $linkRenderer;
57 $this->userFactory = $userFactory;
65 return $this->
msg(
'creditspage' )->escaped();
75 'mediawiki.action.styles',
79 $s = $this->
msg(
'nocredits' )->parse();
84 return Html::rawElement(
'div', [
'id' =>
'mw-credits' ], $s );
98 $s = $this->getAuthor();
99 if ( $cnt > 1 || $cnt < 0 ) {
112 private function getAuthor() {
113 $page = $this->getWikiPage();
114 $user = $this->userFactory->newFromName( $page->getUserText(), UserRigorOptions::RIGOR_NONE );
116 $timestamp = $page->getTimestamp();
118 $lang = $this->getLanguage();
119 $d = $lang->date( $page->getTimestamp(),
true );
120 $t = $lang->time( $page->getTimestamp(),
true );
126 return $this->
msg(
'lastmodifiedatby', $d, $t )->rawParams(
128 $this->
userLink( $user ) )->params( $user->getName() )->escaped();
138 $hiddenPrefs = $this->context->getConfig()->get( MainConfigNames::HiddenPrefs );
139 return !in_array(
'realname', $hiddenPrefs );
151 $others_link =
false;
153 # Hmm... too many to fit!
157 return $this->
msg(
'othercontribs' )->rawParams(
166 # Sift for real versus user names
170 if ( $user->isRegistered() ) {
171 $link = $this->
link( $user );
173 $real_names[] = $link;
175 $user_names[] = $link;
178 $anon_ips[] = $this->
link( $user );
188 if ( count( $real_names ) ) {
189 $real = $lang->listToText( $real_names );
194 # "ThisSite user(s) A, B and C"
195 if ( count( $user_names ) ) {
196 $user = $this->
msg(
'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
197 count( $user_names ) )->escaped();
202 if ( count( $anon_ips ) ) {
203 $anon = $this->
msg(
'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
204 count( $anon_ips ) )->escaped();
209 # This is the big list, all mooshed together. We sift for blank strings
211 foreach ( [ $real, $user, $anon, $others_link ] as $s ) {
212 if ( $s !==
false ) {
217 $count = count( $fullList );
219 # "Based on work by ..."
221 ? $this->
msg(
'othercontribs' )->rawParams(
222 $lang->listToText( $fullList ) )->params( $count )->escaped()
234 if ( $real ===
'' ) {
241 return Linker::userLink( $user->
getId(), $user->
getName(), $real );
250 $link = $this->
link( $user );
252 return $this->
msg(
'anonuser' )->rawParams( $link )->parse();
256 return $this->
msg(
'siteuser' )->rawParams( $link )->params( $user->
getName() )->escaped();
265 return $this->linkRenderer->makeKnownLink(
267 $this->
msg(
'others' )->text(),
269 [
'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.
Interface for objects which can provide a MediaWiki context on request.