54 parent::__construct( $article, $context );
55 $this->linkRenderer = $linkRenderer;
56 $this->userFactory = $userFactory;
64 return $this->
msg(
'creditspage' )->escaped();
74 'mediawiki.action.styles',
78 $s = $this->
msg(
'nocredits' )->parse();
83 return Html::rawElement(
'div', [
'id' =>
'mw-credits' ], $s );
97 $s = $this->getAuthor();
98 if ( $cnt > 1 || $cnt < 0 ) {
111 private function getAuthor() {
112 $page = $this->getWikiPage();
113 $user = $this->userFactory->newFromName( $page->getUserText(), UserRigorOptions::RIGOR_NONE );
115 $timestamp = $page->getTimestamp();
117 $lang = $this->getLanguage();
118 $d = $lang->date( $page->getTimestamp(),
true );
119 $t = $lang->time( $page->getTimestamp(),
true );
125 return $this->
msg(
'lastmodifiedatby', $d, $t )->rawParams(
127 $this->
userLink( $user ) )->params( $user->getName() )->escaped();
137 $hiddenPrefs = $this->context->getConfig()->get( MainConfigNames::HiddenPrefs );
138 return !in_array(
'realname', $hiddenPrefs );
150 $others_link =
false;
152 # Hmm... too many to fit!
156 return $this->
msg(
'othercontribs' )->rawParams(
165 # Sift for real versus user names
169 if ( $user->isRegistered() ) {
170 $link = $this->
link( $user );
172 $real_names[] = $link;
174 $user_names[] = $link;
177 $anon_ips[] = $this->
link( $user );
187 if ( count( $real_names ) ) {
188 $real = $lang->listToText( $real_names );
193 # "ThisSite user(s) A, B and C"
194 if ( count( $user_names ) ) {
195 $user = $this->
msg(
'siteusers' )->rawParams( $lang->listToText( $user_names ) )->params(
196 count( $user_names ) )->escaped();
201 if ( count( $anon_ips ) ) {
202 $anon = $this->
msg(
'anonusers' )->rawParams( $lang->listToText( $anon_ips ) )->params(
203 count( $anon_ips ) )->escaped();
208 # This is the big list, all mooshed together. We sift for blank strings
210 foreach ( [ $real, $user, $anon, $others_link ] as $s ) {
211 if ( $s !==
false ) {
216 $count = count( $fullList );
218 # "Based on work by ..."
220 ? $this->
msg(
'othercontribs' )->rawParams(
221 $lang->listToText( $fullList ) )->params( $count )->escaped()
233 if ( $real ===
'' ) {
240 return Linker::userLink( $user->
getId(), $user->
getName(), $real );
249 $link = $this->
link( $user );
251 return $this->
msg(
'anonuser' )->rawParams( $link )->parse();
255 return $this->
msg(
'siteuser' )->rawParams( $link )->params( $user->
getName() )->escaped();
264 return $this->linkRenderer->makeKnownLink(
266 $this->
msg(
'others' )->text(),
268 [
'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.