Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | 'format' => $wgRequest->getVal( 'format' ), |
70 | 70 | 'offset' => $wgRequest->getVal( 'offset', '0' ), |
71 | 71 | 'limit' => $wgRequest->getVal( 'limit', '20' ) ), |
72 | | - $this->processSortedPOFormBox( $wgRequest ), |
| 72 | + $this->processPoSortFormBox( $wgRequest ), |
73 | 73 | $this->processFormatSelectBox( $wgRequest ) ); |
74 | 74 | $this->uiCore = SMWQueryUIHelper::makeForUI( |
75 | 75 | $this->processQueryFormBox( $wgRequest ), |
— | — | @@ -326,13 +326,12 @@ |
327 | 327 | * complement processQueryFormBox() to decode data sent through these elements. |
328 | 328 | * UI's may overload both to change form parameters. |
329 | 329 | * |
330 | | - * @param string $contents |
331 | 330 | * @param string $errors |
332 | 331 | * @return string |
333 | 332 | */ |
334 | | - protected function getQueryFormBox( $content, $errors = '' ) { |
| 333 | + protected function getQueryFormBox( $errors = '' ) { |
335 | 334 | $result = ''; |
336 | | - $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox', 'rows' => '6' ), $content ); |
| 335 | + $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox', 'rows' => '6' ), $this->uiCore->getQueryString() ); |
337 | 336 | // TODO:enable/disable on checking for errors; perhaps show error messages right below the box |
338 | 337 | return $result; |
339 | 338 | } |
— | — | @@ -353,12 +352,12 @@ |
354 | 353 | |
355 | 354 | /** |
356 | 355 | * Generates the forms elements(s) for choosing printouts and sorting |
357 | | - * options. Use its complement processSortedPOFormBox() to decode data |
| 356 | + * options. Use its complement processPoSortFormBox() to decode data |
358 | 357 | * sent by these elements. |
359 | 358 | * |
360 | 359 | * @return string |
361 | 360 | */ |
362 | | - protected function getSortedPOFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 361 | + protected function getPoSortFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
363 | 362 | global $smwgQSortingSupport, $wgRequest, $wgOut; |
364 | 363 | |
365 | 364 | if ( !$smwgQSortingSupport ) return ''; |
— | — | @@ -386,7 +385,7 @@ |
387 | 386 | * be removed. This is a bit of a hack, converting all strings to |
388 | 387 | * lowercase to simplify searching procedure and using in_array. |
389 | 388 | */ |
390 | | - |
| 389 | + |
391 | 390 | $po = explode( '?', $this->getPOStrings() ); |
392 | 391 | reset( $po ); |
393 | 392 | foreach ( $po as $key => $value ) { |
— | — | @@ -425,12 +424,12 @@ |
426 | 425 | $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i" ) ) . 'Property '; // TODO: add i18n |
427 | 426 | $result .= Html::input( 'property[' . $i . ']', $property_value, 'text', array( 'size' => '35' ) ) . "\n"; |
428 | 427 | $result .= html::openElement( 'select', array( 'name' => "order[$i]" ) ); |
429 | | - if ( !is_array( $order_values ) or !array_key_exists( $i, $order_values ) or $order_values[$i] == 'NONE'){ |
| 428 | + if ( !is_array( $order_values ) or !array_key_exists( $i, $order_values ) or $order_values[$i] == 'NONE' ) { |
430 | 429 | $result .= '<option selected value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n |
431 | 430 | } else { |
432 | 431 | $result .= '<option value="NONE">' . 'No sorting' . "</option>\n"; // TODO: add i18n |
433 | 432 | } |
434 | | - if(is_array( $order_values ) and array_key_exists( $i, $order_values ) and $order_values[$i] == 'ASC' ) { |
| 433 | + if ( is_array( $order_values ) and array_key_exists( $i, $order_values ) and $order_values[$i] == 'ASC' ) { |
435 | 434 | $result .= '<option selected value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
436 | 435 | } else { |
437 | 436 | $result .= '<option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
— | — | @@ -442,9 +441,9 @@ |
443 | 442 | } |
444 | 443 | $result .= "</select> \n"; |
445 | 444 | if ( is_array( $display_values ) and array_key_exists( $i, $display_values ) ) { |
446 | | - $result .= 'show in results: <input type="checkbox" checked name="display[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n |
| 445 | + $result .= '<input type="checkbox" checked name="display[' . $i . ']" value="yes">show in results' . "\n"; // TODO: add i18n |
447 | 446 | } else { |
448 | | - $result .= 'show in results: <input type="checkbox" name="display[' . $i . ']" value="yes">' . "\n"; // TODO: add i18n |
| 447 | + $result .= '<input type="checkbox" name="display[' . $i . ']" value="yes">show in results' . "\n"; // TODO: add i18n |
449 | 448 | } |
450 | 449 | $result .= '[<a href="javascript:removePOInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n"; |
451 | 450 | $result .= "</div> \n"; |
— | — | @@ -457,7 +456,7 @@ |
458 | 457 | $result .= ' <option value="NONE"> No Sorting </option>' . "\n"; // TODO add i18n |
459 | 458 | $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
460 | 459 | $result .= ' <option value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option>\n</select>\n"; |
461 | | - $result .= 'show in results: <input type="checkbox" checked name="display_num" value="yes">' . "\n"; // TODO: add i18n |
| 460 | + $result .= '<input type="checkbox" checked name="display_num" value="yes">show in results' . "\n"; // TODO: add i18n |
462 | 461 | $result .= "</div>\n"; |
463 | 462 | $result .= '<div id="sorting_main"></div>' . "\n"; |
464 | 463 | $result .= '<a href="javascript:addPOInstance(\'sorting_starter\', \'sorting_main\')">' . '[Add additional properties]' . '</a>' . "\n"; |
— | — | @@ -537,14 +536,14 @@ |
538 | 537 | |
539 | 538 | /** |
540 | 539 | * Decodes printouts and sorting - related form options generated by its |
541 | | - * complement, getSortedPOFormBox(). UIs may overload both to change form |
| 540 | + * complement, getPoSortFormBox(). UIs may overload both to change form |
542 | 541 | * parameters. |
543 | 542 | * |
544 | 543 | * @global boolean $smwgQSortingSupport |
545 | 544 | * @param WebRequest $wgRequest |
546 | 545 | * @return string |
547 | 546 | */ |
548 | | - protected function processSortedPOFormBox( WebRequest $wgRequest ) { |
| 547 | + protected function processPoSortFormBox( WebRequest $wgRequest ) { |
549 | 548 | global $smwgQSortingSupport; |
550 | 549 | if ( !$smwgQSortingSupport ) return array(); |
551 | 550 | |
— | — | @@ -568,7 +567,7 @@ |
569 | 568 | $display_values = $wgRequest->getArray( 'display' ); |
570 | 569 | if ( is_array( $display_values ) ) { |
571 | 570 | foreach ( $display_values as $key => $value ) { |
572 | | - if ( $value == 'yes' and array_key_exists($key, $property_values )) { |
| 571 | + if ( $value == 'yes' and array_key_exists( $key, $property_values ) ) { |
573 | 572 | $po[] = '?' . trim( $property_values[$key] ); |
574 | 573 | } |
575 | 574 | |
— | — | @@ -726,11 +725,10 @@ |
727 | 726 | * form elements. UIs may overload both to change the form parameter or the |
728 | 727 | * html elements. |
729 | 728 | * |
730 | | - * @param string $content The content expected to appear in the box |
731 | 729 | * @param boolean $enableAutocomplete If set to true, adds the relevant JS and CSS to the page |
732 | 730 | * @return string The HTML code |
733 | 731 | */ |
734 | | - protected function getPOFormBox( $content, $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
| 732 | + protected function getPOFormBox( $enableAutocomplete = SMWQueryUI::ENABLE_AUTO_SUGGEST ) { |
735 | 733 | global $wgOut; |
736 | 734 | |
737 | 735 | if ( $enableAutocomplete ) { |
— | — | @@ -774,7 +772,7 @@ |
775 | 773 | |
776 | 774 | } |
777 | 775 | |
778 | | - return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $content ); |
| 776 | + return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $this->getPOStrings() ); |
779 | 777 | } |
780 | 778 | |
781 | 779 | /** |
— | — | @@ -861,7 +859,7 @@ |
862 | 860 | |
863 | 861 | foreach ( $params as $param ) { |
864 | 862 | // Ignore the format parameter, as we got a special control in the GUI for it already. |
865 | | - if ( $param->getName() == 'format' ) { |
| 863 | + if ( $param->getName() == 'format' or $param->getName() == 'limit' or $param->getName() == 'offset' ) { |
866 | 864 | continue; |
867 | 865 | } |
868 | 866 | $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false; |