From 097170801df4972df514b9f164c1bb28835f9d3f Mon Sep 17 00:00:00 2001 From: LeoColomb Date: Thu, 11 Apr 2013 20:54:47 +0200 Subject: [PATCH] Tabify --- admin/plugins.php | 2 +- includes/functions-api.php | 2 +- includes/functions-compat.php | 82 +++++++++--------- includes/functions-html.php | 32 ++++---- includes/functions-http.php | 20 ++--- includes/functions-install.php | 64 +++++++-------- includes/functions-l10n.php | 146 ++++++++++++++++----------------- 7 files changed, 174 insertions(+), 174 deletions(-) diff --git a/admin/plugins.php b/admin/plugins.php index 7183308..4a3594a 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -67,7 +67,7 @@ uasort( $plugins, 'yourls_plugins_sort_callback' ); $count = count( $plugins ); - $plugins_count = sprintf( yourls_n( '%s plugin', '%s plugins', $count ), $count ); + $plugins_count = sprintf( yourls_n( '%s plugin', '%s plugins', $count ), $count ); $count_active = yourls_has_active_plugins(); ?> diff --git a/includes/functions-api.php b/includes/functions-api.php index 01a23aa..3d83d42 100644 --- a/includes/functions-api.php +++ b/includes/functions-api.php @@ -108,7 +108,7 @@ function yourls_api_output( $mode, $return ) { header( 'Content-type: application/javascript' ); echo $return['callback'] . '(' . json_encode( $return ) . ')'; break; - + case 'json': header( 'Content-type: application/json' ); echo json_encode( $return ); diff --git a/includes/functions-compat.php b/includes/functions-compat.php index 8bd6391..5ddede4 100644 --- a/includes/functions-compat.php +++ b/includes/functions-compat.php @@ -20,60 +20,60 @@ function json_encode( $array ) { */ function yourls_array_to_json( $array ){ - if( !is_array( $array ) ){ - return false; - } + if( !is_array( $array ) ){ + return false; + } - $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) )); - if( $associative ){ + $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) )); + if( $associative ){ - $construct = array(); - foreach( $array as $key => $value ){ + $construct = array(); + foreach( $array as $key => $value ){ - // We first copy each key/value pair into a staging array, - // formatting each key and value properly as we go. + // We first copy each key/value pair into a staging array, + // formatting each key and value properly as we go. - // Format the key: - if( is_numeric( $key ) ){ - $key = "key_$key"; - } - $key = '"'.addslashes( $key ).'"'; + // Format the key: + if( is_numeric( $key ) ){ + $key = "key_$key"; + } + $key = '"'.addslashes( $key ).'"'; - // Format the value: - if( is_array( $value )){ - $value = yourls_array_to_json( $value ); - } else if( !is_numeric( $value ) || is_string( $value ) ){ - $value = '"'.addslashes( $value ).'"'; - } + // Format the value: + if( is_array( $value )){ + $value = yourls_array_to_json( $value ); + } else if( !is_numeric( $value ) || is_string( $value ) ){ + $value = '"'.addslashes( $value ).'"'; + } - // Add to staging array: - $construct[] = "$key: $value"; - } + // Add to staging array: + $construct[] = "$key: $value"; + } - // Then we collapse the staging array into the JSON form: - $result = "{ " . implode( ", ", $construct ) . " }"; + // Then we collapse the staging array into the JSON form: + $result = "{ " . implode( ", ", $construct ) . " }"; - } else { // If the array is a vector (not associative): + } else { // If the array is a vector (not associative): - $construct = array(); - foreach( $array as $value ){ + $construct = array(); + foreach( $array as $value ){ - // Format the value: - if( is_array( $value )){ - $value = yourls_array_to_json( $value ); - } else if( !is_numeric( $value ) || is_string( $value ) ){ - $value = '"'.addslashes($value).'"'; - } + // Format the value: + if( is_array( $value )){ + $value = yourls_array_to_json( $value ); + } else if( !is_numeric( $value ) || is_string( $value ) ){ + $value = '"'.addslashes($value).'"'; + } - // Add to staging array: - $construct[] = $value; - } + // Add to staging array: + $construct[] = $value; + } - // Then we collapse the staging array into the JSON form: - $result = "[ " . implode( ", ", $construct ) . " ]"; - } + // Then we collapse the staging array into the JSON form: + $result = "[ " . implode( ", ", $construct ) . " ]"; + } - return $result; + return $result; } /** diff --git a/includes/functions-html.php b/includes/functions-html.php index b12b2dc..8587b6e 100644 --- a/includes/functions-html.php +++ b/includes/functions-html.php @@ -113,10 +113,10 @@ function yourls_html_head( $context = 'index', $title = '' ) { - - + +