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 | use MediaWiki\Html\Html; |
| 8 | |
| 9 | class CargoOLFormat extends CargoListFormat { |
| 10 | |
| 11 | public static function allowedParameters() { |
| 12 | return [ |
| 13 | 'columns' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-columnsparam' )->parse() ] |
| 14 | ]; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @param array $valuesTable Unused |
| 19 | * @param array $formattedValuesTable |
| 20 | * @param array $fieldDescriptions |
| 21 | * @param array $displayParams |
| 22 | * @return string HTML |
| 23 | */ |
| 24 | public function display( $valuesTable, $formattedValuesTable, $fieldDescriptions, $displayParams ) { |
| 25 | if ( array_key_exists( 'columns', $displayParams ) ) { |
| 26 | $numColumns = max( $displayParams['columns'], 1 ); |
| 27 | } else { |
| 28 | $numColumns = 1; |
| 29 | } |
| 30 | if ( array_key_exists( 'offset', $displayParams ) ) { |
| 31 | $offset = $displayParams['offset']; |
| 32 | } else { |
| 33 | $offset = 0; |
| 34 | } |
| 35 | $text = ''; |
| 36 | foreach ( $formattedValuesTable as $row ) { |
| 37 | $text .= Html::rawElement( 'li', [], $this->displayRow( $row, $fieldDescriptions ) ) . "\n"; |
| 38 | } |
| 39 | $olAttribs = [ 'start' => $offset + 1 ]; |
| 40 | if ( $numColumns > 1 ) { |
| 41 | $olAttribs['style'] = "margin-top: 0;"; |
| 42 | } |
| 43 | $text = Html::rawElement( 'ol', $olAttribs, $text ); |
| 44 | if ( $numColumns > 1 ) { |
| 45 | $text = Html::rawElement( 'div', |
| 46 | [ 'style' => "-webkit-column-count: $numColumns; -moz-column-count: $numColumns; column-count: $numColumns;" ], $text ); |
| 47 | } |
| 48 | return $text; |
| 49 | } |
| 50 | |
| 51 | } |