Merge "Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups()."
[lhc/web/wiklou.git] / includes / json / FormatJson.php
index bbcc185..f67700c 100644 (file)
@@ -20,7 +20,7 @@
  * @file
  */
 
-require_once dirname( __FILE__ ) . '/Services_JSON.php';
+require_once __DIR__ . '/Services_JSON.php';
 
 /**
  * JSON formatter wrapper class
@@ -41,11 +41,11 @@ class FormatJson {
         * @return string
         */
        public static function encode( $value, $isHtml = false ) {
-               if ( !function_exists( 'json_encode' ) || $isHtml ) {
+               if ( !function_exists( 'json_encode' ) || ( $isHtml && version_compare( PHP_VERSION, '5.4.0', '<' ) ) ) {
                        $json = new Services_JSON();
                        return $json->encode( $value, $isHtml );
                } else {
-                       return json_encode( $value );
+                       return json_encode( $value, $isHtml ? JSON_PRETTY_PRINT : 0 );
                }
        }