Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -258,16 +258,14 @@ |
259 | 259 | */ |
260 | 260 | public function getNavigationBar( $limit, $offset, $hasFurtherResults ) { |
261 | 261 | global $smwgQMaxInlineLimit, $wgLang; |
262 | | - $urlTail = $this->getUrlTail(); |
263 | 262 | // Prepare navigation bar. |
264 | 263 | if ( $offset > 0 ) { |
| 264 | + $this->setUrlArgs( array( 'offset' => max( 0, $offset - $limit ), |
| 265 | + 'limit' => $limit ) ); |
265 | 266 | $navigation = Html::element( |
266 | 267 | 'a', |
267 | 268 | array( |
268 | | - 'href' => $this->getTitle()->getLocalURL( |
269 | | - 'offset=' . max( 0, $offset - $limit ) . |
270 | | - '&limit=' . $limit . $urlTail |
271 | | - ), |
| 269 | + 'href' => $this->getTitle()->getLocalURL( wfArrayToCGI( $this->getUrlArgs() ) ), |
272 | 270 | 'rel' => 'nofollow' |
273 | 271 | ), |
274 | 272 | wfMsg( 'smw_result_prev' ) |
— | — | @@ -285,13 +283,12 @@ |
286 | 284 | '</b>    '; |
287 | 285 | |
288 | 286 | if ( $hasFurtherResults ) { |
| 287 | + $this->setUrlArgs( array( 'offset' => max( 0, $offset + $limit ), |
| 288 | + 'limit' => $limit ) ); |
289 | 289 | $navigation .= Html::element( |
290 | 290 | 'a', |
291 | 291 | array( |
292 | | - 'href' => $this->getTitle()->getLocalURL( |
293 | | - 'offset=' . ( $offset + $limit ) . |
294 | | - '&limit=' . $limit . $urlTail |
295 | | - ), |
| 292 | + 'href' => $this->getTitle()->getLocalURL( wfArrayToCGI( $this->getUrlArgs() ) ), |
296 | 293 | 'rel' => 'nofollow' |
297 | 294 | ), |
298 | 295 | wfMsg( 'smw_result_next' ) |
— | — | @@ -313,13 +310,11 @@ |
314 | 311 | } |
315 | 312 | |
316 | 313 | if ( $limit != $l ) { |
| 314 | + $this->setUrlArgs( array( 'offset' => $offset, 'limit' => $l ) ); |
317 | 315 | $navigation .= Html::element( |
318 | 316 | 'a', |
319 | 317 | array( |
320 | | - 'href' => $this->getTitle()->getLocalURL( |
321 | | - 'offset=' . $offset . |
322 | | - '&limit=' . $l . $urlTail |
323 | | - ), |
| 318 | + 'href' => $this->getTitle()->getLocalURL( wfArrayToCGI( $this->getUrlArgs() ) ), |
324 | 319 | 'rel' => 'nofollow' |
325 | 320 | ), |
326 | 321 | $wgLang->formatNum( $l, false ) |
— | — | @@ -345,6 +340,7 @@ |
346 | 341 | */ |
347 | 342 | protected function getQueryFormBox() { |
348 | 343 | global $wgOut, $smwgScriptPath; |
| 344 | + $this->setUrlArgs( array( 'q' => $this->uiCore->getQueryString() ) ); |
349 | 345 | $result = '<div>'; |
350 | 346 | $result .= Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox' ), |
351 | 347 | $this->uiCore->getQueryString() ); |
— | — | @@ -554,53 +550,32 @@ |
555 | 551 | '<input size="25" value="' . $mainLabelText . '" id="mainlabelvis" />' . |
556 | 552 | '<input type="hidden" name="pmainlabel" value="' . $mainLabel . '" id="mainlabelhid" />' . |
557 | 553 | '</div>'; |
| 554 | + $urlArgs = array(); |
| 555 | + $urlArgs['pmainlabel'] = $mainLabel; |
558 | 556 | |
559 | 557 | // START: create form elements already submitted earlier via form |
560 | 558 | // attempting to load parameters from $wgRequest |
561 | | - $propertyValues = $wgRequest->getArray( 'property' ); |
562 | | - $propertyLabelValues = $wgRequest->getArray( 'prop_label' ); |
563 | | - $propertyFormatValues = $wgRequest->getArray( 'prop_format' ); |
564 | | - $propertyLimitValues = $wgRequest->getArray( 'prop_limit' ); |
565 | | - $orderValues = $wgRequest->getArray( 'order' ); |
566 | | - $displayValues = $wgRequest->getArray( 'display' ); |
567 | | - $categoryValues = $wgRequest->getArray( 'category' ); |
568 | | - $categoryLabelValues = $wgRequest->getArray( 'cat_label' ); |
569 | | - $categoryYesValues = $wgRequest->getArray( 'cat_yes' ); |
570 | | - $categoryNoValues = $wgRequest->getArray( 'cat_no' ); |
571 | | - $mainColumnLabels = $wgRequest->getArray( 'maincol_label' ); |
| 559 | + $propertyValues = $wgRequest->getArray( 'property', array() ); |
| 560 | + $propertyLabelValues = $wgRequest->getArray( 'prop_label', array() ); |
| 561 | + $propertyFormatValues = $wgRequest->getArray( 'prop_format', array() ); |
| 562 | + $propertyLimitValues = $wgRequest->getArray( 'prop_limit', array() ); |
| 563 | + $orderValues = $wgRequest->getArray( 'order', array() ); |
| 564 | + $displayValues = $wgRequest->getArray( 'display', array() ); |
| 565 | + $categoryValues = $wgRequest->getArray( 'category', array() ); |
| 566 | + $categoryLabelValues = $wgRequest->getArray( 'cat_label', array() ); |
| 567 | + $categoryYesValues = $wgRequest->getArray( 'cat_yes', array() ); |
| 568 | + $categoryNoValues = $wgRequest->getArray( 'cat_no', array() ); |
| 569 | + $mainColumnLabels = $wgRequest->getArray( 'maincol_label', array() ); |
572 | 570 | |
573 | | - if ( is_array( $propertyValues ) || is_array( $categoryValues ) || is_array( $mainColumnLabels ) ) { |
| 571 | + $mainLabelCheck = $wgRequest->getCheck( 'pmainlabel' ); |
| 572 | + |
| 573 | + if ( !$mainLabelCheck ) { |
574 | 574 | /* |
575 | | - * Printouts were set via this Ui |
576 | | - */ |
577 | | - if ( is_array( $propertyValues ) ) { |
578 | | - // remove empty property values |
579 | | - foreach ( $propertyValues as $key => $propertyValue ) { |
580 | | - $propertyValues[$key] = trim( $propertyValue ); |
581 | | - if ( $propertyValue == '' ) { |
582 | | - unset( $propertyValues[$key] ); |
583 | | - } |
584 | | - } |
585 | | - } |
586 | | - } else { |
587 | | - /* |
588 | | - * Printouts and sorting were set via another widget/form/source, so |
| 575 | + * Printouts and sorting might be set via another widget/form/source, so |
589 | 576 | * create elements by fetching data from $uiCore. The exact ordering |
590 | | - * of Ui elements might not be preserved, if the above block were to |
| 577 | + * of Ui elements might not be preserved, if the above check were to |
591 | 578 | * be removed. |
592 | 579 | */ |
593 | | - $propertyValues = array(); |
594 | | - $propertyLabelValues = array(); |
595 | | - $propertyFormatValues = array(); |
596 | | - $propertyLimitValues = array(); |
597 | | - $orderValues = array(); |
598 | | - $displayValues = array(); |
599 | | - $categoryValues = array(); |
600 | | - $categoryLabelValues = array(); |
601 | | - $categoryYesValues = array(); |
602 | | - $categoryNoValues = array(); |
603 | | - $mainColumnLabels = array(); |
604 | | - |
605 | 580 | if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) { |
606 | 581 | $sortVal = explode( ',', trim( strtolower( $params['sort'] ) ) ); |
607 | 582 | $orderVal = explode( ',', $params['order'] ); |
— | — | @@ -619,7 +594,7 @@ |
620 | 595 | $counter = 0; |
621 | 596 | foreach ( $printOuts as $poKey => $poValue ) { |
622 | 597 | if ( $poValue->getMode() == SMWPrintRequest::PRINT_CATS ) { |
623 | | - $categoryValues[$counter] = ''; |
| 598 | + $categoryValues[$counter] = ' '; |
624 | 599 | $categoryLabelValues[$counter] = $poValue->getLabel(); |
625 | 600 | $categoryYesValues[$counter] = ''; |
626 | 601 | $categoryNoValues[$counter] = ''; |
— | — | @@ -679,29 +654,36 @@ |
680 | 655 | $counter++; |
681 | 656 | } |
682 | 657 | } |
| 658 | + // remove empty property values |
| 659 | + foreach ( $propertyValues as $key => $propertyValue ) { |
| 660 | + $propertyValues[$key] = trim( $propertyValue ); |
| 661 | + if ( $propertyValue == '' ) { |
| 662 | + unset( $propertyValues[$key] ); |
| 663 | + } |
| 664 | + } |
| 665 | + |
683 | 666 | $i = 0; |
684 | 667 | $additionalPOs = array(); |
685 | | - if ( is_array( $propertyValues ) ) { |
686 | | - $keys = array_keys( $propertyValues ); |
687 | | - foreach ( $keys as $value ) { |
688 | | - $additionalPOs[$value] = $propertyValues[$value]; // array_merge won't work because numeric keys need to be preserved |
689 | | - } |
| 668 | + |
| 669 | + $keys = array_keys( $propertyValues ); |
| 670 | + foreach ( $keys as $value ) { |
| 671 | + $additionalPOs[$value] = $propertyValues[$value]; // array_merge won't work because numeric keys need to be preserved |
690 | 672 | } |
691 | | - if ( is_array( $categoryValues ) ) {// same as testing $categoryLabelValues |
692 | | - $keys = array_keys( $categoryValues ); |
693 | | - foreach ( $keys as $value ) { |
694 | | - $additionalPOs[$value] = $categoryValues[$value]; // array_merge won't work because numeric keys need to be preserved |
695 | | - } |
| 673 | + |
| 674 | + |
| 675 | + $keys = array_keys( $categoryValues ); |
| 676 | + foreach ( $keys as $value ) { |
| 677 | + $additionalPOs[$value] = $categoryValues[$value]; // array_merge won't work because numeric keys need to be preserved |
696 | 678 | } |
697 | | - if ( is_array( $mainColumnLabels ) ) { |
698 | | - $keys = array_keys( $mainColumnLabels ); |
699 | | - foreach ( $keys as $value ) { |
700 | | - $additionalPOs[$value] = $mainColumnLabels[$value]; // array_merge won't work because numeric keys need to be preserved |
701 | | - } |
| 679 | + |
| 680 | + $keys = array_keys( $mainColumnLabels ); |
| 681 | + foreach ( $keys as $value ) { |
| 682 | + $additionalPOs[$value] = $mainColumnLabels[$value]; // array_merge won't work because numeric keys need to be preserved |
702 | 683 | } |
| 684 | + |
703 | 685 | ksort( $additionalPOs ); |
704 | 686 | foreach ( $additionalPOs as $key => $value ) { |
705 | | - if ( is_array( $propertyValues ) && array_key_exists( $key, $propertyValues ) ) { |
| 687 | + if ( array_key_exists( $key, $propertyValues ) ) { |
706 | 688 | /* |
707 | 689 | * Make an element for additional properties |
708 | 690 | */ |
— | — | @@ -709,46 +691,53 @@ |
710 | 692 | $result .= '<span class="smwquisortlabel"><span class="smw-remove"><a href="javascript:removePOInstance(\'sort_div_' . $i . '\')"><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>'; |
711 | 693 | $result .= wfMsg( 'smw_qui_property' ) . '</span>'; |
712 | 694 | $result .= Html::input( 'property[' . $i . ']', $propertyValues[$key], 'text', array( 'size' => '25', 'id' => "property$i" ) ) . "\n"; |
| 695 | + $urlArgs["property[$i]"] = $propertyValues[$key]; |
713 | 696 | $result .= Html::openElement( 'select', array( 'name' => "order[$i]" ) ); |
714 | | - |
715 | | - $if1 = ( !is_array( $orderValues ) || !array_key_exists( $key, $orderValues ) || $orderValues[$key] == 'NONE' ); |
| 697 | + if ( array_key_exists( $key, $orderValues ) ) { |
| 698 | + $urlArgs["order[$i]"] = $orderValues[$key]; |
| 699 | + } |
| 700 | + $if1 = ( !array_key_exists( $key, $orderValues ) || $orderValues[$key] == 'NONE' ); |
716 | 701 | $result .= Xml::option( wfMsg( 'smw_qui_nosort' ), "NONE", $if1 ); |
717 | 702 | |
718 | | - $if2 = ( is_array( $orderValues ) && array_key_exists( $key, $orderValues ) && $orderValues[$key] == 'ASC' ); |
| 703 | + $if2 = ( array_key_exists( $key, $orderValues ) && $orderValues[$key] == 'ASC' ); |
719 | 704 | $result .= Xml::option( wfMsg( 'smw_qui_ascorder' ), "ASC", $if2 ); |
720 | 705 | |
721 | | - $if3 = ( is_array( $orderValues ) && array_key_exists( $key, $orderValues ) && $orderValues[$key] == 'DESC' ); |
| 706 | + $if3 = ( array_key_exists( $key, $orderValues ) && $orderValues[$key] == 'DESC' ); |
722 | 707 | $result .= Xml::option( wfMsg( 'smw_qui_descorder' ), "DESC", $if3 ); |
723 | 708 | |
724 | 709 | $result .= Xml::closeElement( 'select' ); |
725 | 710 | |
726 | | - $if4 = ( is_array( $displayValues ) && array_key_exists( $key, $displayValues ) ); |
| 711 | + $if4 = ( array_key_exists( $key, $displayValues ) ); |
727 | 712 | $result .= Xml::checkLabel( wfMsg( 'smw_qui_shownresults' ), "display[$i]", "display$i", $if4 ); |
| 713 | + if ( $if4 ) $urlArgs["display[$i]"] = '1'; |
728 | 714 | |
729 | | - if ( is_array( $propertyLabelValues ) && array_key_exists( $key, $propertyLabelValues ) ) { |
| 715 | + if ( array_key_exists( $key, $propertyLabelValues ) ) { |
730 | 716 | $result .= Html::hidden( "prop_label[$i]", $propertyLabelValues[$key], array( 'id' => "prop_label$i" ) ); |
| 717 | + $urlArgs["prop_label[$i]"] = $propertyLabelValues[$key]; |
731 | 718 | } else { |
732 | 719 | $result .= Html::hidden( "prop_label[$i]", '', array( 'id' => "prop_label$i" ) ); |
733 | 720 | } |
734 | | - if ( is_array( $propertyFormatValues ) && array_key_exists( $key, $propertyFormatValues ) ) { |
| 721 | + if ( array_key_exists( $key, $propertyFormatValues ) ) { |
735 | 722 | $result .= Html::hidden( "prop_format[$i]", $propertyFormatValues[$key], array( 'id' => "prop_format$i" ) ); |
| 723 | + $urlArgs["prop_format[$i]"] = $propertyFormatValues[$key]; |
736 | 724 | } else { |
737 | 725 | $result .= Html::hidden( "prop_format[$i]", '', array( 'id' => "prop_format$i" ) ); |
738 | 726 | } |
739 | | - if ( is_array( $propertyLimitValues ) && array_key_exists( $key, $propertyLimitValues ) ) { |
| 727 | + if ( array_key_exists( $key, $propertyLimitValues ) ) { |
740 | 728 | $result .= Html::hidden( "prop_limit[$i]", $propertyLimitValues[$key], array( 'id' => "prop_limit$i" ) ); |
| 729 | + $urlArgs["prop_limit[$i]"] = $propertyLimitValues[$key]; |
741 | 730 | } else { |
742 | 731 | $result .= Html::hidden( "prop_limit[$i]", '', array( 'id' => "prop_limit$i" ) ); |
743 | 732 | } |
744 | | - $result .= ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makePropDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> '; |
| 733 | + $result .= ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makePropDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> '; |
745 | 734 | |
746 | 735 | $result .= Xml::closeElement( 'div' ); |
747 | 736 | $i++; |
748 | 737 | } |
749 | | - if ( is_array( $categoryValues ) && array_key_exists( $key, $categoryValues ) && |
750 | | - is_array( $categoryLabelValues ) && array_key_exists( $key, $categoryLabelValues ) && |
751 | | - is_array( $categoryYesValues ) && array_key_exists( $key, $categoryYesValues ) && |
752 | | - is_array( $categoryNoValues ) && array_key_exists( $key, $categoryNoValues ) ) { |
| 738 | + if ( array_key_exists( $key, $categoryValues ) ) { |
| 739 | + if ( !array_key_exists( $key, $categoryLabelValues ) ) $categoryLabelValues[$key] = ''; |
| 740 | + if ( !array_key_exists( $key, $categoryYesValues ) ) $categoryYesValues[$key] = ''; |
| 741 | + if ( !array_key_exists( $key, $categoryNoValues ) ) $categoryNoValues[$key] = ''; |
753 | 742 | /* |
754 | 743 | * Make an element for additional categories |
755 | 744 | */ |
— | — | @@ -759,11 +748,15 @@ |
760 | 749 | Html::hidden( "cat_label[$i]", $categoryLabelValues[$key], array( 'id' => "cat_label$i" ) ) . |
761 | 750 | Html::hidden( "cat_yes[$i]", $categoryYesValues[$key], array( 'id' => "cat_yes$i" ) ) . |
762 | 751 | Html::hidden( "cat_no[$i]", $categoryNoValues[$key], array( 'id' => "cat_no$i" ) ) . |
763 | | - ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ' . |
| 752 | + ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ' . |
764 | 753 | Xml::closeElement( 'div' ); |
| 754 | + $urlArgs["category[$i]"] = ( $categoryValues[$key] == '' ) ? ' ':$categoryValues[$key]; |
| 755 | + $urlArgs["cat_label[$i]"] = $categoryLabelValues[$key]; |
| 756 | + $urlArgs["cat_yes[$i]"] = $categoryYesValues[$key]; |
| 757 | + $urlArgs["cat_no[$i]"] = $categoryNoValues[$key]; |
765 | 758 | $i++; |
766 | 759 | } |
767 | | - if ( is_array( $mainColumnLabels ) && array_key_exists( $key, $mainColumnLabels ) ) { |
| 760 | + if ( array_key_exists( $key, $mainColumnLabels ) ) { |
768 | 761 | /* |
769 | 762 | * Make an element for main column |
770 | 763 | */ |
— | — | @@ -772,10 +765,12 @@ |
773 | 766 | wfMsg( 'smw_qui_rescol' ) . '</span>' . |
774 | 767 | Xml::input( "maincol_label[$i]", '25', $mainColumnLabels[$key], array ( 'id' => "maincol_label$i" ) ) . " " . |
775 | 768 | Xml::closeElement( 'div' ); |
| 769 | + $urlArgs["maincol_label[$i]"] = ( $mainColumnLabels[$key] == '' ) ? ' ':$mainColumnLabels[$key]; |
776 | 770 | $i++; |
777 | 771 | } |
778 | 772 | } |
779 | 773 | $numSortValues = $i; |
| 774 | + $this->setUrlArgs( $urlArgs ); |
780 | 775 | // END: create form elements already submitted earlier via form |
781 | 776 | |
782 | 777 | // create hidden form elements to be cloned later |
— | — | @@ -1174,8 +1169,11 @@ |
1175 | 1170 | } |
1176 | 1171 | |
1177 | 1172 | foreach ( $orders as $i => $order ) { |
| 1173 | + $urlArgs = array(); |
1178 | 1174 | $result .= "<div id=\"sort_div_$i\">" . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort[' . $i . ']" value="' . |
1179 | 1175 | htmlspecialchars( $sorts[$i] ) . "\" size=\"25\"/>\n" . '<select name="order[' . $i . ']"><option '; |
| 1176 | + $urlArgs["sort[$i]"] = htmlspecialchars( $sorts[$i] ); |
| 1177 | + $urlArgs["order[$i]"] = $order; |
1180 | 1178 | if ( $order == 'ASC' ) $result .= 'selected="selected" '; |
1181 | 1179 | $result .= 'value="ASC">' . wfMsg( 'smw_qui_ascorder' ) . '</option><option '; |
1182 | 1180 | if ( $order == 'DESC' ) $result .= 'selected="selected" '; |
— | — | @@ -1183,6 +1181,7 @@ |
1184 | 1182 | $result .= 'value="DESC">' . wfMsg( 'smw_qui_descorder' ) . "</option></select>\n"; |
1185 | 1183 | $result .= '[<a class="smwq-remove" href="javascript:removeInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'smw_qui_delete' ) . '</a>]' . "\n"; |
1186 | 1184 | $result .= "</div>\n"; |
| 1185 | + $this->setUrlArgs( $urlArgs ); |
1187 | 1186 | } |
1188 | 1187 | |
1189 | 1188 | $hidden .= '<div id="sorting_starter" style="display: none">' . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" size="25" />' . "\n"; |
— | — | @@ -1346,7 +1345,7 @@ |
1347 | 1346 | $wgOut->addScript( $javascriptAutocompleteText ); |
1348 | 1347 | |
1349 | 1348 | } |
1350 | | - |
| 1349 | + $this->setUrlArgs( array( 'po' => $this->getPOStrings() ) ); |
1351 | 1350 | return Html::element( 'textarea', array( 'id' => 'add_property', 'name' => 'po', 'cols' => '20', 'rows' => '6' ), $this->getPOStrings() ); |
1352 | 1351 | } |
1353 | 1352 | |
— | — | @@ -1380,42 +1379,35 @@ |
1381 | 1380 | } |
1382 | 1381 | |
1383 | 1382 | /** |
1384 | | - * Generates the url parameters based on passed parameters. |
1385 | | - * UI implementations need to overload this if they use different form |
1386 | | - * parameters. |
| 1383 | + * Keeps track of the various Url Arguments used |
1387 | 1384 | * |
1388 | | - * @return string An url-encoded string. |
| 1385 | + * @var array of strings in the urlparamater=>value format |
1389 | 1386 | */ |
1390 | | - protected function getUrlTail() { |
1391 | | - $urlTail = '&q=' . urlencode( $this->uiCore->getQuerystring() ); |
| 1387 | + protected $urlArgs = array(); |
1392 | 1388 | |
1393 | | - $tmpArray = array(); |
1394 | | - $params = $this->uiCore->getParameters(); |
1395 | | - foreach ( $params as $key => $value ) { |
1396 | | - if ( !in_array( $key, array( 'sort', 'order', 'limit', 'offset', 'title' ) ) ) { |
1397 | | - $tmpArray[$key] = $value; |
1398 | | - } |
1399 | | - } |
1400 | | - $urlTail .= '&p=' . urlencode( SMWInfolink::encodeParameters( $tmpArray ) ); |
| 1389 | + /** |
| 1390 | + * Given an array of urlparameter=>value pairs, this method adds them to its |
| 1391 | + * set of Url-arguments. If the urlparameter already exists, it is replaced by the supplied value |
| 1392 | + * |
| 1393 | + * @param array $args |
| 1394 | + */ |
| 1395 | + protected function setUrlArgs( array $args ) { |
| 1396 | + $this->urlArgs = array_merge( $this->urlArgs, $args ); |
| 1397 | + } |
1401 | 1398 | |
1402 | | - $printOutString = ''; |
1403 | | - foreach ( $this->uiCore->getPrintOuts() as $printout ) { |
1404 | | - $printOutString .= $printout->getSerialisation() . "\n"; |
1405 | | - } |
| 1399 | + /** |
| 1400 | + * |
| 1401 | + * @return array of strings in the urlparamater=>value format |
| 1402 | + */ |
| 1403 | + protected function getUrlArgs() { |
| 1404 | + return $this->urlArgs; |
| 1405 | + } |
1406 | 1406 | |
1407 | | - if ( $printOutString != '' ) { |
1408 | | - $urlTail .= '&po=' . urlencode( $printOutString ); |
1409 | | - } |
1410 | | - if ( array_key_exists( 'sort', $params ) ) { |
1411 | | - $urlTail .= '&sort=' . $params['sort']; |
1412 | | - } |
1413 | | - if ( array_key_exists( 'order', $params ) ) { |
1414 | | - $urlTail .= '&order=' . $params['order']; |
1415 | | - } |
1416 | | - |
1417 | | - return $urlTail; |
| 1407 | + protected function resetUrlArgs() { |
| 1408 | + $this->urlArgs = array(); |
1418 | 1409 | } |
1419 | 1410 | |
| 1411 | + |
1420 | 1412 | /** |
1421 | 1413 | * Displays a form section showing the options for a given format, |
1422 | 1414 | * based on the getParameters() value for that format's query printer. |
— | — | @@ -1432,6 +1424,7 @@ |
1433 | 1425 | $params = method_exists( $printer, 'getValidatorParameters' ) ? $printer->getValidatorParameters() : array(); |
1434 | 1426 | |
1435 | 1427 | $optionsHtml = array(); |
| 1428 | + $urlArgs = array(); |
1436 | 1429 | |
1437 | 1430 | foreach ( $params as $param ) { |
1438 | 1431 | // Ignore the parameters for which we have a special control in the GUI already. |
— | — | @@ -1452,7 +1445,9 @@ |
1453 | 1446 | '<br />' . |
1454 | 1447 | Html::element( 'em', array(), $param->getDescription() ) |
1455 | 1448 | ); |
| 1449 | + $urlArgs['p[' . htmlspecialchars( $param->getName() ) . ']'] = $currentValue; |
1456 | 1450 | } |
| 1451 | + $this->setUrlArgs( $urlArgs ); |
1457 | 1452 | |
1458 | 1453 | for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) { |
1459 | 1454 | if ( $i % 3 == 2 || $i == $n - 1 ) { |
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -83,13 +83,14 @@ |
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | * |
87 | | - * Overridden from parent to ignore GUI parameters 'format' 'limit' and 'offset' |
| 87 | + * Overridden from parent to ignore some parameters. |
88 | 88 | */ |
89 | 89 | protected function showFormatOptions( $format, array $paramValues, array $ignoredAttribs = array() ) { |
90 | 90 | return parent::showFormatOptions( $format, $paramValues, array( |
91 | 91 | 'format', 'limit', 'offset', 'mainlabel', 'intro', 'outro', 'default' |
92 | 92 | ) ); |
93 | 93 | } |
| 94 | + |
94 | 95 | /** |
95 | 96 | * Creates the input form |
96 | 97 | * |
— | — | @@ -127,7 +128,17 @@ |
128 | 129 | $result .= '</div>'; |
129 | 130 | // END: show|hide additional options |
130 | 131 | $result .= '<div id="additional_options" style="display:none">'; |
131 | | - |
| 132 | + $params = $this->uiCore->getParameters(); |
| 133 | + if ( array_key_exists( 'limit', $params ) ) { |
| 134 | + $limit = $params['limit']; |
| 135 | + } else { |
| 136 | + $limit = ''; |
| 137 | + } |
| 138 | + if ( array_key_exists( 'offset', $params ) ) { |
| 139 | + $offset = $params['offset']; |
| 140 | + } else { |
| 141 | + $offset = ''; |
| 142 | + } |
132 | 143 | $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n" . |
133 | 144 | Html::rawElement( 'div', array( 'style' => 'width: 30%; padding: 5px; float: left;' ), |
134 | 145 | 'Intro: <input name="p[intro]" size="32"/> <br/>' . wfMsg( 'smw_paramdesc_intro' ) |
— | — | @@ -138,6 +149,8 @@ |
139 | 150 | Html::rawElement( 'div', array( 'style' => 'width: 30%; padding: 5px; float: left;' ), |
140 | 151 | 'Default: <input name="p[default]" size="32"/> <br/>' . wfMsg( 'smw_paramdesc_default' ) |
141 | 152 | ) . |
| 153 | + Html::hidden( 'p[limit]', $limit ) . |
| 154 | + Html::hidden( 'p[offset]', $offset ) . |
142 | 155 | '</fieldset>'; |
143 | 156 | $result .= '<fieldset><legend>' . wfMsg( 'smw_qc_formatopt' ) . "</legend>\n" . |
144 | 157 | $formatBox[1] . // display the format options |
— | — | @@ -176,9 +189,25 @@ |
177 | 190 | } |
178 | 191 | $result .= '<input type="hidden" name="eq" value="no"/>' . |
179 | 192 | "\n</form><br/>"; |
180 | | - |
181 | 193 | return $result; |
182 | 194 | |
183 | 195 | } |
| 196 | + |
| 197 | + /** |
| 198 | + * Overridden to include form parameters. |
| 199 | + * |
| 200 | + * @return array of strings in the urlparamater=>value format |
| 201 | + */ |
| 202 | + protected function getUrlArgs() { |
| 203 | + $tmpArray = array(); |
| 204 | + $params = $this->uiCore->getParameters(); |
| 205 | + foreach ( $params as $key => $value ) { |
| 206 | + if ( !in_array( $key, array( 'sort', 'order', 'limit', 'offset', 'title' ) ) ) { |
| 207 | + $tmpArray[$key] = $value; |
| 208 | + } |
| 209 | + } |
| 210 | + $this->setUrlArgs( $tmpArray ); |
| 211 | + return $this->urlArgs; |
| 212 | + } |
184 | 213 | } |
185 | 214 | |