Thai has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/285533

Change subject: Add a 'returnto' parameter to be used in #forminput and 
#formlink parser functions or manually constructed links to forms Sometimes you 
want to edit a page and return to a different one after saving. Imagine you 
have a list of contacts on an overview page
......................................................................

Add a 'returnto' parameter to be used in #forminput and #formlink parser 
functions or manually constructed links to forms
Sometimes you want to edit a page and return to a different one after saving. 
Imagine you have a list of contacts on an overview page. The new 'returnto' 
parameter allows you to link to edit forms for every entry and to create forms 
for new entries and bring the user directly back to the overview page after 
hitting the 'save' button.
Usage example:
{{#formlink:form=SampleForm|link text=come back here|query 
string=returnto={{PAGENAME}}}}
Change-Id: Ib0dc10c30d819198a38abf74e76e6cbea9656874
---
M includes/SF_AutoeditAPI.php
1 file changed, 18 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms 
refs/changes/33/285533/1

diff --git a/includes/SF_AutoeditAPI.php b/includes/SF_AutoeditAPI.php
index 2db3e42..f94890c 100644
--- a/includes/SF_AutoeditAPI.php
+++ b/includes/SF_AutoeditAPI.php
@@ -520,8 +520,15 @@
                                $query = $resultDetails['redirect'] ? 
'redirect=no' : '';
                                $anchor = isset( 
$resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
 
-                               $this->getOutput()->redirect( 
$title->getFullURL( $query ) . $anchor );
-                               $this->getResult()->addValue( NULL, 'redirect', 
$title->getFullURL( $query ) . $anchor );
+                               $redirect = $title->getFullURL( $query ) . 
$anchor;
+
+                               $returnto = Title::newFromText( 
$this->getRequest()->getText( 'returnto' ) );
+                               if ( $returnto !== null ) {
+                                       $redirect = $returnto->getFullURL();
+                               }
+
+                               $this->getOutput()->redirect( $redirect );
+                               $this->getResult()->addValue( NULL, 'redirect', 
$redirect );
                                return false; // success
 
                        case EditPage::AS_SUCCESS_UPDATE: // Article 
successfully updated
@@ -540,8 +547,15 @@
                                        }
                                }
 
-                               $this->getOutput()->redirect( 
$title->getFullURL( $extraQuery ) . $sectionanchor );
-                               $this->getResult()->addValue( NULL, 'redirect', 
$title->getFullURL( $extraQuery ) . $sectionanchor );
+                               $redirect = $title->getFullURL( $extraQuery ) . 
$sectionanchor;
+
+                               $returnto = Title::newFromText( 
$this->getRequest()->getText( 'returnto' ) );
+                               if ( $returnto !== null ) {
+                                       $redirect = $returnto->getFullURL();
+                               }
+
+                               $this->getOutput()->redirect( $redirect );
+                               $this->getResult()->addValue( NULL, 'redirect', 
$redirect );
 
                                return false; // success
 

-- 
To view, visit https://gerrit.wikimedia.org/r/285533
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0dc10c30d819198a38abf74e76e6cbea9656874
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Thai <t...@kollabor.at>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to