Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CargoTimelineFormat
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 allowedParameters
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 queryAndDisplay
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * @author Yaron Koren
4 * @ingroup Cargo
5 */
6
7use MediaWiki\Html\Html;
8
9class CargoTimelineFormat 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 Unused
22     * @return string HTML
23     */
24    public function queryAndDisplay( $sqlQueries, $displayParams, $querySpecificParams = null ) {
25        $this->mOutput->addModules( [ 'ext.cargo.timeline' ] );
26        $ce = SpecialPage::getTitleFor( 'CargoExport' );
27        $queryParams = $this->sqlQueriesToQueryParams( $sqlQueries );
28        $queryParams['format'] = 'timeline';
29        // $queryParams['color'] = array();
30        /* foreach ( $sqlQueries as $i => $sqlQuery ) {
31          if ( $querySpecificParams != null ) {
32          // Add any handling here.
33          }
34          } */
35
36        $height = CargoUtils::getCSSSize( $displayParams, 'height', '350px' );
37        $width = CargoUtils::getCSSSize( $displayParams, 'width', '100%' );
38
39        $attrs = [
40            'class' => 'cargoTimeline',
41            'dataurl' => $ce->getFullURL( $queryParams ),
42            'style' => "height: $height; width: $width; border: 1px solid #aaa;"
43        ];
44        $text = Html::rawElement( 'div', $attrs, '' );
45
46        return $text;
47    }
48
49}