Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
CodeRevisionAuthorView | |
0.00% |
0 / 33 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getPager | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
linkStatus | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
execute | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CodeReview\UI; |
4 | |
5 | use Linker; |
6 | use RequestContext; |
7 | use SpecialPage; |
8 | |
9 | class CodeRevisionAuthorView extends CodeRevisionListView { |
10 | public function __construct( $repo, $author ) { |
11 | parent::__construct( $repo ); |
12 | $this->mAuthor = $author; |
13 | $this->mUser = $this->mRepo->authorWikiUser( $author ); |
14 | } |
15 | |
16 | public function getPager() { |
17 | return new SvnRevAuthorTablePager( $this, $this->mAuthor ); |
18 | } |
19 | |
20 | public function linkStatus() { |
21 | if ( !$this->mUser ) { |
22 | return wfMessage( 'code-author-orphan' )->rawParams( $this->authorLink( $this->mAuthor ) ) |
23 | ->escaped(); |
24 | } |
25 | |
26 | return wfMessage( 'code-author-haslink' ) |
27 | ->rawParams( Linker::userLink( $this->mUser->getId(), $this->mUser->getName() ) . |
28 | Linker::userToolLinks( |
29 | $this->mUser->getId(), |
30 | $this->mUser->getName(), |
31 | // default for redContribsWhenNoEdits |
32 | false, |
33 | // Add "send email" link |
34 | Linker::TOOL_LINKS_EMAIL |
35 | ) )->escaped(); |
36 | } |
37 | |
38 | public function execute() { |
39 | global $wgOut; |
40 | |
41 | $linkInfo = $this->linkStatus(); |
42 | |
43 | $linkRenderer = \MediaWiki\MediaWikiServices::getInstance()->getLinkRenderer(); |
44 | // Give grep a chance to find the usages: |
45 | // code-author-link, code-author-unlink |
46 | if ( RequestContext::getMain()->getUser()->isAllowed( 'codereview-link-user' ) ) { |
47 | $repo = $this->mRepo->getName(); |
48 | $page = SpecialPage::getTitleFor( 'Code', "$repo/author/$this->mAuthor/link" ); |
49 | $linkInfo .= ' (' . $linkRenderer->makeLink( $page, |
50 | wfMessage( 'code-author-' . ( $this->mUser ? 'un' : '' ) . 'link' )->text() ) . ')'; |
51 | } |
52 | |
53 | $repoLink = $linkRenderer->makeLink( |
54 | SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ), |
55 | $this->mRepo->getName() |
56 | ); |
57 | $fields = [ |
58 | 'code-rev-repo' => $repoLink, |
59 | 'code-rev-author' => $this->mAuthor, |
60 | ]; |
61 | |
62 | $wgOut->addHTML( $this->formatMetaData( $fields ) . $linkInfo ); |
63 | |
64 | parent::execute(); |
65 | } |
66 | } |