Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -883,10 +883,11 @@ |
884 | 884 | * |
885 | 885 | * @param string $format |
886 | 886 | * @param array $paramValues The current values for the parameters (name => value) |
| 887 | + * @param array $ignoredattribs Attributes which should not be generated by this method. |
887 | 888 | * |
888 | 889 | * @return string |
889 | 890 | */ |
890 | | - protected function showFormatOptions( $format, array $paramValues ) { |
| 891 | + protected function showFormatOptions( $format, array $paramValues, $ignoredattribs = array() ) { |
891 | 892 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
892 | 893 | |
893 | 894 | $params = method_exists( $printer, 'getValidatorParameters' ) ? $printer->getValidatorParameters() : array(); |
— | — | @@ -894,8 +895,8 @@ |
895 | 896 | $optionsHtml = array(); |
896 | 897 | |
897 | 898 | foreach ( $params as $param ) { |
898 | | - // Ignore the format parameter, as we got a special control in the GUI for it already. |
899 | | - if ( $param->getName() == 'format' ) { |
| 899 | + // Ignore the parameters for which we have a special control in the GUI already. |
| 900 | + if ( in_array( $param->getName(), $ignoredattribs ) ) { |
900 | 901 | continue; |
901 | 902 | } |
902 | 903 | |
— | — | @@ -907,7 +908,7 @@ |
908 | 909 | array( |
909 | 910 | 'style' => 'width: 30%; padding: 5px; float: left;' |
910 | 911 | ), |
911 | | - htmlspecialchars( $param->getName() ) . ': ' . |
| 912 | + '<label for="p[' . htmlspecialchars( $param->getName() ) . ']">' . htmlspecialchars( $param->getName() ) . ': </label>' . |
912 | 913 | $this->showFormatOption( $param, $currentValue ) . |
913 | 914 | '<br />' . |
914 | 915 | Html::element( 'em', array(), $param->getDescription() ) |
— | — | @@ -923,7 +924,8 @@ |
924 | 925 | $i = 0; |
925 | 926 | $rowHtml = ''; |
926 | 927 | $resultHtml = ''; |
927 | | - |
| 928 | + $flip_style = true; |
| 929 | + $flip_count = 0; |
928 | 930 | while ( $option = array_shift( $optionsHtml ) ) { |
929 | 931 | $rowHtml .= $option; |
930 | 932 | $i++; |
— | — | @@ -931,12 +933,18 @@ |
932 | 934 | $resultHtml .= Html::rawElement( |
933 | 935 | 'div', |
934 | 936 | array( |
935 | | - 'style' => 'background: ' . ( $i % 6 == 0 ? 'white' : '#dddddd' ) . ';' |
| 937 | + 'style' => 'background: ' . ( $flip_style ? 'white' : '#dddddd' ) . ';' |
936 | 938 | ), |
937 | 939 | $rowHtml |
938 | 940 | ); |
939 | 941 | |
940 | 942 | $rowHtml = ''; |
| 943 | + $flip_count++; |
| 944 | + if ( $flip_count == 3 ) { |
| 945 | + $flip_style = !$flip_style; |
| 946 | + $flip_count = 0; |
| 947 | + } |
| 948 | + |
941 | 949 | } |
942 | 950 | |
943 | 951 | return $resultHtml; |
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -50,6 +50,21 @@ |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
| 54 | + * Displays a form section showing the options for a given format, |
| 55 | + * based on the getParameters() value for that format's query printer. |
| 56 | + * |
| 57 | + * @param string $format |
| 58 | + * @param array $paramValues The current values for the parameters (name => value) |
| 59 | + * @param array $ignoredattribs Attributes which should not be generated by this method. |
| 60 | + * |
| 61 | + * @return string |
| 62 | + * |
| 63 | + * Overridden from parent to ignore GUI parameters 'format' 'limit' and 'offset' |
| 64 | + */ |
| 65 | + protected function showFormatOptions( $format, array $paramValues, $ignoredattribs = array() ) { |
| 66 | + return parent::showFormatOptions( $format, $paramValues, array( 'format', 'limit', 'offset' ) ); |
| 67 | + } |
| 68 | + /** |
54 | 69 | * Creates the input form |
55 | 70 | * |
56 | 71 | * @global OutputPage $wgOut |
— | — | @@ -143,7 +158,9 @@ |
144 | 159 | if ( is_array( $display_values ) ) { |
145 | 160 | foreach ( $display_values as $key => $value ) { |
146 | 161 | if ( $value == '1' and array_key_exists( $key, $property_values ) ) { |
147 | | - $po[] = trim( $property_values[$key] ); |
| 162 | + $property_values[$key] = trim( $property_values[$key] ); |
| 163 | + $property_values[$key] = ( $property_values[$key][0] == '?' ) ? $property_values[$key]:'?' . $property_values[$key]; |
| 164 | + $po[] = $property_values[$key]; |
148 | 165 | } |
149 | 166 | |
150 | 167 | } |
— | — | @@ -297,7 +314,35 @@ |
298 | 315 | $javascript_text = <<<EOT |
299 | 316 | <script type="text/javascript"> |
300 | 317 | var num_elements = {$num_sort_values}; |
301 | | -// code for handling adding and removing the "sort" inputs |
| 318 | +EOT; |
| 319 | +// add autocomplete |
| 320 | + if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 321 | + $javascript_text .= <<<EOT |
| 322 | + |
| 323 | +function smw_property_autocomplete(){ |
| 324 | + jQuery('[name*="property"]').autocomplete({ |
| 325 | + minLength: 2, |
| 326 | + source: function(request, response) { |
| 327 | + url=wgScriptPath+'/api.php?action=opensearch&limit=10&namespace='+wgNamespaceIds['property']+'&format=jsonfm'; |
| 328 | + |
| 329 | + jQuery.getJSON(url, 'search='+request.term, function(data){ |
| 330 | + //remove the namespace prefix 'Property:' from returned data |
| 331 | + for(i=0;i<data[1].length;i++) data[1][i]='?'+data[1][i].substr(data[1][i].indexOf(':')+1); |
| 332 | + response(data[1]); |
| 333 | + }); |
| 334 | + |
| 335 | + } |
| 336 | + }); |
| 337 | +} |
| 338 | +EOT; |
| 339 | + } else { |
| 340 | + $javascript_text .= <<<EOT |
| 341 | +function smw_property_autocomplete(){ |
| 342 | +} |
| 343 | +EOT; |
| 344 | + } |
| 345 | + |
| 346 | + $javascript_text .= <<<EOT |
302 | 347 | function smw_prop_code_update(){ |
303 | 348 | code = '?'+\$j('#d-property')[0].value; |
304 | 349 | if(code!=''){ |
— | — | @@ -334,6 +379,7 @@ |
335 | 380 | \$j('#dialog').dialog.id=prop_id; |
336 | 381 | \$j('#dialog').dialog('open'); |
337 | 382 | } |
| 383 | +// code for handling adding and removing the "sort" inputs |
338 | 384 | function addPOInstance(starter_div_id, main_div_id) { |
339 | 385 | var starter_div = document.getElementById(starter_div_id); |
340 | 386 | var main_div = document.getElementById(main_div_id); |
— | — | @@ -367,6 +413,7 @@ |
368 | 414 | st='sort_div_'+num_elements; |
369 | 415 | jQuery('#'+new_div.id).find(".smw-remove a")[0].href="javascript:removePOInstance('"+st+"')"; |
370 | 416 | num_elements++; |
| 417 | + smw_property_autocomplete(); |
371 | 418 | } |
372 | 419 | |
373 | 420 | function removePOInstance(div_id) { |
— | — | @@ -396,29 +443,6 @@ |
397 | 444 | } |
398 | 445 | } |
399 | 446 | }); |
400 | | -}); |
401 | | - |
402 | | -jQuery(document).ready(function(){ |
403 | | -EOT; |
404 | | - if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
405 | | - $javascript_text .= <<<EOT |
406 | | - //add autocomplete |
407 | | - jQuery('[name*="property"]').autocomplete({ |
408 | | - minLength: 2, |
409 | | - source: function(request, response) { |
410 | | - url=wgScriptPath+'/api.php?action=opensearch&limit=10&namespace='+wgNamespaceIds['property']+'&format=jsonfm'; |
411 | | - |
412 | | - jQuery.getJSON(url, 'search='+request.term, function(data){ |
413 | | - //remove the namespace prefix 'Property:' from returned data |
414 | | - for(i=0;i<data[1].length;i++) data[1][i]='?'+data[1][i].substr(data[1][i].indexOf(':')+1); |
415 | | - response(data[1]); |
416 | | - }); |
417 | | - |
418 | | - } |
419 | | - }); |
420 | | -EOT; |
421 | | - } |
422 | | - $javascript_text .= <<<EOT |
423 | 447 | jQuery('#sort-more').click(function(){jQuery('#dialog').dialog("open");}); |
424 | 448 | jQuery('#dialog input').bind('keyup click', smw_prop_code_update ); |
425 | 449 | |
— | — | @@ -428,6 +452,7 @@ |
429 | 453 | }); |
430 | 454 | }); |
431 | 455 | |
| 456 | +jQuery(document).ready(smw_property_autocomplete); |
432 | 457 | </script> |
433 | 458 | |
434 | 459 | EOT; |