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