Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php |
— | — | @@ -208,7 +208,7 @@ |
209 | 209 | $html .= '  ' . SMWInfolink::newBrowsingLink( '+', $result[0]->getShortHTMLText() )->getHTML( smwfGetLinker() ); |
210 | 210 | } |
211 | 211 | |
212 | | - if ( ( $this->value != $result[1] ) || $highlight ) { |
| 212 | + if ( is_object( $result[1] ) && ( ( $this->value != $result[1] ) || $highlight ) ) { |
213 | 213 | $html .= " <em><small>(" . $result[1]->getLongHTMLText( smwfGetLinker() ) . ")</small></em>"; |
214 | 214 | } |
215 | 215 | |
Index: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES |
— | — | @@ -5,6 +5,8 @@ |
6 | 6 | |
7 | 7 | * Use of native MediaWiki sortable tables for the table formats. |
8 | 8 | * Fixed separator and filename parameters for the DSV format. |
| 9 | +* Added definitions for missing params (sort, order, searchlabel) to the base query printer. |
| 10 | +* Added validation and manipulation of the format paremeter using Validator. |
9 | 11 | |
10 | 12 | == SMW 1.6.1 == |
11 | 13 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -36,9 +36,13 @@ |
37 | 37 | */ |
38 | 38 | static public function createQuery( $querystring, array $params, $context = self::INLINE_QUERY, $format = '', $extraprintouts = array() ) { |
39 | 39 | global $smwgQDefaultNamespaces, $smwgQFeatures, $smwgQConceptFeatures; |
40 | | - if ( $format == '' ) { |
41 | | - $format = self::getResultFormat( $params ); |
42 | | - } |
| 40 | + |
| 41 | + // TODO: this is a hack |
| 42 | + // Idially one round of Validation would be done through Validator on this level |
| 43 | + // instead of on query printer level and then have weirdness here. |
| 44 | + $formatParam = new SMWParamFormat(); |
| 45 | + $p = array(); |
| 46 | + $formatParam->doManipulation( $format, new Parameter( 'format' ), $p ); |
43 | 47 | |
44 | 48 | // parse query: |
45 | 49 | $queryfeatures = ( $context == self::CONCEPT_DESC ) ? $smwgQConceptFeatures : $smwgQFeatures; |
— | — | @@ -266,7 +270,7 @@ |
267 | 271 | static public function getResultFromQueryString( $querystring, array $params, $extraprintouts, $outputmode, $context = self::INLINE_QUERY ) { |
268 | 272 | wfProfileIn( 'SMWQueryProcessor::getResultFromQueryString (SMW)' ); |
269 | 273 | |
270 | | - $format = self::getResultFormat( $params ); |
| 274 | + $format = array_key_exists( 'format', $params ) ? $params['format'] : ''; |
271 | 275 | $query = self::createQuery( $querystring, $params, $context, $format, $extraprintouts ); |
272 | 276 | $result = self::getResultFromQuery( $query, $params, $extraprintouts, $outputmode, $context, $format ); |
273 | 277 | |
— | — | @@ -278,6 +282,13 @@ |
279 | 283 | static public function getResultFromQuery( SMWQuery $query, array $params, $extraprintouts, $outputmode, $context = self::INLINE_QUERY, $format = '' ) { |
280 | 284 | wfProfileIn( 'SMWQueryProcessor::getResultFromQuery (SMW)' ); |
281 | 285 | |
| 286 | + // TODO: this is a hack |
| 287 | + // Idially one round of Validation would be done through Validator on this level |
| 288 | + // instead of on query printer level and then have weirdness here. |
| 289 | + $formatParam = new SMWParamFormat(); |
| 290 | + $p = array(); |
| 291 | + $formatParam->doManipulation( $format, new Parameter( 'format' ), $p ); |
| 292 | + |
282 | 293 | // Query routing allows extensions to provide alternative stores as data sources |
283 | 294 | // The while feature is experimental and is not properly integrated with most of SMW's architecture. For instance, some query printers just fetch their own store. |
284 | 295 | // @todo FIXME: case-insensitive |
— | — | @@ -329,55 +340,6 @@ |
330 | 341 | } |
331 | 342 | |
332 | 343 | /** |
333 | | - * Determines the format from an array of parameters, and returns it. |
334 | | - * |
335 | | - * @param array $params |
336 | | - * |
337 | | - * @return string |
338 | | - */ |
339 | | - static protected function getResultFormat( array $params ) { |
340 | | - $format = 'auto'; |
341 | | - |
342 | | - if ( array_key_exists( 'format', $params ) ) { |
343 | | - global $smwgResultFormats; |
344 | | - |
345 | | - $format = strtolower( trim( $params['format'] ) ); |
346 | | - |
347 | | - if ( !array_key_exists( $format, $smwgResultFormats ) ) { |
348 | | - $isAlias = self::resolveFormatAliases( $format ); |
349 | | - if ( !$isAlias ) { |
350 | | - $format = 'auto'; // If it is an unknown format, defaults to list/table again |
351 | | - } |
352 | | - } |
353 | | - } |
354 | | - |
355 | | - return $format; |
356 | | - } |
357 | | - |
358 | | - /** |
359 | | - * Turns format aliases into main formats. |
360 | | - * |
361 | | - * @param string $format |
362 | | - * |
363 | | - * @return boolean Indicates if the passed format was an alias, and thus was changed. |
364 | | - */ |
365 | | - static protected function resolveFormatAliases( &$format ) { |
366 | | - global $smwgResultAliases; |
367 | | - |
368 | | - $isAlias = false; |
369 | | - |
370 | | - foreach ( $smwgResultAliases as $mainFormat => $aliases ) { |
371 | | - if ( in_array( $format, $aliases ) ) { |
372 | | - $format = $mainFormat; |
373 | | - $isAlias = true; |
374 | | - break; |
375 | | - } |
376 | | - } |
377 | | - |
378 | | - return $isAlias; |
379 | | - } |
380 | | - |
381 | | - /** |
382 | 344 | * Find suitable SMWResultPrinter for the given format. The context in which the query is to be |
383 | 345 | * used determines some basic settings of the returned printer object. Possible contexts are |
384 | 346 | * SMWQueryProcessor::SPECIAL_PAGE, SMWQueryProcessor::INLINE_QUERY, SMWQueryProcessor::CONCEPT_DESC. |
— | — | @@ -390,9 +352,6 @@ |
391 | 353 | static public function getResultPrinter( $format, $context = self::SPECIAL_PAGE ) { |
392 | 354 | global $smwgResultFormats; |
393 | 355 | |
394 | | - self::resolveFormatAliases( $format ); |
395 | | - |
396 | | - // TODO: this seems to contain the same logic as found in getResultFormat - a single function for this might be better. |
397 | 356 | $formatClass = array_key_exists( $format, $smwgResultFormats ) ? $smwgResultFormats[$format] : 'SMWAutoResultPrinter'; |
398 | 357 | |
399 | 358 | return new $formatClass( $format, ( $context != self::SPECIAL_PAGE ) ); |
Index: trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php |
— | — | @@ -0,0 +1,66 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation ensuring the value is an file url. |
| 6 | + * |
| 7 | + * @since 1.6.2 |
| 8 | + * |
| 9 | + * @file SMW_ParamFormat.php |
| 10 | + * @ingroup SMW |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * |
| 13 | + * @licence GNU GPL v3 |
| 14 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 15 | + */ |
| 16 | +class SMWParamFormat extends ItemParameterManipulation { |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor. |
| 20 | + * |
| 21 | + * @since 1.6.2 |
| 22 | + */ |
| 23 | + public function __construct() { |
| 24 | + parent::__construct(); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * @see ItemParameterManipulation::doManipulation |
| 29 | + * |
| 30 | + * @since 0.7 |
| 31 | + */ |
| 32 | + public function doManipulation( &$value, Parameter $parameter, array &$parameters ) { |
| 33 | + global $smwgResultFormats; |
| 34 | + |
| 35 | + if ( !array_key_exists( $value, $smwgResultFormats ) ) { |
| 36 | + $isAlias = self::resolveFormatAliases( $value ); |
| 37 | + |
| 38 | + if ( !$isAlias ) { |
| 39 | + $value = 'auto'; // If it is an unknown format, defaults to list/table again |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Turns format aliases into main formats. |
| 46 | + * |
| 47 | + * @param string $format |
| 48 | + * |
| 49 | + * @return boolean Indicates if the passed format was an alias, and thus was changed. |
| 50 | + */ |
| 51 | + static protected function resolveFormatAliases( &$format ) { |
| 52 | + global $smwgResultAliases; |
| 53 | + |
| 54 | + $isAlias = false; |
| 55 | + |
| 56 | + foreach ( $smwgResultAliases as $mainFormat => $aliases ) { |
| 57 | + if ( in_array( $format, $aliases ) ) { |
| 58 | + $format = $mainFormat; |
| 59 | + $isAlias = true; |
| 60 | + break; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + return $isAlias; |
| 65 | + } |
| 66 | + |
| 67 | +} |
Property changes on: trunk/extensions/SemanticMediaWiki/includes/params/SMW_ParamFormat.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 68 | + native |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php |
— | — | @@ -622,7 +622,10 @@ |
623 | 623 | /** |
624 | 624 | * A function to describe the allowed parameters of a query using |
625 | 625 | * any specific format - most query printers should override this |
626 | | - * function |
| 626 | + * function. |
| 627 | + * |
| 628 | + * TODO: refactor non-printer params up to the query processor |
| 629 | + * and do all param handling there. |
627 | 630 | * |
628 | 631 | * @since 1.5.0 |
629 | 632 | * |
— | — | @@ -631,7 +634,16 @@ |
632 | 635 | public function getParameters() { |
633 | 636 | $params = array(); |
634 | 637 | |
| 638 | + $allowedFormats = $GLOBALS['smwgResultFormats']; |
| 639 | + |
| 640 | + foreach ( $GLOBALS['smwgResultAliases'] as $aliases ) { |
| 641 | + $allowedFormats += $aliases; |
| 642 | + } |
| 643 | + |
635 | 644 | $params['format'] = new Parameter( 'format' ); |
| 645 | + $params['format']->setDefault( 'auto' ); |
| 646 | + //$params['format']->addCriteria( new CriterionInArray( $allowedFormats ) ); |
| 647 | + $params['format']->addManipulations( new SMWParamFormat() ); |
636 | 648 | |
637 | 649 | $params['limit'] = new Parameter( 'limit', Parameter::TYPE_INTEGER ); |
638 | 650 | $params['limit']->setMessage( 'smw_paramdesc_limit' ); |
— | — | @@ -660,10 +672,14 @@ |
661 | 673 | $params['mainlabel']->setDefault( false, false ); |
662 | 674 | |
663 | 675 | $params['link'] = new Parameter( 'link' ); |
664 | | - $params['link']->setMessage( 'smw_paramdesc_link' ); |
| 676 | + $params['link']->setMessage( 'smw_paramdesc_link' ); |
665 | 677 | $params['link']->addCriteria( new CriterionInArray( 'all', 'subject', 'none' ) ); |
666 | 678 | $params['link']->setDefault( 'all' ); |
667 | 679 | |
| 680 | + $params['searchlabel'] = new Parameter( 'searchlabel' ); |
| 681 | + $params['searchlabel']->setDefault( '' ); |
| 682 | + $params['searchlabel']->setMessage( 'smw-paramdesc-searchlabel' ); |
| 683 | + |
668 | 684 | return $params; |
669 | 685 | } |
670 | 686 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php |
— | — | @@ -231,7 +231,7 @@ |
232 | 232 | // Datavalues |
233 | 233 | $dvDir = $smwgIP . 'includes/datavalues/'; |
234 | 234 | $wgAutoloadClasses['SMWDataValue'] = $dvDir . 'SMW_DataValue.php'; |
235 | | - $wgAutoloadClasses['SMWContainerValue'] = $dvDir . 'SMW_DV_Container.php'; |
| 235 | + $wgAutoloadClasses['SMWContainerValue'] = $dvDir . 'SMW_DV_Container.php'; |
236 | 236 | $wgAutoloadClasses['SMWRecordValue'] = $dvDir . 'SMW_DV_Record.php'; |
237 | 237 | $wgAutoloadClasses['SMWErrorValue'] = $dvDir . 'SMW_DV_Error.php'; |
238 | 238 | $wgAutoloadClasses['SMWStringValue'] = $dvDir . 'SMW_DV_String.php'; |
— | — | @@ -239,7 +239,7 @@ |
240 | 240 | $wgAutoloadClasses['SMWPropertyValue'] = $dvDir . 'SMW_DV_Property.php'; |
241 | 241 | $wgAutoloadClasses['SMWURIValue'] = $dvDir . 'SMW_DV_URI.php'; |
242 | 242 | $wgAutoloadClasses['SMWTypesValue'] = $dvDir . 'SMW_DV_Types.php'; |
243 | | - $wgAutoloadClasses['SMWPropertyListValue'] = $dvDir . 'SMW_DV_PropertyList.php'; |
| 243 | + $wgAutoloadClasses['SMWPropertyListValue'] = $dvDir . 'SMW_DV_PropertyList.php'; |
244 | 244 | $wgAutoloadClasses['SMWNumberValue'] = $dvDir . 'SMW_DV_Number.php'; |
245 | 245 | $wgAutoloadClasses['SMWTemperatureValue'] = $dvDir . 'SMW_DV_Temperature.php'; |
246 | 246 | $wgAutoloadClasses['SMWQuantityValue'] = $dvDir . 'SMW_DV_Quantity.php'; |
— | — | @@ -256,11 +256,15 @@ |
257 | 257 | $wgAutoloadClasses['SMWExpLiteral'] = $expDir . 'SMW_Exp_Element.php'; |
258 | 258 | $wgAutoloadClasses['SMWExpResource'] = $expDir . 'SMW_Exp_Element.php'; |
259 | 259 | $wgAutoloadClasses['SMWExpNsResource'] = $expDir . 'SMW_Exp_Element.php'; |
260 | | - $wgAutoloadClasses['SMWExportController'] = $expDir . 'SMW_ExportController.php'; |
261 | | - $wgAutoloadClasses['SMWSerializer'] = $expDir . 'SMW_Serializer.php'; |
| 260 | + $wgAutoloadClasses['SMWExportController'] = $expDir . 'SMW_ExportController.php'; |
| 261 | + $wgAutoloadClasses['SMWSerializer'] = $expDir . 'SMW_Serializer.php'; |
262 | 262 | $wgAutoloadClasses['SMWRDFXMLSerializer'] = $expDir . 'SMW_Serializer_RDFXML.php'; |
263 | 263 | $wgAutoloadClasses['SMWTurtleSerializer'] = $expDir . 'SMW_Serializer_Turtle.php'; |
264 | 264 | |
| 265 | + // Parameter classes |
| 266 | + $parDir = $smwgIP . 'includes/params/'; |
| 267 | + $wgAutoloadClasses['SMWParamFormat'] = $parDir . 'SMW_ParamFormat.php'; |
| 268 | + |
265 | 269 | // Parser hooks |
266 | 270 | $phDir = $smwgIP . 'includes/parserhooks/'; |
267 | 271 | $wgAutoloadClasses['SMWAsk'] = $phDir . 'SMW_Ask.php'; |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -95,6 +95,7 @@ |
96 | 96 | 'smw-smwdoc-par-format' => 'The result format to display parameter documentation for.', |
97 | 97 | 'smw-paramdesc-sort' => 'Property to sort the query by', |
98 | 98 | 'smw-paramdesc-order' => 'Order of the query sort', |
| 99 | + 'smw-paramdesc-searchlabel' => 'Text for continuing the search (default is «… further results»)', |
99 | 100 | |
100 | 101 | // Messages and strings for inline queries |
101 | 102 | 'smw_iq_disabled' => "Semantic queries have been disabled for this wiki.", |