Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | |
98 | 98 | $result .= "<br /><br />\n<p>" . wfMsg( 'smw_ask_format_as' ) . ' <input type="hidden" name="eq" value="yes"/>' . "\n" . |
99 | 99 | '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . |
100 | | - ' <option value="broadtable"' . ( $this->m_params['format'] == 'broadtable' ? ' selected' : '' ) . '>' . |
| 100 | + ' <option value="broadtable">' . |
101 | 101 | $printer->getName() . ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n"; |
102 | 102 | |
103 | 103 | $formats = array(); |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | natcasesort( $formats ); |
114 | 114 | |
115 | 115 | foreach ( $formats as $format => $name ) { |
116 | | - $result .= ' <option value="' . $format . '"' . ( $this->m_params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
| 116 | + $result .= ' <option value="' . $format . '>' . $name . "</option>\n"; |
117 | 117 | } |
118 | 118 | //add javascript for updating formating options by ajax |
119 | 119 | $default_format_url = SpecialPage::getSafeTitleFor( 'Ask' )->getLocalURL( "showformatoptions=broadtable" ); |
— | — | @@ -134,7 +134,6 @@ |
135 | 135 | $result .= '<fieldset><legend>' . wfMsg( 'smw_ask_otheroptions' ) . "</legend>\n"; |
136 | 136 | $result .= "<div id=\"other_options\"></div>"; |
137 | 137 | $result .= "</fieldset>\n"; |
138 | | - $urltail = str_replace( '&eq=yes', '', $urltail ) . '&eq=no'; |
139 | 138 | $result .= '</div>'; |
140 | 139 | $result .= '<br /><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/>' . |
141 | 140 | '<input type="hidden" name="eq" value="no"/>' . |
Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php |
— | — | @@ -547,7 +547,7 @@ |
548 | 548 | |
549 | 549 | $printer = SMWQueryProcessor::getResultPrinter( 'broadtable', SMWQueryProcessor::SPECIAL_PAGE ); |
550 | 550 | $url = SpecialPage::getSafeTitleFor( 'Ask' )->getLocalURL( "showformatoptions=' + this.value + '" ); |
551 | | - |
| 551 | + |
552 | 552 | foreach ( $this->m_params as $param => $value ) { |
553 | 553 | if ( $param !== 'format' ) { |
554 | 554 | $url .= '¶ms[' . Xml::escapeJsString( $param ) . ']=' . Xml::escapeJsString( $value ); |
— | — | @@ -596,7 +596,7 @@ |
597 | 597 | "\n</form>"; |
598 | 598 | } else { // if $this->m_editquery == false |
599 | 599 | $urltail = str_replace( '&eq=no', '', $urltail ) . '&eq=yes'; |
600 | | - $result .= '<p>' . |
| 600 | + $result .= '<p>' . |
601 | 601 | Html::element( |
602 | 602 | 'a', |
603 | 603 | array( |
— | — | @@ -670,14 +670,14 @@ |
671 | 671 | 'rel' => 'nofollow' |
672 | 672 | ), |
673 | 673 | wfMsg( 'smw_result_prev' ) |
674 | | - ); |
675 | | - |
| 674 | + ); |
| 675 | + |
676 | 676 | } else { |
677 | 677 | $navigation = wfMsg( 'smw_result_prev' ); |
678 | 678 | } |
679 | 679 | |
680 | | - $navigation .= |
681 | | - '     <b>' . |
| 680 | + $navigation .= |
| 681 | + '     <b>' . |
682 | 682 | wfMsg( 'smw_result_results' ) . ' ' . ( $offset + 1 ) . |
683 | 683 | '– ' . |
684 | 684 | ( $offset + $res->getCount() ) . |
— | — | @@ -694,7 +694,7 @@ |
695 | 695 | 'rel' => 'nofollow' |
696 | 696 | ), |
697 | 697 | wfMsg( 'smw_result_next' ) |
698 | | - ); |
| 698 | + ); |
699 | 699 | } else { |
700 | 700 | $navigation .= wfMsg( 'smw_result_next' ); |
701 | 701 | } |
— | — | @@ -722,7 +722,7 @@ |
723 | 723 | 'rel' => 'nofollow' |
724 | 724 | ), |
725 | 725 | $l |
726 | | - ); |
| 726 | + ); |
727 | 727 | } else { |
728 | 728 | $navigation .= '<b>' . $l . '</b>'; |
729 | 729 | } |
— | — | @@ -748,12 +748,12 @@ |
749 | 749 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
750 | 750 | |
751 | 751 | $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array(); |
752 | | - |
| 752 | + |
753 | 753 | // Ignore the format parameter, as we got a special control in the GUI for it already. |
754 | 754 | unset( $params['format'] ); |
755 | | - |
| 755 | + |
756 | 756 | $optionsHtml = array(); |
757 | | - |
| 757 | + |
758 | 758 | foreach ( $params as $param ) { |
759 | 759 | $param = $this->toValidatorParam( $param ); |
760 | 760 | $currentValue = array_key_exists( $param->getName(), $paramValues ) ? $paramValues[$param->getName()] : false; |
— | — | @@ -770,21 +770,21 @@ |
771 | 771 | Html::element( 'em', array(), $param->getDescription() ) |
772 | 772 | ); |
773 | 773 | } |
774 | | - |
| 774 | + |
775 | 775 | for ( $i = 0, $n = count( $optionsHtml ); $i < $n; $i++ ) { |
776 | 776 | if ( $i % 3 == 2 || $i == $n - 1 ) { |
777 | 777 | $optionsHtml[$i] .= "<div style=\"clear: both\";></div>\n"; |
778 | 778 | } |
779 | 779 | } |
780 | | - |
| 780 | + |
781 | 781 | $i = 0; |
782 | 782 | $rowHtml = ''; |
783 | 783 | $resultHtml = ''; |
784 | | - |
| 784 | + |
785 | 785 | while ( $option = array_shift( $optionsHtml ) ) { |
786 | 786 | $rowHtml .= $option; |
787 | 787 | $i++; |
788 | | - |
| 788 | + |
789 | 789 | if ( $i % 3 == 0 ) { |
790 | 790 | $resultHtml .= Html::rawElement( |
791 | 791 | 'div', |
— | — | @@ -799,65 +799,65 @@ |
800 | 800 | |
801 | 801 | return $resultHtml; |
802 | 802 | } |
803 | | - |
| 803 | + |
804 | 804 | /** |
805 | 805 | * Returns a Validator style Parameter definition. |
806 | 806 | * SMW 1.5.x style definitions are converted. |
807 | | - * |
| 807 | + * |
808 | 808 | * @since 1.6 |
809 | | - * |
| 809 | + * |
810 | 810 | * @param mixed $param |
811 | | - * |
| 811 | + * |
812 | 812 | * @return Parameter |
813 | 813 | */ |
814 | 814 | protected function toValidatorParam( $param ) { |
815 | 815 | static $typeMap = array( |
816 | 816 | 'int' => Parameter::TYPE_INTEGER |
817 | 817 | ); |
818 | | - |
| 818 | + |
819 | 819 | if ( !( $param instanceof Parameter ) ) { |
820 | 820 | if ( !array_key_exists( 'type', $param ) ) { |
821 | 821 | $param['type'] = 'string'; |
822 | 822 | } |
823 | | - |
| 823 | + |
824 | 824 | $paramClass = $param['type'] == 'enum-list' ? 'ListParameter' : 'Parameter'; |
825 | 825 | $paramType = array_key_exists( $param['type'], $typeMap ) ? $typeMap[$param['type']] : Parameter::TYPE_STRING; |
826 | | - |
| 826 | + |
827 | 827 | $parameter = new $paramClass( $param['name'], $paramType ); |
828 | | - |
| 828 | + |
829 | 829 | if ( array_key_exists( 'description', $param ) ) { |
830 | 830 | $parameter->setDescription( $param['description'] ); |
831 | 831 | } |
832 | | - |
| 832 | + |
833 | 833 | if ( array_key_exists( 'values', $param ) && is_array( $param['values'] ) ) { |
834 | 834 | $parameter->addCriteria( new CriterionInArray( $param['values'] ) ); |
835 | 835 | } |
836 | | - |
| 836 | + |
837 | 837 | return $parameter; |
838 | 838 | } |
839 | 839 | else { |
840 | 840 | return $param; |
841 | 841 | } |
842 | 842 | } |
843 | | - |
| 843 | + |
844 | 844 | /** |
845 | 845 | * Get the HTML for a single parameter input. |
846 | | - * |
| 846 | + * |
847 | 847 | * @since 1.6 |
848 | | - * |
| 848 | + * |
849 | 849 | * @param Parameter $parameter |
850 | 850 | * @param mixed $currentValue |
851 | | - * |
| 851 | + * |
852 | 852 | * @return string |
853 | 853 | */ |
854 | 854 | protected function showFormatOption( Parameter $parameter, $currentValue ) { |
855 | 855 | $input = new ParameterInput( $parameter ); |
856 | 856 | $input->setInputName( 'p[' . $parameter->getName() . ']' ); |
857 | | - |
| 857 | + |
858 | 858 | if ( $currentValue !== false ) { |
859 | 859 | $input->setCurrentValue( $currentValue ); |
860 | 860 | } |
861 | | - |
| 861 | + |
862 | 862 | return $input->getHtml(); |
863 | 863 | } |
864 | 864 | |