Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -895,9 +895,10 @@ |
896 | 896 | |
897 | 897 | foreach ( $params as $param ) { |
898 | 898 | // Ignore the format parameter, as we got a special control in the GUI for it already. |
899 | | - if ( $param->getName() == 'format' or $param->getName() == 'limit' or $param->getName() == 'offset' ) { |
| 899 | + if ( $param->getName() == 'format' ) { |
900 | 900 | continue; |
901 | 901 | } |
| 902 | + |
902 | 903 | $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false; |
903 | 904 | |
904 | 905 | $optionsHtml[] = |
— | — | @@ -907,15 +908,15 @@ |
908 | 909 | 'style' => 'width: 30%; padding: 5px; float: left;' |
909 | 910 | ), |
910 | 911 | htmlspecialchars( $param->getName() ) . ': ' . |
911 | | - $this->getFormatOption( $param, $currentValue ) . |
| 912 | + $this->showFormatOption( $param, $currentValue ) . |
912 | 913 | '<br />' . |
913 | 914 | Html::element( 'em', array(), $param->getDescription() ) |
914 | 915 | ); |
915 | 916 | } |
916 | 917 | |
917 | | - for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i += 1 ) { |
| 918 | + for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) { |
918 | 919 | if ( $i % 3 == 2 || $i == $n - 1 ) { |
919 | | - $optionsHtml[$i] .= Html::element( 'div', array( 'style' => 'clear: both;' ) ) . "\n"; |
| 920 | + $optionsHtml[$i] .= "<div style=\"clear: both\";></div>\n"; |
920 | 921 | } |
921 | 922 | } |
922 | 923 | |
— | — | @@ -925,7 +926,8 @@ |
926 | 927 | |
927 | 928 | while ( $option = array_shift( $optionsHtml ) ) { |
928 | 929 | $rowHtml .= $option; |
929 | | - $i += 1; |
| 930 | + $i++; |
| 931 | + |
930 | 932 | $resultHtml .= Html::rawElement( |
931 | 933 | 'div', |
932 | 934 | array( |
— | — | @@ -933,22 +935,23 @@ |
934 | 936 | ), |
935 | 937 | $rowHtml |
936 | 938 | ); |
| 939 | + |
937 | 940 | $rowHtml = ''; |
938 | 941 | } |
939 | 942 | |
940 | 943 | return $resultHtml; |
941 | 944 | } |
942 | 945 | |
| 946 | + |
943 | 947 | /** |
944 | 948 | * Get the HTML for a single parameter input. |
945 | | - * A helper method for showFormatOptions() |
946 | 949 | * |
947 | 950 | * @param Parameter $parameter |
948 | | - * @param mixed $currentValue curretly set value of the parameter, or false if unknown. |
| 951 | + * @param mixed $currentValue |
949 | 952 | * |
950 | | - * @return string generated HTML |
| 953 | + * @return string |
951 | 954 | */ |
952 | | - private function getFormatOption( Parameter $parameter, $currentValue ) { |
| 955 | + protected function showFormatOption( Parameter $parameter, $currentValue ) { |
953 | 956 | $input = new ParameterInput( $parameter ); |
954 | 957 | $input->setInputName( 'p[' . $parameter->getName() . ']' ); |
955 | 958 | |
— | — | @@ -961,16 +964,19 @@ |
962 | 965 | |
963 | 966 | /** |
964 | 967 | * Creates form elements for choosing the result-format and their |
965 | | - * associated format. Use in conjunction with processFormatOptions() to |
| 968 | + * associated format. |
| 969 | + * |
| 970 | + * The drop-down list and the format options are returned seperately as |
| 971 | + * elements of an array.Use in conjunction with processFormatOptions() to |
966 | 972 | * supply formats options using ajax. Also, use its complement |
967 | 973 | * processFormatSelectBox() to decode form data sent by these elements. |
968 | 974 | * UI's may overload these methods to change behaviour or form |
969 | 975 | * parameters. |
970 | 976 | * |
971 | 977 | * @param string $defaultformat The default format which remains selected in the form |
972 | | - * @return string |
| 978 | + * @return array The first element contains the format selector, while the second contains the Format options |
973 | 979 | */ |
974 | | - protected function getFormatSelectBox( $defaultformat = 'broadtable' ) { |
| 980 | + protected function getFormatSelectBoxSep( $defaultformat = 'broadtable' ) { |
975 | 981 | global $smwgResultFormats, $wgOut; |
976 | 982 | |
977 | 983 | $this->enableJQuery(); |
— | — | @@ -990,7 +996,7 @@ |
991 | 997 | } |
992 | 998 | } |
993 | 999 | |
994 | | - $result = "\n<p>" . wfMsg( 'smw_ask_format_as' ) . "\n" . |
| 1000 | + $result[0] = "\n<p>" . wfMsg( 'smw_ask_format_as' ) . "\n" . |
995 | 1001 | '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . |
996 | 1002 | '<option value="' . $default_format . '">' . $printer->getName() . |
997 | 1003 | ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n"; |
— | — | @@ -1007,14 +1013,14 @@ |
1008 | 1014 | |
1009 | 1015 | $params = $this->uiCore->getParameters(); |
1010 | 1016 | foreach ( $formats as $format => $name ) { |
1011 | | - $result .= '<option value="' . $format . '"' . ( $params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
| 1017 | + $result[0] .= '<option value="' . $format . '"' . ( $params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
1012 | 1018 | } |
1013 | 1019 | |
1014 | | - $result .= "</select>"; |
1015 | | - $result .= "</p>\n"; |
1016 | | - $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n"; |
1017 | | - $result .= "<div id=\"other_options\">" . $this->showFormatOptions( $params['format'], $params ) . " </div>"; |
1018 | | - $result .= "</fieldset>\n"; |
| 1020 | + $result[0] .= "</select>"; |
| 1021 | + $result[0] .= "</p>\n"; |
| 1022 | + $result[] .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n"; |
| 1023 | + $result[1] .= "<div id=\"other_options\">" . $this->showFormatOptions( $params['format'], $params ) . " </div>"; |
| 1024 | + $result[1] .= "</fieldset>\n"; |
1019 | 1025 | |
1020 | 1026 | // BEGIN: add javascript for updating formating options by ajax |
1021 | 1027 | $javascript = <<<END |