Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
SvnTablePager
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 isFieldSortable
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 formatRevValue
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 formatRow
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
12
 getStartBody
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\CodeReview\UI;
4
5use MediaWiki\Extension\CodeReview\Backend\CodeRepository;
6use stdClass;
7use TablePager;
8
9abstract class SvnTablePager extends TablePager {
10    /**
11     * @var CodeRepository
12     */
13    protected $mRepo;
14
15    /**
16     * @var CodeView
17     */
18    protected $mView;
19
20    /**
21     * @param CodeView $view
22     */
23    public function __construct( $view ) {
24        $this->mView = $view;
25        $this->mRepo = $view->mRepo;
26        $this->mDefaultDirection = true;
27        parent::__construct();
28    }
29
30    public function isFieldSortable( $field ) {
31        return $field == $this->getDefaultSort();
32    }
33
34    public function formatRevValue( $name, $value, $row ) {
35        return $this->formatValue( $name, $value );
36    }
37
38    /**
39     * @note this function is poorly factored in the parent class
40     * @param stdClass $row
41     * @return string
42     */
43    public function formatRow( $row ) {
44        $css = "mw-codereview-status-{$row->cr_status}";
45        $s = "<tr class=\"$css\">\n";
46        // Some of this stolen from Pager.php...sigh
47        $fieldNames = $this->getFieldNames();
48        // In case formatValue needs to know
49        $this->mCurrentRow = $row;
50        foreach ( $fieldNames as $field => $name ) {
51            $value = $row->$field ?? null;
52            $formatted = strval( $this->formatRevValue( $field, $value, $row ) );
53            if ( $formatted == '' ) {
54                $formatted = '&#160;';
55            }
56            $class = 'TablePager_col_' . htmlspecialchars( $field );
57            $s .= "<td class=\"$class\">$formatted</td>\n";
58        }
59        $s .= "</tr>\n";
60        return $s;
61    }
62
63    public function getStartBody() {
64        $this->getOutput()->addModules( 'ext.codereview.overview' );
65        return parent::getStartBody();
66    }
67}