http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97507

Revision: 97507
Author:   jeroendedauw
Date:     2011-09-19 15:34:24 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
have the category format use new style param handling and fix bug 30761

Modified Paths:
--------------
    trunk/extensions/SemanticMediaWiki/RELEASE-NOTES
    
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
    trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php

Modified: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES
===================================================================
--- trunk/extensions/SemanticMediaWiki/RELEASE-NOTES    2011-09-19 15:32:58 UTC 
(rev 97506)
+++ trunk/extensions/SemanticMediaWiki/RELEASE-NOTES    2011-09-19 15:34:24 UTC 
(rev 97507)
@@ -14,6 +14,7 @@
 * Fixed display of properties of type URL (bug 30912).
 * Fixed hide query functionality on Special:Ask (bug 30768).
 * Fixed display of internal SMW helper constants in certain queries (bug 
30969).
+* Fixed some issue with the category result format (including bug 30761).
 
 == SMW 1.6.1 ==
 

Modified: 
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php
===================================================================
--- 
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php   
    2011-09-19 15:32:58 UTC (rev 97506)
+++ 
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Category.php   
    2011-09-19 15:34:24 UTC (rev 97507)
@@ -3,8 +3,11 @@
  * Print query results in alphabetic groups displayed in columns, a la the
  * standard Category pages and the default view in Semantic Drilldown.
  * Based on SMW_QP_List by Markus Krötzsch.
+ * 
  * @author David Loomer
  * @author Yaron Koren
+ * @author Jeroen De Dauw < [email protected] >
+ * 
  * @file
  * @ingroup SMWQuery
  */
@@ -16,28 +19,32 @@
  */
 class SMWCategoryResultPrinter extends SMWResultPrinter {
 
-       protected $mDelim = ',';
-       protected $mTemplate = '';
-       protected $mUserParam = '';
-       protected $mNumColumns = 3;
+       protected $mDelim;
+       protected $mTemplate;
+       protected $mUserParam;
+       protected $mNumColumns;
 
-       protected function readParameters( $params, $outputmode ) {
-               parent::readParameters( $params, $outputmode );
-
-               if ( array_key_exists( 'delim', $params ) ) {
-                       $this->mDelim = str_replace( '_', ' ', $params['delim'] 
);
-               }
-               if ( array_key_exists( 'template', $params ) ) {
-                       $this->mTemplate = trim( $params['template'] );
-               }
-               if ( array_key_exists( 'userparam', $params ) ) {
-                       $this->mUserParam = trim( $params['userparam'] );
-               }
-               if ( array_key_exists( 'columns', $params ) ) {
-                       $this->mNumColumns = (int)$params['columns'];
-               }
+       public function __construct( $format, $inline, $useValidator = true ) {
+               parent::__construct( $format, $inline, $useValidator );
        }
-
+       
+       /**
+        * @see SMWResultPrinter::handleParameters
+        * 
+        * @since 1.6.2
+        * 
+        * @param array $params
+        * @param $outputmode
+        */
+       protected function handleParameters( array $params, $outputmode ) {
+               parent::handleParameters( $params, $outputmode );
+               
+               $this->mUserParam = trim( $params['userparam'] );
+               $this->mDelim = trim( $params['delim'] );
+               $this->mNumColumns = $params['columns'];
+               $this->mTemplate = $params['template'];
+       }       
+       
        public function getName() {
                smwfLoadExtensionMessages( 'SemanticMediaWiki' );
                return wfMsg( 'smw_printername_' . $this->mFormat );
@@ -186,8 +193,20 @@
                
                $params['columns'] = new Parameter( 'columns', 
Parameter::TYPE_INTEGER );
                $params['columns']->setDescription( wfMsg( 
'smw_paramdesc_columns', 3 ) );
-               $params['columns']->setDefault( '', false );
+               $params['columns']->setDefault( 3, false );
                
+               $params['delim'] = new Parameter( 'delim' );
+               $params['delim']->setDescription( wfMsg( 
'smw-paramdesc-category-delim' ) );
+               $params['delim']->setDefault( ',' );
+               
+               $params['template'] = new Parameter( 'template' );
+               $params['template']->setDescription( wfMsg( 
'smw-paramdesc-category-template' ) );
+               $params['template']->setDefault( '' );
+               
+               $params['userparam'] = new Parameter( 'userparam' );
+               $params['userparam']->setDescription( wfMsg( 
'smw-paramdesc-category-userparam' ) );
+               $params['userparam']->setDefault( '' );
+               
                return $params;
        }
 

Modified: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php       
2011-09-19 15:32:58 UTC (rev 97506)
+++ trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php       
2011-09-19 15:34:24 UTC (rev 97507)
@@ -375,6 +375,11 @@
        'smw_adminlinks_datastructure' => 'Data structure',
        'smw_adminlinks_displayingdata' => 'Data display',
        'smw_adminlinks_inlinequerieshelp' => 'Inline queries help',
+       
+       // Category QP
+       'smw-paramdesc-category-delim' => 'The delimiter',
+       'smw-paramdesc-category-template' => 'A template to format the items 
with',
+       'smw-paramdesc-category-userparam' => 'A parameter to pass to the 
template',
 );
 
 /** Message documentation (Message documentation)


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to