Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PageTranslationHookHandler | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
onSpecialPrefixIndexGetFormFilters | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
onSpecialPrefixIndexQuery | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
onLonelyPagesQuery | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\PageTranslation; |
5 | |
6 | use HTMLCheckField; |
7 | use IContextSource; |
8 | use MediaWiki\Hook\LonelyPagesQueryHook; |
9 | use MediaWiki\Hook\SpecialPrefixIndexGetFormFiltersHook; |
10 | use MediaWiki\Hook\SpecialPrefixIndexQueryHook; |
11 | use Wikimedia\Rdbms\SelectQueryBuilder; |
12 | |
13 | class PageTranslationHookHandler implements |
14 | SpecialPrefixIndexGetFormFiltersHook, |
15 | SpecialPrefixIndexQueryHook, |
16 | LonelyPagesQueryHook |
17 | { |
18 | |
19 | public function onSpecialPrefixIndexGetFormFilters( IContextSource $contextSource, array &$filters ) { |
20 | $filters[ 'translate-hidetranslations' ] = [ |
21 | 'class' => HTMLCheckField::class, |
22 | 'name' => 'translate-hidetranslations', |
23 | 'label-message' => 'translate-hidetranslations', |
24 | ]; |
25 | } |
26 | |
27 | public function onSpecialPrefixIndexQuery( array $fieldData, SelectQueryBuilder $queryBuilder ) { |
28 | if ( $fieldData[ 'translate-hidetranslations' ] === true ) { |
29 | $queryBuilder->leftJoin( |
30 | 'page_props', |
31 | 'translate_pp', |
32 | [ |
33 | 'translate_pp.pp_page=page_id', |
34 | 'translate_pp.pp_propname' => 'translate-is-translation' |
35 | ] |
36 | )->andWhere( [ 'translate_pp.pp_value' => null ] ); |
37 | } |
38 | } |
39 | |
40 | public function onLonelyPagesQuery( &$tables, &$conds, &$joinConds ) { |
41 | $tables[ 'translate_pp' ] = 'page_props'; |
42 | $joinConds['translate_pp'] = [ |
43 | 'LEFT JOIN', [ |
44 | 'translate_pp.pp_page=page_id', |
45 | 'translate_pp.pp_propname' => 'translate-is-translation' |
46 | ] |
47 | ]; |
48 | $conds['translate_pp.pp_value'] = null; |
49 | } |
50 | } |