r98743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98742‎ | r98743 | r98744 >
Date:09:38, 3 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for new setting, $sfgRunQueryFormAtTop - also improved code layout of SF_RunQuery.php
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_RunQuery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -324,6 +324,8 @@
325325 # ##
326326 $sfgRedLinksCheckOnlyLocalProps = false;
327327
 328+$sfgRunQueryFormAtTop = false;
 329+
328330 # ##
329331 # Page properties, used for the API
330332 # ##
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php
@@ -32,7 +32,7 @@
3333 }
3434
3535 function printPage( $form_name, $embedded = false ) {
36 - global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser;
 36+ global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop;
3737
3838 // Get contents of form-definition page.
3939 $form_title = Title::makeTitleSafe( SF_NS_FORM, $form_name );
@@ -100,27 +100,43 @@
101101 }
102102 }
103103
104 - // Display the text of the results.
 104+ // Get the text of the results.
 105+ $resultsText = '';
105106 if ( $form_submitted ) {
106 - $text = $wgParser->parse( $data_text, $wgTitle, $wgParser->mOptions )->getText();
 107+ $resultsText = $wgParser->parse( $data_text, $wgTitle, $wgParser->mOptions )->getText();
107108 }
108109
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 = '';
116113 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+ }
117119 $action = htmlspecialchars( $this->getTitle( $form_name )->getLocalURL() );
118 - $text .= <<<END
 120+ $fullFormText .= <<<END
119121 <form id="sfForm" name="createbox" action="$action" method="post" class="createbox">
120122
121123 END;
122 - $text .= SFFormUtils::hiddenFieldHTML( 'query', 'true' );
123 - $text .= $form_text;
 124+ $fullFormText .= SFFormUtils::hiddenFieldHTML( 'query', 'true' );
 125+ $fullFormText .= $form_text;
124126 }
 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+
125141 if ( $embedded ) {
126142 $text = "<div class='runQueryEmbedded'>$text</div>";
127143 }