r99849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99848‎ | r99849 | r99850 >
Date:08:29, 15 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
smw 1.7 compat
Modified paths:
  • /trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php
@@ -7,41 +7,29 @@
88 */
99
1010 class SRFjqPlotBar extends SMWResultPrinter {
 11+
 12+ protected static $m_barchartnum = 1;
 13+
1114 protected $m_width = '150';
1215 protected $m_height = '400';
1316 protected $m_charttitle = ' ';
1417 protected $m_barcolor = '#85802b' ;
1518 protected $m_bardirection = 'vertical';
1619 protected $m_numbersaxislabel = ' ';
17 - static protected $m_barchartnum = 1;
1820
19 - protected function readParameters( $params, $outputmode ) {
20 - parent::readParameters( $params, $outputmode );
21 - if ( array_key_exists( 'width', $this->m_params ) ) {
22 - $this->m_width = $this->m_params['width'];
23 - }
24 - if ( array_key_exists( 'height', $this->m_params ) ) {
25 - $this->m_height = $this->m_params['height'];
26 - }
27 - if ( array_key_exists( 'charttitle', $this->m_params ) ) {
28 - $this->m_charttitle = $this->m_params['charttitle'];
29 - }
30 - if ( array_key_exists( 'barcolor', $this->m_params ) ) {
31 - $this->m_barcolor = $this->m_params['barcolor'];
32 - }
33 - if ( array_key_exists( 'bardirection', $this->m_params ) ) {
34 - // keep it simple - only 'horizontal' makes sense as
35 - // an alternate value
36 - if ( $this->m_params['bardirection'] == 'horizontal' ) {
37 - $this->m_bardirection = $this->m_params['bardirection'];
38 - }
39 - }
40 - else{
41 - $this->m_bardirection = 'vertical';
42 - }
43 - if ( array_key_exists( 'numbersaxislabel', $this->m_params ) ) {
44 - $this->m_numbersaxislabel = $this->m_params['numbersaxislabel'];
45 - }
 21+ /**
 22+ * (non-PHPdoc)
 23+ * @see SMWResultPrinter::handleParameters()
 24+ */
 25+ protected function handleParameters( array $params, $outputmode ) {
 26+ parent::handleParameters( $params, $outputmode );
 27+
 28+ $this->m_width = $this->m_params['width'];
 29+ $this->m_height = $this->m_params['height'];
 30+ $this->m_charttitle = $this->m_params['charttitle'];
 31+ $this->m_barcolor = $this->m_params['barcolor'];
 32+ $this->m_bardirection = $this->m_params['bardirection'];
 33+ $this->m_numbersaxislabel = $this->m_params['numbersaxislabel'];
4634 }
4735
4836 public function getName() {
@@ -278,15 +266,28 @@
279267 }
280268
281269 public function getParameters() {
282 - return array(
283 - array( 'name' => 'limit', 'type' => 'int', 'description' => wfMsg( 'smw_paramdesc_limit' ) ),
284 - array( 'name' => 'height', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_chartheight' ) ),
285 - array( 'name' => 'charttitle', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_charttitle' ) ),
286 - array( 'name' => 'barcolor', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_barcolor' ) ),
287 - array( 'name' => 'bardirection', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_bardirection' ),'values' => array('horizontal', 'vertical')),
288 - array( 'name' => 'numbersaxislabel', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_barnumbersaxislabel' ) ),
289 - array( 'name' => 'width', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_chartwidth' ) ),
290 - );
 270+ $params = parent::getParameters();
 271+
 272+ $params['height'] = new Parameter( 'height', Parameter::TYPE_INTEGER, 400 );
 273+ $params['height']->setMessage( 'srf_paramdesc_chartheight' );
 274+
 275+ $params['width'] = new Parameter( 'height', Parameter::TYPE_INTEGER, 150 );
 276+ $params['width']->setMessage( 'srf_paramdesc_chartwidth' );
 277+
 278+ $params['charttitle'] = new Parameter( 'charttitle', Parameter::TYPE_STRING, ' ' );
 279+ $params['charttitle']->setMessage( 'srf_paramdesc_charttitle' );
 280+
 281+ $params['barcolor'] = new Parameter( 'barcolor', Parameter::TYPE_STRING, '#85802b' );
 282+ $params['barcolor']->setMessage( 'srf_paramdesc_barcolor' );
 283+
 284+ $params['bardirection'] = new Parameter( 'bardirection', Parameter::TYPE_STRING, 'vertical' );
 285+ $params['bardirection']->setMessage( 'srf_paramdesc_bardirection' );
 286+ $params['bardirection']->addCriteria( new CriterionInArray( 'horizontal', 'vertical' ) );
 287+
 288+ $params['numbersaxislabel'] = new Parameter( 'numbersaxislabel', Parameter::TYPE_STRING, ' ' );
 289+ $params['numbersaxislabel']->setMessage( 'srf_paramdesc_barnumbersaxislabel' );
 290+
 291+ return $params;
291292 }
292293
293294 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r99850Follow up to r99849;jeroendedauw08:34, 15 October 2011
r99852Follow up to r99849;jeroendedauw08:45, 15 October 2011