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 | use MediaWiki\Html\Html; |
| 8 | |
| 9 | class CargoULFormat extends CargoListFormat { |
| 10 | |
| 11 | public static function allowedParameters() { |
| 12 | return [ 'columns' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-columnsparam' )->parse() ] ]; |
| 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 | |
| 29 | $text = ''; |
| 30 | foreach ( $formattedValuesTable as $row ) { |
| 31 | $text .= Html::rawElement( 'li', [], $this->displayRow( $row, $fieldDescriptions ) ) . "\n"; |
| 32 | } |
| 33 | $ulAttribs = []; |
| 34 | if ( $numColumns > 1 ) { |
| 35 | $ulAttribs['style'] = "margin-top: 0;"; |
| 36 | } |
| 37 | $text = Html::rawElement( 'ul', $ulAttribs, $text ); |
| 38 | if ( $numColumns > 1 ) { |
| 39 | $text = Html::rawElement( 'div', |
| 40 | [ 'style' => |
| 41 | "-webkit-column-count: $numColumns; -moz-column-count: $numColumns; column-count: $numColumns;" ], $text ); |
| 42 | } |
| 43 | return $text; |
| 44 | } |
| 45 | |
| 46 | } |