http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73943
Revision: 73943
Author: jojo
Date: 2010-09-29 12:30:43 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
return redirect URL as JSON or a 302 response
Modified Paths:
--------------
trunk/extensions/Collection/Collection.body.php
trunk/extensions/Collection/Collection.php
trunk/extensions/Collection/Collection.session.php
trunk/extensions/Collection/js/check_load_from_localstorage.js
Modified: trunk/extensions/Collection/Collection.body.php
===================================================================
--- trunk/extensions/Collection/Collection.body.php 2010-09-29 12:09:55 UTC
(rev 73942)
+++ trunk/extensions/Collection/Collection.body.php 2010-09-29 12:30:43 UTC
(rev 73943)
@@ -339,12 +339,10 @@
$coll = CollectionSession::getCollection();
$dialogtxt = wfMsg( 'coll-load_local_book' );
- $redirecturl = SkinTemplate::makeSpecialUrl( 'Book' );
$wgOut->addScript(
"<script type=\"$wgJsMimeType\">\n" .
"var collection_dialogtxt = " . Xml::encodeJsVar(
$dialogtxt ) . ";\n" .
- "var collection_redirect_url = " . Xml::encodeJsVar(
$redirecturl ) . ";\n" .
"</script>" );
$wgOut->mScripts .= <<<EOS
Modified: trunk/extensions/Collection/Collection.php
===================================================================
--- trunk/extensions/Collection/Collection.php 2010-09-29 12:09:55 UTC (rev
73942)
+++ trunk/extensions/Collection/Collection.php 2010-09-29 12:30:43 UTC (rev
73943)
@@ -174,15 +174,24 @@
$wgAjaxExportList[] = 'wfAjaxGetCollection';
-function wfAjaxPostCollection( $collection = '' ) {
+function wfAjaxPostCollection( $collection = '', $redirect = '' ) {
$json = new Services_JSON( SERVICES_JSON_LOOSE_TYPE );
if ( session_id() == '' ) {
wfSetupSession();
}
$collection = $json->decode( $collection );
+ $collection['enabled'] = true;
$_SESSION['wsCollection'] = $collection;
- $r = new AjaxResponse( $json->encode( array( 'collection' =>
$collection ) ) );
- $r->setContentType( 'application/json' );
+ $title = SpecialPage::getTitleFor( 'Book' );
+ $redirecturl = $title->getFullURL( $urlaction );
+ $r = new AjaxResponse();
+ if ( $redirect ) {
+ $r->setResponseCode( 302 );
+ header( 'Location: ' . $redirecturl );
+ } else {
+ $r->setContentType( 'application/json' );
+ $r->addText( $json->encode( array( 'redirect_url' =>
$redirecturl ) ) );
+ }
return $r;
}
Modified: trunk/extensions/Collection/Collection.session.php
===================================================================
--- trunk/extensions/Collection/Collection.session.php 2010-09-29 12:09:55 UTC
(rev 73942)
+++ trunk/extensions/Collection/Collection.session.php 2010-09-29 12:30:43 UTC
(rev 73943)
@@ -42,7 +42,7 @@
static function clearCollection() {
$_SESSION['wsCollection'] = array(
- 'enabled' => 'true',
+ 'enabled' => true,
'title' => '',
'subtitle' => '',
'items' => array(),
Modified: trunk/extensions/Collection/js/check_load_from_localstorage.js
===================================================================
--- trunk/extensions/Collection/js/check_load_from_localstorage.js
2010-09-29 12:09:55 UTC (rev 73942)
+++ trunk/extensions/Collection/js/check_load_from_localstorage.js
2010-09-29 12:30:43 UTC (rev 73943)
@@ -25,8 +25,8 @@
'action': 'ajax',
'rs': 'wfAjaxPostCollection',
'rsargs[]': [JSON.stringify(c)]
- }, function() {
- window.location.href =
collection_redirect_url;
+ }, function(result) {
+ window.location.href =
result.redirect_url;
}, 'json');
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs