Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CargoExcelFormat | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
72 | |
0.00% |
0 / 1 |
| allowedParameters | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| queryAndDisplay | |
0.00% |
0 / 14 |
|
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 CargoExcelFormat extends CargoDeferredFormat { |
| 10 | |
| 11 | public static function allowedParameters() { |
| 12 | return [ |
| 13 | 'filename' => [ 'type' => 'string' ], |
| 14 | 'link text' => [ 'type' => 'string' ], |
| 15 | 'parse values' => [ 'type' => 'boolean' ] |
| 16 | ]; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @param array $sqlQueries |
| 21 | * @param array $displayParams Unused |
| 22 | * @param array|null $querySpecificParams Unused |
| 23 | * @return string HTML |
| 24 | */ |
| 25 | public function queryAndDisplay( $sqlQueries, $displayParams, $querySpecificParams = null ) { |
| 26 | $ce = SpecialPage::getTitleFor( 'CargoExport' ); |
| 27 | $queryParams = $this->sqlQueriesToQueryParams( $sqlQueries ); |
| 28 | $queryParams['format'] = 'excel'; |
| 29 | if ( array_key_exists( 'filename', $displayParams ) && $displayParams['filename'] != '' ) { |
| 30 | $queryParams['filename'] = $displayParams['filename']; |
| 31 | } |
| 32 | if ( array_key_exists( 'parse values', $displayParams ) && $displayParams['parse values'] != '' ) { |
| 33 | $queryParams['parse values'] = $displayParams['parse values']; |
| 34 | } |
| 35 | if ( array_key_exists( 'link text', $displayParams ) && $displayParams['link text'] != '' ) { |
| 36 | $linkText = $displayParams['link text']; |
| 37 | } else { |
| 38 | $linkText = wfMessage( 'cargo-viewxls' )->text(); |
| 39 | } |
| 40 | $linkAttrs = [ |
| 41 | 'href' => $ce->getFullURL( $queryParams ), |
| 42 | ]; |
| 43 | return Html::element( 'a', $linkAttrs, $linkText ); |
| 44 | } |
| 45 | |
| 46 | } |