Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -186,17 +186,28 @@ |
187 | 187 | return $query; |
188 | 188 | } |
189 | 189 | |
| 190 | + /** |
| 191 | + * |
| 192 | + * |
| 193 | + * FIXME: show queries are not getting any results w/o passing any query condition |
| 194 | + * |
| 195 | + * @since 1.6.3 |
| 196 | + * |
| 197 | + * @param array $printRequests |
| 198 | + * @param array $rawParams |
| 199 | + * @param boolean $isShow |
| 200 | + */ |
190 | 201 | public static function addThisPrinteout( array &$printRequests, array $rawParams, $isShow = false ) { |
191 | | - $rawParams['mainlabel'] = ( !$isShow && array_key_exists( 'mainlabel', $rawParams ) ) ? $rawParams['mainlabel'] : false; |
192 | | - $noMainlabel = $rawParams['mainlabel'] === '-'; |
193 | | - // !$desc->isSingleton() || count( $printRequests ) == 0 ) && ( !$noMainlabel ) |
194 | | - |
195 | | - if ( !is_null( $printRequests ) && !$noMainlabel ) { |
196 | | - array_unshift( $printRequests, new SMWPrintRequest( |
197 | | - SMWPrintRequest::PRINT_THIS, |
198 | | - $rawParams['mainlabel'] |
199 | | - ) ); |
200 | | - } |
| 202 | + if ( !$isShow && !is_null( $printRequests ) ) { |
| 203 | + $hasMainlabel = array_key_exists( 'mainlabel', $rawParams ); |
| 204 | + |
| 205 | + if ( !$hasMainlabel || $rawParams['mainlabel'] === '-' ) { |
| 206 | + array_unshift( $printRequests, new SMWPrintRequest( |
| 207 | + SMWPrintRequest::PRINT_THIS, |
| 208 | + $hasMainlabel ? $rawParams['mainlabel'] : '' |
| 209 | + ) ); |
| 210 | + } |
| 211 | + } |
201 | 212 | } |
202 | 213 | |
203 | 214 | /** |
— | — | @@ -314,7 +325,7 @@ |
315 | 326 | */ |
316 | 327 | static public function getResultFromFunctionParams( array $rawparams, $outputmode, $context = self::INLINE_QUERY, $showmode = false ) { |
317 | 328 | self::processFunctionParams( $rawparams, $querystring, $params, $printouts, $showmode ); |
318 | | - self::addThisPrinteout( $printouts, $params ); |
| 329 | + self::addThisPrinteout( $printouts, $params, $showmode ); |
319 | 330 | $params = self::getProcessedParams( $params, $printouts ); |
320 | 331 | return self::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI, $context ); |
321 | 332 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_List.php |
— | — | @@ -18,43 +18,34 @@ |
19 | 19 | */ |
20 | 20 | class SMWListResultPrinter extends SMWResultPrinter { |
21 | 21 | |
22 | | - protected $mSep = ''; |
23 | | - protected $mTemplate = ''; |
24 | | - protected $mUserParam = ''; |
25 | | - protected $mColumns = 1; |
26 | | - protected $mIntroTemplate = ''; |
27 | | - protected $mOutroTemplate = ''; |
| 22 | + protected $mSep; |
| 23 | + protected $mTemplate; |
| 24 | + protected $mUserParam; |
| 25 | + protected $mColumns; |
| 26 | + protected $mIntroTemplate; |
| 27 | + protected $mOutroTemplate; |
28 | 28 | |
29 | | - protected function readParameters( $params, $outputmode ) { |
30 | | - parent::readParameters( $params, $outputmode ); |
31 | | - |
32 | | - if ( array_key_exists( 'sep', $params ) ) { |
33 | | - $this->mSep = str_replace( '_', ' ', $params['sep'] ); |
34 | | - } |
35 | | - |
36 | | - if ( array_key_exists( 'template', $params ) ) { |
37 | | - $this->mTemplate = trim( $params['template'] ); |
38 | | - } |
39 | | - |
40 | | - if ( array_key_exists( 'userparam', $params ) ) { |
41 | | - $this->mUserParam = trim( $params['userparam'] ); |
42 | | - } |
43 | | - |
44 | | - if ( array_key_exists( 'columns', $params ) ) { |
45 | | - $columns = trim( $params['columns'] ); |
46 | | - if ( $columns > 1 && $columns <= 10 ) { // allow a maximum of 10 columns |
47 | | - $this->mColumns = (int)$columns; |
48 | | - } |
49 | | - } |
50 | | - |
51 | | - if ( array_key_exists( 'introtemplate', $params ) ) { |
52 | | - $this->mIntroTemplate = $params['introtemplate']; |
53 | | - } |
54 | | - |
55 | | - if ( array_key_exists( 'outrotemplate', $params ) ) { |
56 | | - $this->mOutroTemplate = $params['outrotemplate']; |
57 | | - } |
| 29 | + public function __construct( $format, $inline, $useValidator = true ) { |
| 30 | + parent::__construct( $format, $inline ); |
| 31 | + $this->useValidator = $useValidator; |
58 | 32 | } |
| 33 | + |
| 34 | + /** |
| 35 | + * @see SMWResultPrinter::handleParameters |
| 36 | + * |
| 37 | + * @since 1.6 |
| 38 | + * |
| 39 | + * @param array $params |
| 40 | + * @param $outputmode |
| 41 | + */ |
| 42 | + protected function handleParameters( array $params, $outputmode ) { |
| 43 | + $this->mSep = $this->isPlainlist() ? $params['sep'] : ''; |
| 44 | + $this->mTemplate = trim( $params['template'] ); |
| 45 | + $this->mUserParam = trim( $params['userparam'] ); |
| 46 | + $this->mColumns = !$this->isPlainlist() ? $params['columns'] : 1; |
| 47 | + $this->mIntroTemplate = $params['introtemplate']; |
| 48 | + $this->mOutroTemplate = $params['outrotemplate']; |
| 49 | + } |
59 | 50 | |
60 | 51 | public function getName() { |
61 | 52 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
— | — | @@ -295,12 +286,14 @@ |
296 | 287 | $result .= $rowstart . ' '. $link->getText( SMW_OUTPUT_WIKI, $this->mLinker ) . $rowend; |
297 | 288 | } |
298 | 289 | |
| 290 | + protected function isPlainlist() { |
| 291 | + return $this->mFormat != 'ul' && $this->mFormat != 'ol'; |
| 292 | + } |
| 293 | + |
299 | 294 | public function getParameters() { |
300 | 295 | $params = array_merge( parent::getParameters(), parent::textDisplayParameters() ); |
301 | 296 | |
302 | | - $plainlist = ( $this->mFormat != 'ul' && $this->mFormat != 'ol' ); |
303 | | - |
304 | | - if ( $plainlist ) { |
| 297 | + if ( $this->isPlainlist() ) { |
305 | 298 | $params['sep'] = new Parameter( 'sep' ); |
306 | 299 | $params['sep']->setMessage( 'smw_paramdesc_sep' ); |
307 | 300 | $params['sep']->setDefault( '' ); |
— | — | @@ -310,10 +303,11 @@ |
311 | 304 | $params['template']->setMessage( 'smw_paramdesc_template' ); |
312 | 305 | $params['template']->setDefault( '' ); |
313 | 306 | |
314 | | - if ( !$plainlist ) { |
| 307 | + if ( !$this->isPlainlist() ) { |
315 | 308 | $params['columns'] = new Parameter( 'columns', Parameter::TYPE_INTEGER ); |
316 | 309 | $params['columns']->setMessage( 'smw_paramdesc_columns', 1 ); |
317 | | - $params['columns']->setDefault( '', false ); |
| 310 | + $params['columns']->setDefault( 1, false ); |
| 311 | + $params['columns']->addCriteria( new CriterionInRange( 1, 10 ) ); |
318 | 312 | } |
319 | 313 | |
320 | 314 | $params['userparam'] = new Parameter( 'userparam' ); |