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