Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CargoGanttFormat | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| allowedParameters | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| queryAndDisplay | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
12 | |||
| 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 | $height = CargoUtils::getCSSSize( $displayParams, 'height', '350px' ); |
| 27 | $width = CargoUtils::getCSSSize( $displayParams, 'width', '100%' ); |
| 28 | |
| 29 | $attrs = [ |
| 30 | 'id' => 'ganttid', |
| 31 | 'class' => 'cargoGantt', |
| 32 | 'style' => "height: $height; width: $width; border: 1px solid #aaa;" |
| 33 | ]; |
| 34 | |
| 35 | if ( array_key_exists( 'columns', $displayParams ) ) { |
| 36 | $attrs['data-columns'] = $displayParams['columns']; |
| 37 | } |
| 38 | |
| 39 | if ( array_key_exists( 'inline', $displayParams ) ) { |
| 40 | // Make this a non-"deferred" display. |
| 41 | $attrs['datafull'] = CargoExport::getGanttJSONData( $sqlQueries ); |
| 42 | } else { |
| 43 | $attrs['dataurl'] = $ce->getFullURL( $queryParams ); |
| 44 | } |
| 45 | |
| 46 | $text = Html::rawElement( 'div', $attrs, '' ); |
| 47 | |
| 48 | return $text; |
| 49 | } |
| 50 | |
| 51 | } |