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