Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CargoOLFormat | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
allowedParameters | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
display | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
42 |
1 | <?php |
2 | /** |
3 | * @author Yaron Koren |
4 | * @ingroup Cargo |
5 | */ |
6 | |
7 | class CargoOLFormat extends CargoListFormat { |
8 | |
9 | public static function allowedParameters() { |
10 | return [ |
11 | 'columns' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-columnsparam' )->parse() ] |
12 | ]; |
13 | } |
14 | |
15 | /** |
16 | * @param array $valuesTable Unused |
17 | * @param array $formattedValuesTable |
18 | * @param array $fieldDescriptions |
19 | * @param array $displayParams |
20 | * @return string HTML |
21 | */ |
22 | public function display( $valuesTable, $formattedValuesTable, $fieldDescriptions, $displayParams ) { |
23 | if ( array_key_exists( 'columns', $displayParams ) ) { |
24 | $numColumns = max( $displayParams['columns'], 1 ); |
25 | } else { |
26 | $numColumns = 1; |
27 | } |
28 | if ( array_key_exists( 'offset', $displayParams ) ) { |
29 | $offset = $displayParams['offset']; |
30 | } else { |
31 | $offset = 0; |
32 | } |
33 | $text = ''; |
34 | foreach ( $formattedValuesTable as $row ) { |
35 | $text .= Html::rawElement( 'li', null, $this->displayRow( $row, $fieldDescriptions ) ) . "\n"; |
36 | } |
37 | $olAttribs = [ 'start' => $offset + 1 ]; |
38 | if ( $numColumns > 1 ) { |
39 | $olAttribs['style'] = "margin-top: 0;"; |
40 | } |
41 | $text = Html::rawElement( 'ol', $olAttribs, $text ); |
42 | if ( $numColumns > 1 ) { |
43 | $text = Html::rawElement( 'div', |
44 | [ 'style' => "-webkit-column-count: $numColumns; -moz-column-count: $numColumns; column-count: $numColumns;" ], $text ); |
45 | } |
46 | return $text; |
47 | } |
48 | |
49 | } |