r111672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111671‎ | r111672 | r111673 >
Date:20:01, 16 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Use the FormatJson wrapper functions
Modified paths:
  • /trunk/extensions/Collection/Collection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -192,13 +192,12 @@
193193 # register global Ajax functions:
194194
195195 function wfAjaxGetCollection() {
196 - $json = new Services_JSON();
197196 if ( isset( $_SESSION['wsCollection'] ) ) {
198197 $collection = $_SESSION['wsCollection'];
199198 } else {
200199 $collection = array();
201200 }
202 - $r = new AjaxResponse( $json->encode( array( 'collection' => $collection ) ) );
 201+ $r = new AjaxResponse( FormatJson::encode( array( 'collection' => $collection ) ) );
203202 $r->setContentType( 'application/json' );
204203 return $r;
205204 }
@@ -231,7 +230,6 @@
232231 $wgAjaxExportList[] = 'wfAjaxPostCollection';
233232
234233 function wfAjaxGetMWServeStatus( $collection_id = '', $writer = 'rl' ) {
235 - $json = new Services_JSON();
236234 $result = SpecialCollection::mwServeCommand( 'render_status', array(
237235 'collection_id' => $collection_id,
238236 'writer' => $writer
@@ -239,7 +237,7 @@
240238 if ( isset( $result['status']['progress'] ) ) {
241239 $result['status']['progress'] = number_format( $result['status']['progress'], 2, '.', '' );
242240 }
243 - $r = new AjaxResponse( $json->encode( $result ) );
 241+ $r = new AjaxResponse( FormatJson::encode( $result ) );
244242 $r->setContentType( 'application/json' );
245243 return $r;
246244 }
@@ -282,10 +280,9 @@
283281
284282 $html = CollectionHooks::getBookCreatorBoxContent( $title, $ajaxHint, $oldid );
285283
286 - $json = new Services_JSON();
287284 $result = array();
288285 $result['html'] = $html;
289 - $r = new AjaxResponse( $json->encode( $result ) );
 286+ $r = new AjaxResponse( FormatJson::encode( $result ) );
290287 $r->setContentType( 'application/json' );
291288 return $r;
292289 }
@@ -303,11 +300,10 @@
304301 $html = ob_get_contents();
305302 ob_end_clean();
306303
307 - $json = new Services_JSON();
308304 $result = array();
309305 $result['html'] = $html;
310306 $result['collection'] = $collection;
311 - $r = new AjaxResponse( $json->encode( $result ) );
 307+ $r = new AjaxResponse( FormatJson::encode( $result ) );
312308 $r->setContentType( 'application/json' );
313309 return $r;
314310 }
@@ -368,7 +364,6 @@
369365 function wfAjaxCollectionGetPopupData( $title ) {
370366 global $wgScriptPath;
371367
372 - $json = new Services_JSON();
373368 $result = array();
374369 $imagePath = "$wgScriptPath/extensions/Collection/images";
375370 $t = Title::newFromText( $title );
@@ -389,7 +384,7 @@
390385 $result['img'] = "$imagePath/silk-remove.png";
391386 }
392387 $result['title'] = $title;
393 - $r = new AjaxResponse( $json->encode( $result ) );
 388+ $r = new AjaxResponse( FormatJson::encode( $result ) );
394389 $r->setContentType( 'application/json' );
395390 return $r;
396391 }
@@ -403,7 +398,6 @@
404399 * @return AjaxResponse with JSON-encoded array including HTML fragment.
405400 */
406401 function wfCollectionSuggestAction( $action, $article ) {
407 - $json = new Services_JSON();
408402 $result = CollectionSuggest::refresh( $action, $article );
409403 $undoLink = Xml::element( 'a',
410404 array(
@@ -423,7 +417,7 @@
424418 $undoLink
425419 );
426420 $result['collection'] = CollectionSession::getCollection();
427 - $r = new AjaxResponse( $json->encode( $result ) );
 421+ $r = new AjaxResponse( FormatJson::encode( $result ) );
428422 $r->setContentType( 'application/json' );
429423 return $r;
430424 }

Status & tagging log