Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -217,7 +217,14 @@ |
218 | 218 | if ( !is_null( $oldid ) ) { |
219 | 219 | $oldid = intval( $oldid ); |
220 | 220 | } |
221 | | - return CollectionHooks::getBookCreatorBoxContent( $ajaxHint, $oldid ); |
| 221 | + $html = CollectionHooks::getBookCreatorBoxContent( $ajaxHint, $oldid ); |
| 222 | + |
| 223 | + $json = new Services_JSON(); |
| 224 | + $result = array(); |
| 225 | + $result['html'] = $html; |
| 226 | + $r = new AjaxResponse( $json->encode( $result ) ); |
| 227 | + $r->setContentType( 'application/json' ); |
| 228 | + return $r; |
222 | 229 | } |
223 | 230 | |
224 | 231 | $wgAjaxExportList[] = 'wfAjaxCollectionGetBookCreatorBoxContent'; |
— | — | @@ -225,14 +232,24 @@ |
226 | 233 | function wfAjaxCollectionGetItemList() { |
227 | 234 | wfLoadExtensionMessages( 'CollectionCore' ); |
228 | 235 | wfLoadExtensionMessages( 'Collection' ); |
| 236 | + |
| 237 | + $collection = $_SESSION['wsCollection']; |
| 238 | + |
229 | 239 | $template = new CollectionListTemplate(); |
230 | | - $template->set( 'collection', $_SESSION['wsCollection'] ); |
| 240 | + $template->set( 'collection', $collection ); |
231 | 241 | $template->set( 'is_ajax', true ); |
232 | 242 | ob_start(); |
233 | 243 | $template->execute(); |
234 | 244 | $html = ob_get_contents(); |
235 | 245 | ob_end_clean(); |
236 | | - return $html; |
| 246 | + |
| 247 | + $json = new Services_JSON(); |
| 248 | + $result = array(); |
| 249 | + $result['html'] = $html; |
| 250 | + $result['collection'] = $collection; |
| 251 | + $r = new AjaxResponse( $json->encode( $result ) ); |
| 252 | + $r->setContentType( 'application/json' ); |
| 253 | + return $r; |
237 | 254 | } |
238 | 255 | |
239 | 256 | $wgAjaxExportList[] = 'wfAjaxCollectionGetItemList'; |
Index: trunk/extensions/Collection/js/bookcreator.js |
— | — | @@ -24,12 +24,12 @@ |
25 | 25 | var script_url = wgServer + ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
26 | 26 | |
27 | 27 | function refreshBookCreatorBox(hint, oldid) { |
28 | | - $.get(script_url, { |
| 28 | + $.getJSON(script_url, { |
29 | 29 | 'action': 'ajax', |
30 | 30 | 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
31 | 31 | 'rsargs[]': [hint, oldid] |
32 | 32 | }, function(result) { |
33 | | - $('#coll-book_creator_box').html(result); |
| 33 | + $('#coll-book_creator_box').html(result.html); |
34 | 34 | }); |
35 | 35 | } |
36 | 36 | |
Index: trunk/extensions/Collection/js/collection.js |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | 'action': 'ajax', |
50 | 50 | 'rs': 'wfAjaxCollection' + func, |
51 | 51 | 'rsargs[]': args |
52 | | - }, callback); |
| 52 | + }, callback, 'json'); |
53 | 53 | } |
54 | 54 | |
55 | 55 | var script_url = wgServer + |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | function(result) { |
93 | 93 | refresh_list(result); |
94 | 94 | req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
95 | | - $('#coll-book_creator_box').html(result2); |
| 95 | + $('#coll-book_creator_box').html(result2.html); |
96 | 96 | }); |
97 | 97 | }); |
98 | 98 | } |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | function(result) { |
122 | 122 | refresh_list(result); |
123 | 123 | req('GetBookCreatorBoxContent', ['showbook', null], function(result2) { |
124 | | - $('#coll-book_creator_box').html(result2); |
| 124 | + $('#coll-book_creator_box').html(result2.html); |
125 | 125 | }); |
126 | 126 | }); |
127 | 127 | return false; |
— | — | @@ -173,8 +173,8 @@ |
174 | 174 | $('#collectionList .sortableitem').css('cursor', 'move'); |
175 | 175 | } |
176 | 176 | |
177 | | -function refresh_list(html) { |
178 | | - $('#collectionListContainer').html(html); |
| 177 | +function refresh_list(data) { |
| 178 | + $('#collectionListContainer').html(data.html); |
179 | 179 | $('.makeVisible').css('display', 'inline'); |
180 | 180 | make_sortable(); |
181 | 181 | if ($('#collectionList .article').length == 0) { |
Index: trunk/extensions/Collection/js/suggest.js |
— | — | @@ -26,12 +26,12 @@ |
27 | 27 | $('#collectionSuggestions').html(result.suggestions_html); |
28 | 28 | $('#collectionMembers').html(result.members_html); |
29 | 29 | $('#coll-num_pages').text(result.num_pages); |
30 | | - $.get(script_url, { |
| 30 | + $.getJSON(script_url, { |
31 | 31 | 'action': 'ajax', |
32 | 32 | 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent', |
33 | 33 | 'rsargs[]': ['suggest', null] |
34 | 34 | }, function(result) { |
35 | | - $('#coll-book_creator_box').html(result); |
| 35 | + $('#coll-book_creator_box').html(result.html); |
36 | 36 | }); |
37 | 37 | }, 'json'); |
38 | 38 | } |