http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97994
Revision: 97994
Author: jeroendedauw
Date: 2011-09-24 12:15:01 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
fixed mainlabel handling for show and migrated list qp to new param handling
system
Modified Paths:
--------------
trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
Modified: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
2011-09-24 11:57:59 UTC (rev 97993)
+++ trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
2011-09-24 12:15:01 UTC (rev 97994)
@@ -186,17 +186,28 @@
return $query;
}
+ /**
+ *
+ *
+ * FIXME: show queries are not getting any results w/o passing any
query condition
+ *
+ * @since 1.6.3
+ *
+ * @param array $printRequests
+ * @param array $rawParams
+ * @param boolean $isShow
+ */
public static function addThisPrinteout( array &$printRequests, array
$rawParams, $isShow = false ) {
- $rawParams['mainlabel'] = ( !$isShow && array_key_exists(
'mainlabel', $rawParams ) ) ? $rawParams['mainlabel'] : false;
- $noMainlabel = $rawParams['mainlabel'] === '-';
- // !$desc->isSingleton() || count( $printRequests ) == 0 ) && (
!$noMainlabel )
-
- if ( !is_null( $printRequests ) && !$noMainlabel ) {
- array_unshift( $printRequests, new SMWPrintRequest(
- SMWPrintRequest::PRINT_THIS,
- $rawParams['mainlabel']
- ) );
- }
+ if ( !$isShow && !is_null( $printRequests ) ) {
+ $hasMainlabel = array_key_exists( 'mainlabel',
$rawParams );
+
+ if ( !$hasMainlabel || $rawParams['mainlabel'] === '-'
) {
+ array_unshift( $printRequests, new
SMWPrintRequest(
+ SMWPrintRequest::PRINT_THIS,
+ $hasMainlabel ? $rawParams['mainlabel']
: ''
+ ) );
+ }
+ }
}
/**
@@ -314,7 +325,7 @@
*/
static public function getResultFromFunctionParams( array $rawparams,
$outputmode, $context = self::INLINE_QUERY, $showmode = false ) {
self::processFunctionParams( $rawparams, $querystring, $params,
$printouts, $showmode );
- self::addThisPrinteout( $printouts, $params );
+ self::addThisPrinteout( $printouts, $params, $showmode );
$params = self::getProcessedParams( $params, $printouts );
return self::getResultFromQueryString( $querystring, $params,
$printouts, SMW_OUTPUT_WIKI, $context );
}
Modified:
trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
2011-09-24 11:57:59 UTC (rev 97993)
+++ trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php
2011-09-24 12:15:01 UTC (rev 97994)
@@ -18,43 +18,34 @@
*/
class SMWListResultPrinter extends SMWResultPrinter {
- protected $mSep = '';
- protected $mTemplate = '';
- protected $mUserParam = '';
- protected $mColumns = 1;
- protected $mIntroTemplate = '';
- protected $mOutroTemplate = '';
+ protected $mSep;
+ protected $mTemplate;
+ protected $mUserParam;
+ protected $mColumns;
+ protected $mIntroTemplate;
+ protected $mOutroTemplate;
- protected function readParameters( $params, $outputmode ) {
- parent::readParameters( $params, $outputmode );
-
- if ( array_key_exists( 'sep', $params ) ) {
- $this->mSep = str_replace( '_', ' ', $params['sep'] );
- }
-
- 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 ) ) {
- $columns = trim( $params['columns'] );
- if ( $columns > 1 && $columns <= 10 ) { // allow a
maximum of 10 columns
- $this->mColumns = (int)$columns;
- }
- }
-
- if ( array_key_exists( 'introtemplate', $params ) ) {
- $this->mIntroTemplate = $params['introtemplate'];
- }
-
- if ( array_key_exists( 'outrotemplate', $params ) ) {
- $this->mOutroTemplate = $params['outrotemplate'];
- }
+ public function __construct( $format, $inline, $useValidator = true ) {
+ parent::__construct( $format, $inline );
+ $this->useValidator = $useValidator;
}
+
+ /**
+ * @see SMWResultPrinter::handleParameters
+ *
+ * @since 1.6
+ *
+ * @param array $params
+ * @param $outputmode
+ */
+ protected function handleParameters( array $params, $outputmode ) {
+ $this->mSep = $this->isPlainlist() ? $params['sep'] : '';
+ $this->mTemplate = trim( $params['template'] );
+ $this->mUserParam = trim( $params['userparam'] );
+ $this->mColumns = !$this->isPlainlist() ? $params['columns'] :
1;
+ $this->mIntroTemplate = $params['introtemplate'];
+ $this->mOutroTemplate = $params['outrotemplate'];
+ }
public function getName() {
smwfLoadExtensionMessages( 'SemanticMediaWiki' );
@@ -295,12 +286,14 @@
$result .= $rowstart . ' '. $link->getText( SMW_OUTPUT_WIKI,
$this->mLinker ) . $rowend;
}
+ protected function isPlainlist() {
+ return $this->mFormat != 'ul' && $this->mFormat != 'ol';
+ }
+
public function getParameters() {
$params = array_merge( parent::getParameters(),
parent::textDisplayParameters() );
- $plainlist = ( $this->mFormat != 'ul' && $this->mFormat != 'ol'
);
-
- if ( $plainlist ) {
+ if ( $this->isPlainlist() ) {
$params['sep'] = new Parameter( 'sep' );
$params['sep']->setMessage( 'smw_paramdesc_sep' );
$params['sep']->setDefault( '' );
@@ -310,10 +303,11 @@
$params['template']->setMessage( 'smw_paramdesc_template' );
$params['template']->setDefault( '' );
- if ( !$plainlist ) {
+ if ( !$this->isPlainlist() ) {
$params['columns'] = new Parameter( 'columns',
Parameter::TYPE_INTEGER );
$params['columns']->setMessage(
'smw_paramdesc_columns', 1 );
- $params['columns']->setDefault( '', false );
+ $params['columns']->setDefault( 1, false );
+ $params['columns']->addCriteria( new CriterionInRange(
1, 10 ) );
}
$params['userparam'] = new Parameter( 'userparam' );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs