r97507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97506‎ | r97507 | r97508 >
Date:15:34, 19 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
have the category format use new style param handling and fix bug 30761
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES
@@ -14,6 +14,7 @@
1515 * Fixed display of properties of type URL (bug 30912).
1616 * Fixed hide query functionality on Special:Ask (bug 30768).
1717 * Fixed display of internal SMW helper constants in certain queries (bug 30969).
 18+* Fixed some issue with the category result format (including bug 30761).
1819
1920 == SMW 1.6.1 ==
2021
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
@@ -3,8 +3,11 @@
44 * Print query results in alphabetic groups displayed in columns, a la the
55 * standard Category pages and the default view in Semantic Drilldown.
66 * Based on SMW_QP_List by Markus Krötzsch.
 7+ *
78 * @author David Loomer
89 * @author Yaron Koren
 10+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 11+ *
912 * @file
1013 * @ingroup SMWQuery
1114 */
@@ -16,28 +19,32 @@
1720 */
1821 class SMWCategoryResultPrinter extends SMWResultPrinter {
1922
20 - protected $mDelim = ',';
21 - protected $mTemplate = '';
22 - protected $mUserParam = '';
23 - protected $mNumColumns = 3;
 23+ protected $mDelim;
 24+ protected $mTemplate;
 25+ protected $mUserParam;
 26+ protected $mNumColumns;
2427
25 - protected function readParameters( $params, $outputmode ) {
26 - parent::readParameters( $params, $outputmode );
27 -
28 - if ( array_key_exists( 'delim', $params ) ) {
29 - $this->mDelim = str_replace( '_', ' ', $params['delim'] );
30 - }
31 - if ( array_key_exists( 'template', $params ) ) {
32 - $this->mTemplate = trim( $params['template'] );
33 - }
34 - if ( array_key_exists( 'userparam', $params ) ) {
35 - $this->mUserParam = trim( $params['userparam'] );
36 - }
37 - if ( array_key_exists( 'columns', $params ) ) {
38 - $this->mNumColumns = (int)$params['columns'];
39 - }
 28+ public function __construct( $format, $inline, $useValidator = true ) {
 29+ parent::__construct( $format, $inline, $useValidator );
4030 }
41 -
 31+
 32+ /**
 33+ * @see SMWResultPrinter::handleParameters
 34+ *
 35+ * @since 1.6.2
 36+ *
 37+ * @param array $params
 38+ * @param $outputmode
 39+ */
 40+ protected function handleParameters( array $params, $outputmode ) {
 41+ parent::handleParameters( $params, $outputmode );
 42+
 43+ $this->mUserParam = trim( $params['userparam'] );
 44+ $this->mDelim = trim( $params['delim'] );
 45+ $this->mNumColumns = $params['columns'];
 46+ $this->mTemplate = $params['template'];
 47+ }
 48+
4249 public function getName() {
4350 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
4451 return wfMsg( 'smw_printername_' . $this->mFormat );
@@ -186,8 +193,20 @@
187194
188195 $params['columns'] = new Parameter( 'columns', Parameter::TYPE_INTEGER );
189196 $params['columns']->setDescription( wfMsg( 'smw_paramdesc_columns', 3 ) );
190 - $params['columns']->setDefault( '', false );
 197+ $params['columns']->setDefault( 3, false );
191198
 199+ $params['delim'] = new Parameter( 'delim' );
 200+ $params['delim']->setDescription( wfMsg( 'smw-paramdesc-category-delim' ) );
 201+ $params['delim']->setDefault( ',' );
 202+
 203+ $params['template'] = new Parameter( 'template' );
 204+ $params['template']->setDescription( wfMsg( 'smw-paramdesc-category-template' ) );
 205+ $params['template']->setDefault( '' );
 206+
 207+ $params['userparam'] = new Parameter( 'userparam' );
 208+ $params['userparam']->setDescription( wfMsg( 'smw-paramdesc-category-userparam' ) );
 209+ $params['userparam']->setDefault( '' );
 210+
192211 return $params;
193212 }
194213
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -375,6 +375,11 @@
376376 'smw_adminlinks_datastructure' => 'Data structure',
377377 'smw_adminlinks_displayingdata' => 'Data display',
378378 'smw_adminlinks_inlinequerieshelp' => 'Inline queries help',
 379+
 380+ // Category QP
 381+ 'smw-paramdesc-category-delim' => 'The delimiter',
 382+ 'smw-paramdesc-category-template' => 'A template to format the items with',
 383+ 'smw-paramdesc-category-userparam' => 'A parameter to pass to the template',
379384 );
380385
381386 /** Message documentation (Message documentation)

Sign-offs

UserFlagDate
Nikerabbitinspected17:15, 19 September 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r97535fix bug 30761jeroendedauw18:45, 19 September 2011
r114317Fix for r97507 - default for 'delim' parameter is ''yaron21:51, 20 March 2012