r98087 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98086‎ | r98087 | r98088 >
Date:22:10, 25 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
migrate param handling
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RSSlink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RSSlink.php
@@ -10,34 +10,36 @@
1111 *
1212 * @author Denny Vrandecic
1313 * @author Markus Krötzsch
 14+ *
1415 * @ingroup SMWQuery
1516 */
1617 class SMWRSSResultPrinter extends SMWResultPrinter {
 18+
1719 protected $m_title = '';
1820 protected $m_description = '';
1921
20 - protected function readParameters( $params, $outputmode ) {
21 - parent::readParameters( $params, $outputmode );
22 - if ( array_key_exists( 'title', $this->m_params ) ) {
23 - $this->m_title = trim( $this->m_params['title'] );
24 - // for backward compatibiliy
25 - } elseif ( array_key_exists( 'rsstitle', $this->m_params ) ) {
26 - $this->m_title = trim( $this->m_params['rsstitle'] );
27 - }
28 - if ( array_key_exists( 'description', $this->m_params ) ) {
29 - $this->m_description = trim( $this->m_params['description'] );
30 - // for backward compatibiliy
31 - } elseif ( array_key_exists( 'rssdescription', $this->m_params ) ) {
32 - $this->m_description = trim( $this->m_params['rssdescription'] );
33 - }
 22+ /**
 23+ * @see SMWResultPrinter::handleParameters
 24+ *
 25+ * @since 1.6.3
 26+ *
 27+ * @param array $params
 28+ * @param $outputmode
 29+ */
 30+ protected function handleParameters( array $params, $outputmode ) {
 31+ parent::handleParameters( $params, $outputmode );
 32+
 33+ $this->m_title = trim( $params['title'] );
 34+ $this->m_description = trim( $params['description'] );
3435 }
35 -
 36+
3637 public function getMimeType( $res ) {
37 - return 'application/rss+xml'; // or is rdf+xml better? Might be confused in either case (with RSS2.0 or RDF)
 38+ // or is rdf+xml better? Might be confused in either case (with RSS2.0 or RDF)
 39+ return 'application/rss+xml';
3840 }
3941
4042 public function getQueryMode( $context ) {
41 - return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ? SMWQuery::MODE_INSTANCES:SMWQuery::MODE_NONE;
 43+ return $context == SMWQueryProcessor::SPECIAL_PAGE ? SMWQuery::MODE_INSTANCES : SMWQuery::MODE_NONE;
4244 }
4345
4446 public function getName() {
@@ -153,9 +155,11 @@
154156
155157 $params['title'] = new Parameter( 'title' );
156158 $params['title']->setMessage( 'smw_paramdesc_rsstitle' );
 159+ $params['title']->setDefault( '' );
157160
158161 $params['description'] = new Parameter( 'title' );
159162 $params['description']->setMessage( 'smw_paramdesc_rssdescription' );
 163+ $params['description']->setDefault( '' );
160164
161165 return $params;
162166 }
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Table.php
@@ -13,11 +13,6 @@
1414
1515 protected $mHTMLClass = '';
1616
17 - public function __construct( $format, $inline, $useValidator = true ) {
18 - parent::__construct( $format, $inline );
19 - $this->useValidator = $useValidator;
20 - }
21 -
2217 public function getName() {
2318 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
2419 return wfMsg( 'smw_printername_' . $this->mFormat );
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php
@@ -296,6 +296,7 @@
297297 */
298298 protected function handleParameters( array $params, $outputmode ) {
299299 $this->params = $params;
 300+ $this->m_params = $params; // Compat, change made in 1.6.3
300301
301302 if ( array_key_exists( 'intro', $params ) ) { $this->mIntro = $params['intro']; }
302303 if ( array_key_exists( 'outro', $params ) ) { $this->mOutro = $params['outro']; }
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php
@@ -94,14 +94,14 @@
9595 $link->setParameter( 'csv', 'format' );
9696 $link->setParameter( $this->m_sep, 'sep' );
9797
98 - if ( array_key_exists( 'mainlabel', $this->m_params ) && $this->m_params['mainlabel'] !== false ) {
99 - $link->setParameter( $this->m_params['mainlabel'], 'mainlabel' );
 98+ if ( array_key_exists( 'mainlabel', $this->params ) && $this->params['mainlabel'] !== false ) {
 99+ $link->setParameter( $this->params['mainlabel'], 'mainlabel' );
100100 }
101101
102102 $link->setParameter( $this->mShowHeaders ? 'show' : 'hide', 'headers' );
103103
104 - if ( array_key_exists( 'limit', $this->m_params ) ) {
105 - $link->setParameter( $this->m_params['limit'], 'limit' );
 104+ if ( array_key_exists( 'limit', $this->params ) ) {
 105+ $link->setParameter( $this->params['limit'], 'limit' );
106106 } else { // use a reasonable default limit
107107 $link->setParameter( 100, 'limit' );
108108 }
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
@@ -251,8 +251,8 @@
252252
253253 if ( $this->mTemplate != '' ) {
254254 $link->setParameter( $this->mTemplate, 'template' );
255 - if ( array_key_exists( 'link', $this->m_params ) ) { // linking may interfere with templates
256 - $link->setParameter( $this->m_params['link'], 'link' );
 255+ if ( array_key_exists( 'link', $this->params ) ) { // linking may interfere with templates
 256+ $link->setParameter( $this->params['link'], 'link' );
257257 }
258258 }
259259
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_RDF.php
@@ -102,8 +102,8 @@
103103 $link->setParameter( 'rdf', 'format' );
104104 $link->setParameter( $this->syntax, 'syntax' );
105105
106 - if ( array_key_exists( 'limit', $this->m_params ) ) {
107 - $link->setParameter( $this->m_params['limit'], 'limit' );
 106+ if ( array_key_exists( 'limit', $this->params ) ) {
 107+ $link->setParameter( $this->params['limit'], 'limit' );
108108 } else { // use a reasonable default limit
109109 $link->setParameter( 100, 'limit' );
110110 }