r65565 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65564‎ | r65565 | r65566 >
Date:08:40, 27 April 2010
Author:jojo
Status:ok
Tags:
Comment:
JSON responses only
Modified paths:
  • /trunk/extensions/Collection/Collection.php (modified) (history)
  • /trunk/extensions/Collection/js/bookcreator.js (modified) (history)
  • /trunk/extensions/Collection/js/collection.js (modified) (history)
  • /trunk/extensions/Collection/js/suggest.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -217,7 +217,14 @@
218218 if ( !is_null( $oldid ) ) {
219219 $oldid = intval( $oldid );
220220 }
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;
222229 }
223230
224231 $wgAjaxExportList[] = 'wfAjaxCollectionGetBookCreatorBoxContent';
@@ -225,14 +232,24 @@
226233 function wfAjaxCollectionGetItemList() {
227234 wfLoadExtensionMessages( 'CollectionCore' );
228235 wfLoadExtensionMessages( 'Collection' );
 236+
 237+ $collection = $_SESSION['wsCollection'];
 238+
229239 $template = new CollectionListTemplate();
230 - $template->set( 'collection', $_SESSION['wsCollection'] );
 240+ $template->set( 'collection', $collection );
231241 $template->set( 'is_ajax', true );
232242 ob_start();
233243 $template->execute();
234244 $html = ob_get_contents();
235245 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;
237254 }
238255
239256 $wgAjaxExportList[] = 'wfAjaxCollectionGetItemList';
Index: trunk/extensions/Collection/js/bookcreator.js
@@ -24,12 +24,12 @@
2525 var script_url = wgServer + ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript);
2626
2727 function refreshBookCreatorBox(hint, oldid) {
28 - $.get(script_url, {
 28+ $.getJSON(script_url, {
2929 'action': 'ajax',
3030 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent',
3131 'rsargs[]': [hint, oldid]
3232 }, function(result) {
33 - $('#coll-book_creator_box').html(result);
 33+ $('#coll-book_creator_box').html(result.html);
3434 });
3535 }
3636
Index: trunk/extensions/Collection/js/collection.js
@@ -48,7 +48,7 @@
4949 'action': 'ajax',
5050 'rs': 'wfAjaxCollection' + func,
5151 'rsargs[]': args
52 - }, callback);
 52+ }, callback, 'json');
5353 }
5454
5555 var script_url = wgServer +
@@ -91,7 +91,7 @@
9292 function(result) {
9393 refresh_list(result);
9494 req('GetBookCreatorBoxContent', ['showbook', null], function(result2) {
95 - $('#coll-book_creator_box').html(result2);
 95+ $('#coll-book_creator_box').html(result2.html);
9696 });
9797 });
9898 }
@@ -120,7 +120,7 @@
121121 function(result) {
122122 refresh_list(result);
123123 req('GetBookCreatorBoxContent', ['showbook', null], function(result2) {
124 - $('#coll-book_creator_box').html(result2);
 124+ $('#coll-book_creator_box').html(result2.html);
125125 });
126126 });
127127 return false;
@@ -173,8 +173,8 @@
174174 $('#collectionList .sortableitem').css('cursor', 'move');
175175 }
176176
177 -function refresh_list(html) {
178 - $('#collectionListContainer').html(html);
 177+function refresh_list(data) {
 178+ $('#collectionListContainer').html(data.html);
179179 $('.makeVisible').css('display', 'inline');
180180 make_sortable();
181181 if ($('#collectionList .article').length == 0) {
Index: trunk/extensions/Collection/js/suggest.js
@@ -26,12 +26,12 @@
2727 $('#collectionSuggestions').html(result.suggestions_html);
2828 $('#collectionMembers').html(result.members_html);
2929 $('#coll-num_pages').text(result.num_pages);
30 - $.get(script_url, {
 30+ $.getJSON(script_url, {
3131 'action': 'ajax',
3232 'rs': 'wfAjaxCollectionGetBookCreatorBoxContent',
3333 'rsargs[]': ['suggest', null]
3434 }, function(result) {
35 - $('#coll-book_creator_box').html(result);
 35+ $('#coll-book_creator_box').html(result.html);
3636 });
3737 }, 'json');
3838 }

Status & tagging log