r56781 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56780‎ | r56781 | r56782 >
Date:19:22, 22 September 2009
Author:dale
Status:deferred
Tags:
Comment:
added missing json function in stand alone usage
Modified paths:
  • /trunk/phase3/js2/mwEmbed/php/noMediaWikiConfig.php (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/php/noMediaWikiConfig.php
@@ -105,4 +105,29 @@
106106 return '<' . $msgKey . '>';
107107 }
108108 }
 109+class FormatJson{
 110+ public static function encode($value, $isHtml=false){
 111+ // Some versions of PHP have a broken json_encode, see PHP bug
 112+ // 46944. Test encoding an affected character (U+20000) to
 113+ // avoid this.
 114+ if (!function_exists('json_encode') || $isHtml || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') {
 115+ $json = new Services_JSON();
 116+ return $json->encode($value, $isHtml) ;
 117+ } else {
 118+ return json_encode($value);
 119+ }
 120+ }
 121+ public static function decode( $value, $assoc=false ){
 122+ if (!function_exists('json_decode') ) {
 123+ $json = new Services_JSON();
 124+ $jsonDec = $json->decode( $value );
 125+ if( $assoc )
 126+ $jsonDec = wfObjectToArray( $jsonDec );
 127+ return $jsonDec;
 128+ } else {
 129+ return json_decode( $value, $assoc );
 130+ }
 131+ }
 132+}
 133+
109134 ?>

Status & tagging log