Index: trunk/extensions/SemanticForms/SemanticForms.php |
— | — | @@ -324,6 +324,8 @@ |
325 | 325 | # ## |
326 | 326 | $sfgRedLinksCheckOnlyLocalProps = false; |
327 | 327 | |
| 328 | +$sfgRunQueryFormAtTop = false; |
| 329 | + |
328 | 330 | # ## |
329 | 331 | # Page properties, used for the API |
330 | 332 | # ## |
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | } |
34 | 34 | |
35 | 35 | function printPage( $form_name, $embedded = false ) { |
36 | | - global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser; |
| 36 | + global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop; |
37 | 37 | |
38 | 38 | // Get contents of form-definition page. |
39 | 39 | $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name ); |
— | — | @@ -100,27 +100,43 @@ |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | | - // Display the text of the results. |
| 104 | + // Get the text of the results. |
| 105 | + $resultsText = ''; |
105 | 106 | if ( $form_submitted ) { |
106 | | - $text = $wgParser->parse( $data_text, $wgTitle, $wgParser->mOptions )->getText(); |
| 107 | + $resultsText = $wgParser->parse( $data_text, $wgTitle, $wgParser->mOptions )->getText(); |
107 | 108 | } |
108 | 109 | |
109 | | - // Display the "additional query" header, if the form has |
110 | | - // already been submitted. |
111 | | - if ( $form_submitted ) { |
112 | | - $additional_query = wfMsg( 'sf_runquery_additionalquery' ); |
113 | | - if ( !$raw ) |
114 | | - $text .= "\n<h2>$additional_query</h2>\n"; |
115 | | - } |
| 110 | + // Get the full text of the form. |
| 111 | + $fullFormText = ''; |
| 112 | + $additionalQueryHeader = ''; |
116 | 113 | if ( !$raw ) { |
| 114 | + // The "additional query" header - displayed if the form has |
| 115 | + // already been submitted. |
| 116 | + if ( $form_submitted ) { |
| 117 | + $additionalQueryHeader = "\n" . Xml::element( 'h2', null, wfMsg( 'sf_runquery_additionalquery' ) ) . "\n"; |
| 118 | + } |
117 | 119 | $action = htmlspecialchars( $this->getTitle( $form_name )->getLocalURL() ); |
118 | | - $text .= <<<END |
| 120 | + $fullFormText .= <<<END |
119 | 121 | <form id="sfForm" name="createbox" action="$action" method="post" class="createbox"> |
120 | 122 | |
121 | 123 | END; |
122 | | - $text .= SFFormUtils::hiddenFieldHTML( 'query', 'true' ); |
123 | | - $text .= $form_text; |
| 124 | + $fullFormText .= SFFormUtils::hiddenFieldHTML( 'query', 'true' ); |
| 125 | + $fullFormText .= $form_text; |
124 | 126 | } |
| 127 | + |
| 128 | + // Either display the query form at the top, and the results at |
| 129 | + // the bottom, or the other way around, depending on the |
| 130 | + // settings - the display is slightly different in each case. |
| 131 | + if ( $sfgRunQueryFormAtTop ) { |
| 132 | + $text .= $fullFormText; |
| 133 | + $text .= "\n<hr style=\"margin: 15px 0;\" />\n"; |
| 134 | + $text .= $resultsText; |
| 135 | + } else { |
| 136 | + $text .= $resultsText; |
| 137 | + $text .= $additionalQueryHeader; |
| 138 | + $text .= $fullFormText; |
| 139 | + } |
| 140 | + |
125 | 141 | if ( $embedded ) { |
126 | 142 | $text = "<div class='runQueryEmbedded'>$text</div>"; |
127 | 143 | } |