Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/50039
Change subject: bugfixes (incorrect page title; some inputs don't work)
......................................................................
bugfixes (incorrect page title; some inputs don't work)
* The form at the top now has the correct title.
* The "map" form input works again.
Change-Id: I68ad0415e5de258734947da15ba700a56842c3ae
followup: Ifa72f031b
---
M includes/SF_AutoeditAPI.php
M specials/SF_FormEdit.php
2 files changed, 35 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/39/50039/1
diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index 2ab2208..af5a34c 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -768,7 +768,10 @@
// save $wgRequest for later restoration
$oldRequest = $wgRequest;
-
+
+ // flag to keep track of formHTML runs
+ $formHtmlHasRun = false;
+
// preload data if not explicitly excluded and if the preload
page exists
if ( !isset( $this->mOptions[ 'preload' ] ) || $this->mOptions[
'preload' ] !== false ) {
@@ -793,18 +796,13 @@
// save wgOut for later restoration
$oldOut = $wgOut;
- // spoof wgOut; if we took the general $wgOut
some JS modules
- // might attach themselves twice and thus be
called twice
- $wgOut = new OutputPage(
RequestContext::getMain() );
-
// call SFFormPrinter::formHTML to get at the
form html of the existing page
list ( $formHTML, $formJS, $targetContent,
$form_page_title, $generatedTargetNameFormula ) =
$sfgFormPrinter->formHTML(
$formContent, $isFormSubmitted,
$isPageSource, $formArticleId, $preloadContent, $targetName, $targetNameFormula
);
- // restore wgOut
- $wgOut = $oldOut;
+ $formHtmlHasRun = true;
// parse the data to be preloaded from the form
html of the
// existing page
@@ -829,10 +827,23 @@
// spoof wgRequest for SFFormPrinter::formHTML
$wgRequest = new FauxRequest( $this->mOptions, true );
- // get wikitext for submitted data and form
- list ( $formHTML, $formJS, $targetContent, $generatedFormName,
$generatedTargetNameFormula ) =
- $sfgFormPrinter->formHTML( $formContent,
$isFormSubmitted, $isPageSource, $formArticleId, $preloadContent, $targetName,
$targetNameFormula );
+ // if necessary spoof wgOut; if we took the general $wgOut
again some JS
+ // modules might attach themselves twice and thus be called
twice
+ if ( $formHtmlHasRun ) {
+ $wgOut = new OutputPage( RequestContext::getMain() );
+ // get wikitext for submitted data and form
+ list ( $formHTML, $formJS, $targetContent,
$generatedFormName, $generatedTargetNameFormula ) =
+ $sfgFormPrinter->formHTML(
$formContent, $isFormSubmitted, $isPageSource, $formArticleId, $preloadContent,
$targetName, $targetNameFormula );
+
+ // restore wgOut
+ $wgOut = $oldOut;
+ } else {
+
+ // get wikitext for submitted data and form
+ list ( $formHTML, $formJS, $targetContent,
$generatedFormName, $generatedTargetNameFormula ) =
+ $sfgFormPrinter->formHTML(
$formContent, $isFormSubmitted, $isPageSource, $formArticleId, $preloadContent,
$targetName, $targetNameFormula );
+ }
// restore original request
$wgRequest = $oldRequest;
diff --git a/specials/SF_FormEdit.php b/specials/SF_FormEdit.php
index e0b9dde..df89482 100644
--- a/specials/SF_FormEdit.php
+++ b/specials/SF_FormEdit.php
@@ -61,7 +61,7 @@
return $text;
}
- static function printForm( &$form_name, &$target_name, $alt_forms =
array( ) ) {
+ static function printForm( &$form_name, &$targetName, $alt_forms =
array( ) ) {
global $wgOut, $wgRequest;
@@ -71,12 +71,12 @@
$module = new SFAutoeditAPI( new ApiMain( $wgRequest ),
'sfautoedit' );
}
$module->setOption( 'form', $form_name );
- $module->setOption( 'target', $target_name );
+ $module->setOption( 'target', $targetName );
if ( $wgRequest->getCheck( 'wpSave' ) || $wgRequest->getCheck(
'wpPreview' ) || $wgRequest->getCheck( 'wpDiff' ) ) {
// if the page was submitted, formdata should be
complete => do not preload
$module->setOption( 'preload', false );
- } else if ( !empty($target_name) && Title::newFromText(
$target_name )->exists ( ) ) {
+ } else if ( !empty($targetName) && Title::newFromText(
$targetName )->exists ( ) ) {
// if target page exists do not overwrite it with
preload data, just preload the page's data
$module->setOption( 'preload', true );
} else if ( $wgRequest->getCheck( 'preload' ) ) {
@@ -96,26 +96,31 @@
// override the default title for this page if a title was
specified in the form
$result = $module->getOptions();
- $target_title = Title::newFromText( $result[ 'target' ] );
+ $targetTitle = Title::newFromText( $result[ 'target' ] );
+ // set page title depending on whether the target page exists
+
if ( $result[ 'form' ] !== '' ) {
- if ( $target_name === null || $target_name === '' ) {
- $wgOut->setPageTitle( $result[ 'form' ] );
+ if ( empty( $targetName ) ) {
+ $pageTitle = wfMessage(
'sf_formedit_createtitlenotarget', $result[ 'form' ] )->text();
+ } elseif ( $targetTitle->exists() ) {
+ $pageTitle = wfMessage(
'sf_formedit_edittitle', $result[ 'form' ], $targetName )->text();
} else {
- $wgOut->setPageTitle( $result[ 'form' ] . ': '
. $target_name );
+ $pageTitle = wfMessage(
'sf_formedit_createtitle', $result[ 'form' ], $targetName )->text();
}
+ $wgOut->setPageTitle( $pageTitle );
}
$text = '';
if ( count( $alt_forms ) > 0 ) {
$text .= '<div class="infoMessage">' . wfMessage(
'sf_formedit_altforms' )->escaped() . ' ';
- $text .= self::printAltFormsList( $alt_forms,
$target_name );
+ $text .= self::printAltFormsList( $alt_forms,
$targetName );
$text .= "</div>\n";
}
$text .= '<form name="createbox" id="sfForm" method="post"
class="createbox">';
$pre_form_html = '';
- wfRunHooks( 'sfHTMLBeforeForm', array( &$target_title,
&$pre_form_html ) );
+ wfRunHooks( 'sfHTMLBeforeForm', array( &$targetTitle,
&$pre_form_html ) );
$text .= $pre_form_html;
if ( isset( $result[ 'formHTML' ] ) ) {
$text .= $result[ 'formHTML' ];
--
To view, visit https://gerrit.wikimedia.org/r/50039
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I68ad0415e5de258734947da15ba700a56842c3ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits