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