Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -174,15 +174,24 @@ |
175 | 175 | |
176 | 176 | $wgAjaxExportList[] = 'wfAjaxGetCollection'; |
177 | 177 | |
178 | | -function wfAjaxPostCollection( $collection = '' ) { |
| 178 | +function wfAjaxPostCollection( $collection = '', $redirect = '' ) { |
179 | 179 | $json = new Services_JSON( SERVICES_JSON_LOOSE_TYPE ); |
180 | 180 | if ( session_id() == '' ) { |
181 | 181 | wfSetupSession(); |
182 | 182 | } |
183 | 183 | $collection = $json->decode( $collection ); |
| 184 | + $collection['enabled'] = true; |
184 | 185 | $_SESSION['wsCollection'] = $collection; |
185 | | - $r = new AjaxResponse( $json->encode( array( 'collection' => $collection ) ) ); |
186 | | - $r->setContentType( 'application/json' ); |
| 186 | + $title = SpecialPage::getTitleFor( 'Book' ); |
| 187 | + $redirecturl = $title->getFullURL( $urlaction ); |
| 188 | + $r = new AjaxResponse(); |
| 189 | + if ( $redirect ) { |
| 190 | + $r->setResponseCode( 302 ); |
| 191 | + header( 'Location: ' . $redirecturl ); |
| 192 | + } else { |
| 193 | + $r->setContentType( 'application/json' ); |
| 194 | + $r->addText( $json->encode( array( 'redirect_url' => $redirecturl ) ) ); |
| 195 | + } |
187 | 196 | return $r; |
188 | 197 | } |
189 | 198 | |
Index: trunk/extensions/Collection/Collection.session.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | |
44 | 44 | static function clearCollection() { |
45 | 45 | $_SESSION['wsCollection'] = array( |
46 | | - 'enabled' => 'true', |
| 46 | + 'enabled' => true, |
47 | 47 | 'title' => '', |
48 | 48 | 'subtitle' => '', |
49 | 49 | 'items' => array(), |
Index: trunk/extensions/Collection/js/check_load_from_localstorage.js |
— | — | @@ -25,8 +25,8 @@ |
26 | 26 | 'action': 'ajax', |
27 | 27 | 'rs': 'wfAjaxPostCollection', |
28 | 28 | 'rsargs[]': [JSON.stringify(c)] |
29 | | - }, function() { |
30 | | - window.location.href = collection_redirect_url; |
| 29 | + }, function(result) { |
| 30 | + window.location.href = result.redirect_url; |
31 | 31 | }, 'json'); |
32 | 32 | } |
33 | 33 | } |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -339,12 +339,10 @@ |
340 | 340 | |
341 | 341 | $coll = CollectionSession::getCollection(); |
342 | 342 | $dialogtxt = wfMsg( 'coll-load_local_book' ); |
343 | | - $redirecturl = SkinTemplate::makeSpecialUrl( 'Book' ); |
344 | 343 | |
345 | 344 | $wgOut->addScript( |
346 | 345 | "<script type=\"$wgJsMimeType\">\n" . |
347 | 346 | "var collection_dialogtxt = " . Xml::encodeJsVar( $dialogtxt ) . ";\n" . |
348 | | - "var collection_redirect_url = " . Xml::encodeJsVar( $redirecturl ) . ";\n" . |
349 | 347 | "</script>" ); |
350 | 348 | |
351 | 349 | $wgOut->mScripts .= <<<EOS |