coding standards

This commit is contained in:
Loïc Chapeaux
2002-07-05 13:25:03 +00:00
parent a895515170
commit a5d00d53a9
3 changed files with 93 additions and 75 deletions

View File

@@ -16,7 +16,6 @@ if (!defined('PMA_BOOKMARK_LIB_INCLUDED')){
* *
* @return array the bookmark parameters for the current user * @return array the bookmark parameters for the current user
* *
* @global array the list of settings for the current server
* @global integer the id of the current server * @global integer the id of the current server
* *
* @access public * @access public

View File

@@ -13,9 +13,9 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
/** /**
* Loads the recode or iconv extensions if any of it is not loaded yet * Loads the recode or iconv extensions if any of it is not loaded yet
*/ */
if ( isset($cfg['AllowAnywhereRecoding']) if ( isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding'] && $cfg['AllowAnywhereRecoding']
&& $allow_recoding && $allow_recoding
&& ((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) && ((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl'))
|| (PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) || (PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
&& @function_exists('dl')) { && @function_exists('dl')) {
@@ -37,6 +37,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} // end load mysql extension } // end load mysql extension
// if allowed recoding, we should try to load extensions for it... // if allowed recoding, we should try to load extensions for it...
/** /**
* Converts encoding according to current settings. * Converts encoding according to current settings.
* *
@@ -44,63 +45,72 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
* *
* @return string converted string or array of strings * @return string converted string or array of strings
* *
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public * @access public
* *
* @author nijel * @author nijel
*/ */
function PMA_convert_display_charset($what) { function PMA_convert_display_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset; global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what; if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
} else { return $what;
if (is_array($what)) { }
$result = array(); else if (is_array($what)) {
reset($what); $result = array();
while(list($key,$val) = each($what)) { reset($what);
//Debug: echo '['.$key.']='.$val.'<br>'; while(list($key, $val) = each($what)) {
//Debug: echo '['.$key.'] = ' . $val . '<br />';
if (is_string($val) || is_array($val)) {
if (is_string($key)) { if (is_string($val) || is_array($val)) {
$result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val); if (is_string($key)) {
} else { $result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val);
$result[$key] = PMA_convert_display_charset($val); } else {
} $result[$key] = PMA_convert_display_charset($val);
} else { }
$result[$key] = $val; } else {
} $result[$key] = $val;
} }
return $result; } // end while
} elseif (is_string($what)) { return $result;
if (@function_exists('iconv')) { }
//Debug: echo 'PMA_convert_display_charset: '.$what.'->'.iconv($convcharset, $charset, $what)."\n<br>"; else if (is_string($what)) {
return iconv($convcharset, $charset, $what); if (@function_exists('iconv')) {
} else if (@function_exists('libiconv')) { //Debug: echo 'PMA_convert_display_charset: ' . $what . '->' . iconv($convcharset, $charset, $what) . "\n<br />";
return iconv($convcharset, $charset, $what); return iconv($convcharset, $charset, $what);
} else if (@function_exists('recode_string')) { } else if (@function_exists('libiconv')) {
return recode_string($convcharset . '..' . $charset, $what); return iconv($convcharset, $charset, $what);
} else { } else if (@function_exists('recode_string')) {
echo $strCantUseRecodeIconv; return recode_string($convcharset . '..' . $charset, $what);
return $what; } else {
} echo $strCantUseRecodeIconv;
} elseif (is_object($what)) { return $what;
// isn't it object returned from mysql_fetch_field ? }
if (@is_string($what->name)) { }
$what->name = PMA_convert_display_charset( $what->name ); else if (is_object($what)) {
} // isn't it object returned from mysql_fetch_field ?
if (@is_string($what->table)) { if (@is_string($what->name)) {
$what->table = PMA_convert_display_charset( $what->table ); $what->name = PMA_convert_display_charset($what->name);
} }
if (@is_string($what->Database)) { if (@is_string($what->table)) {
$what->Database = PMA_convert_display_charset( $what->Database ); $what->table = PMA_convert_display_charset($what->table);
} }
return $what; if (@is_string($what->Database)) {
} else { $what->Database = PMA_convert_display_charset($what->Database);
// when we don't know what it is we don't touch it... }
return $what; return $what;
} }
} else {
} // when we don't know what it is we don't touch it...
return $what;
}
} // end of the "PMA_convert_display_charset()" function
/** /**
* Converts encoding of text according to current settings. * Converts encoding of text according to current settings.
* *
@@ -108,27 +118,35 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
* *
* @return string converted text * @return string converted text
* *
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public * @access public
* *
* @author nijel * @author nijel
*/ */
function PMA_convert_charset($what) { function PMA_convert_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset; global $cfg, $allow_recoding, $charset, $convcharset;
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
return $what; return $what;
} else { }
if (@function_exists('iconv')) { else {
//Debug: echo 'PMA_convert_charset: '.$what.'->'.iconv($charset, $convcharset, $what)."\n<br>"; if (@function_exists('iconv')) {
return iconv($charset, $convcharset, $what); //Debug: echo 'PMA_convert_charset: ' . $what . '->' . iconv($charset, $convcharset, $what) . "\n<br />";
} else if (@function_exists('libiconv')) { return iconv($charset, $convcharset, $what);
return iconv($charset, $convcharset, $what); } else if (@function_exists('libiconv')) {
} else if (@function_exists('recode_string')) { return iconv($charset, $convcharset, $what);
return recode_string($charset . '..' . $convcharset, $what); } else if (@function_exists('recode_string')) {
} else { return recode_string($charset . '..' . $convcharset, $what);
echo $strCantUseRecodeIconv; } else {
return $what; echo $strCantUseRecodeIconv;
} return $what;
} }
} }
} // PMA_CHARSET_CONVERSION_LIB_INCLUDED } // end of the "PMA_convert_charset()" function
} // $__PMA_CHARSET_CONVERSION_LIB__
?> ?>

View File

@@ -1,6 +1,7 @@
<?php <?php
/* $Id$ */ /* $Id$ */
/** /**
* Ensure the database and the table exist (else move to the "parent" script) * Ensure the database and the table exist (else move to the "parent" script)
* and display headers * and display headers