User:Daniel5000/SemanticForms-HideAdditionalQuery

This patch adds an additional parameter to the info tag to hide the additional query form after a form has been submitted. This could be useful if you want to split a large query into many smaller queries and connect them via {{#queryformlink}}.

{{{info|hide additional query}}}

includes/SF_FormPrinter.php edit

Modify includes/SF_FormPrinter.php:

Replace this section (around line 1501):

                                                } elseif ( $tag == 'query form at top' ) {
							// TODO - this should be made a field of
							// some non-static class that actually
							// prints the form, instead of requiring
							// a global variable.
							global $sfgRunQueryFormAtTop;
							$sfgRunQueryFormAtTop = true;

with this extended section:

                                                } elseif ( $tag == 'query form at top' ) {
							// TODO - this should be made a field of
							// some non-static class that actually
							// prints the form, instead of requiring
							// a global variable.
							global $sfgRunQueryFormAtTop;
							$sfgRunQueryFormAtTop = true;
						} elseif ( $tag == 'hide additional query' ) {
							global $sfgHideAdditionalQuery;
							$sfgHideAdditionalQuery = true;

specials/SF_RunQuery.php edit

At about line 34, replace:

	function printPage( $form_name, $embedded = false ) {
		global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop;
		global $wgUser, $wgTitle;

with:

	function printPage( $form_name, $embedded = false ) {
		global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop, $sfgHideAdditionalQuery;
		global $wgUser, $wgTitle;

and about line 125, replace:

		// Either don't display a query form at all, or display the
		// query form at the top, and the results at the bottom, or the
		// other way around, depending on the settings.
		if ( $wgRequest->getVal( 'additionalquery' ) == 'false' ) {
			$text .= $resultsText;
		} elseif ( $sfgRunQueryFormAtTop ) {
			$text .= $fullFormText;
			$text .= $dividerText;
			$text .= $resultsText;
		} else {
			$text .= $resultsText;
			$text .= $additionalQueryHeader;
			$text .= $fullFormText;
		}

with:


		// Either don't display a query form at all, or display the
		// query form at the top, and the results at the bottom, or the
		// other way around, depending on the settings.
		if ( $wgRequest->getVal( 'additionalquery' ) == 'false' ) {
			$text .= $resultsText;
		} elseif ( $sfgHideAdditionalQuery and $form_submitted ) {
			$text .= $resultsText;
		} elseif ( $sfgRunQueryFormAtTop ) {
			$text .= $fullFormText;
			$text .= $dividerText;
			$text .= $resultsText;
		} else {
			$text .= $resultsText;
			$text .= $additionalQueryHeader;
			$text .= $fullFormText;
		}