Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CargoTimelineFormat | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
72 | |
0.00% |
0 / 1 |
allowedParameters | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
queryAndDisplay | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
56 |
1 | <?php |
2 | /** |
3 | * @author Yaron Koren |
4 | * @ingroup Cargo |
5 | */ |
6 | |
7 | class CargoTimelineFormat extends CargoDeferredFormat { |
8 | |
9 | public static function allowedParameters() { |
10 | return [ |
11 | 'height' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-heightparam' )->parse() ], |
12 | 'width' => [ 'type' => 'int', 'label' => wfMessage( 'cargo-viewdata-widthparam' )->parse() ] |
13 | ]; |
14 | } |
15 | |
16 | /** |
17 | * @param array $sqlQueries |
18 | * @param array $displayParams |
19 | * @param array|null $querySpecificParams Unused |
20 | * @return string HTML |
21 | */ |
22 | public function queryAndDisplay( $sqlQueries, $displayParams, $querySpecificParams = null ) { |
23 | $this->mOutput->addModules( [ 'ext.cargo.timeline' ] ); |
24 | $ce = SpecialPage::getTitleFor( 'CargoExport' ); |
25 | $queryParams = $this->sqlQueriesToQueryParams( $sqlQueries ); |
26 | $queryParams['format'] = 'timeline'; |
27 | // $queryParams['color'] = array(); |
28 | /* foreach ( $sqlQueries as $i => $sqlQuery ) { |
29 | if ( $querySpecificParams != null ) { |
30 | // Add any handling here. |
31 | } |
32 | } */ |
33 | |
34 | if ( array_key_exists( 'height', $displayParams ) && $displayParams['height'] != '' ) { |
35 | $height = $displayParams['height']; |
36 | // Add on "px", if no unit is defined. |
37 | if ( is_numeric( $height ) ) { |
38 | $height .= "px"; |
39 | } |
40 | } else { |
41 | $height = "350px"; |
42 | } |
43 | if ( array_key_exists( 'width', $displayParams ) && $displayParams['width'] != '' ) { |
44 | $width = $displayParams['width']; |
45 | // Add on "px", if no unit is defined. |
46 | if ( is_numeric( $width ) ) { |
47 | $width .= "px"; |
48 | } |
49 | } else { |
50 | $width = "100%"; |
51 | } |
52 | |
53 | $attrs = [ |
54 | 'class' => 'cargoTimeline', |
55 | 'dataurl' => $ce->getFullURL( $queryParams ), |
56 | 'style' => "height: $height; width: $width; border: 1px solid #aaa;" |
57 | ]; |
58 | $text = Html::rawElement( 'div', $attrs, '' ); |
59 | |
60 | return $text; |
61 | } |
62 | |
63 | } |