Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
TalkpageHistoryPager | |
0.00% |
0 / 54 |
|
0.00% |
0 / 4 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getFieldMessages | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
formatValue | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | use MediaWiki\Html\Html; |
4 | use MediaWiki\MediaWikiServices; |
5 | use MediaWiki\Title\Title; |
6 | |
7 | class TalkpageHistoryPager extends ThreadHistoryPager { |
8 | |
9 | /** @var Article */ |
10 | protected $talkpage; |
11 | |
12 | public function __construct( LqtView $view, $talkpage ) { |
13 | $this->talkpage = $talkpage; |
14 | |
15 | parent::__construct( $view, null ); |
16 | } |
17 | |
18 | public function getFieldMessages() { |
19 | $headers = [ |
20 | 'th_timestamp' => $this->msg( 'lqt-history-time' )->text(), |
21 | 'thread_subject' => $this->msg( 'lqt-history-thread' )->text(), |
22 | 'th_user_text' => $this->msg( 'lqt-history-user' )->text(), |
23 | 'th_change_type' => $this->msg( 'lqt-history-action' )->text(), |
24 | 'th_change_comment' => $this->msg( 'lqt-history-comment' )->text(), |
25 | ]; |
26 | |
27 | return $headers; |
28 | } |
29 | |
30 | public function getQueryInfo() { |
31 | $queryInfo = [ |
32 | 'tables' => [ 'thread_history', 'thread', 'page' ], |
33 | 'fields' => '*', |
34 | 'conds' => [ Threads::articleClause( $this->talkpage->getPage() ) ], |
35 | 'options' => [ 'order by' => 'th_timestamp desc' ], |
36 | 'join_conds' => [ |
37 | 'thread' => [ 'LEFT JOIN', 'thread_id=th_thread' ], |
38 | 'page' => [ 'LEFT JOIN', 'thread_root=page_id' ], |
39 | ], |
40 | ]; |
41 | |
42 | return $queryInfo; |
43 | } |
44 | |
45 | public function formatValue( $name, $value ) { |
46 | $this->getOutput()->setRobotPolicy( 'noindex, nofollow' ); |
47 | |
48 | $row = $this->mCurrentRow; |
49 | |
50 | $ns = $row->page_namespace; |
51 | $title = $row->page_title; |
52 | |
53 | if ( $ns === null ) { |
54 | $ns = $row->thread_article_namespace; |
55 | $title = $row->thread_article_title; |
56 | } |
57 | |
58 | switch ( $name ) { |
59 | case 'thread_subject': |
60 | $title = Title::makeTitleSafe( |
61 | $ns, |
62 | $title |
63 | ); |
64 | |
65 | $link = $this->linkRenderer->makeKnownLink( |
66 | $title, |
67 | $value, |
68 | [], |
69 | [] |
70 | ); |
71 | |
72 | $contLang = MediaWikiServices::getInstance()->getContentLanguage(); |
73 | |
74 | return Html::rawElement( 'div', [ 'dir' => $contLang->getDir() ], $link ); |
75 | case 'th_timestamp': |
76 | $formatted = $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ); |
77 | $title = Title::makeTitleSafe( |
78 | $ns, |
79 | $title |
80 | ); |
81 | |
82 | return $this->linkRenderer->makeLink( |
83 | $title, |
84 | $formatted, |
85 | [], |
86 | [ 'lqt_oldid' => $row->th_id ] |
87 | ); |
88 | default: |
89 | return parent::formatValue( $name, $value ); |
90 | } |
91 | } |
92 | } |