Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93813
Change subject: fix bug 56569 ("Create pages with form" and
sfEditFormPreloadText)
......................................................................
fix bug 56569 ("Create pages with form" and sfEditFormPreloadText)
The sfEditFormPreloadText hook was only called, when a preload was required
(implicitly when saving an existing page or explicitly using the preload
parameter).
It is now called in every case.
Change-Id: I66b9621b8df6d7e39823e14a20847452e3aab3f2
---
M includes/SF_AutoeditAPI.php
1 file changed, 28 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/13/93813/1
diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index 8797183..ab09538 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -725,7 +725,7 @@
*
* @global $wgRequest
* @global $wgOut
- * @global $sfgFormPrinter
+ * @global SFFormPrinter $sfgFormPrinter
* @throws MWException
*/
public function doAction() {
@@ -786,9 +786,6 @@
// 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 ) {
@@ -802,33 +799,8 @@
// the content of the page that was specified
to be used for preloading
$preloadContent = WikiPage::factory(
$preloadTitle )->getRawText();
- } else {
- $preloadContent = null;
- }
-
- wfRunHooks( 'sfEditFormPreloadText', array(
&$preloadContent, $targetTitle, $formTitle ) );
-
- if ( $preloadContent !== null ) {
$pageExists = true;
-
- // spoof $wgRequest for SFFormPrinter::formHTML
- $wgRequest = new FauxRequest( $this->mOptions,
true );
-
- // 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,
$pageExists, $formArticleId, $preloadContent, $targetName, $targetNameFormula
- );
-
- $formHtmlHasRun = true;
-
- // parse the data to be preloaded from the form
html of the
- // existing page
- $data = $this->parseDataFromHTMLFrag( $formHTML
);
-
- // and merge/overwrite it with the new data
- $this->mOptions =
SFUtils::array_merge_recursive_distinct( $data, $this->mOptions );
} else {
if ( isset( $this->mOptions[ 'preload' ] ) ) {
@@ -837,6 +809,33 @@
}
}
+ // allow extensions to set/change the preload text
+ wfRunHooks( 'sfEditFormPreloadText', array( &$preloadContent,
$targetTitle, $formTitle ) );
+
+ // flag to keep track of formHTML runs
+ $formHtmlHasRun = false;
+
+ if ( $preloadContent !== '' ) {
+
+ // spoof $wgRequest for SFFormPrinter::formHTML
+ $wgRequest = new FauxRequest( $this->mOptions, true );
+
+ // 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,
$pageExists, $formArticleId, $preloadContent, $targetName, $targetNameFormula
+ );
+
+ $formHtmlHasRun = true;
+
+ // parse the data to be preloaded from the form html of
the
+ // existing page
+ $data = $this->parseDataFromHTMLFrag( $formHTML );
+
+ // and merge/overwrite it with the new data
+ $this->mOptions =
SFUtils::array_merge_recursive_distinct( $data, $this->mOptions );
+ }
+
// We already preloaded stuff for saving/previewing -
// do not do this again.
if ( $isFormSubmitted && !$wgRequest->getCheck( 'partial' ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/93813
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I66b9621b8df6d7e39823e14a20847452e3aab3f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits