Improve function and variables names

This commit is contained in:
Marc Delisle
2010-04-13 08:51:07 -04:00
parent da979369c8
commit 05e4e16b8a
2 changed files with 17 additions and 13 deletions

View File

@@ -1506,23 +1506,23 @@ function PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false)
/** /**
* Returns the number of bytes when a formatted size is given * Returns the number of bytes when a formatted size is given
* *
* @param double $value the value that should be converted to bytes * @param string $size the size expression (for example 8MB)
* @uses PMA_pow() * @uses PMA_pow()
* @return integer The number of bytes corresponding to the formatted size given * @return integer The numerical part of the expression (for example 8)
*/ */
function PMA_getBytes($value) function PMA_extractValueFromFormattedSize($formatted_size)
{ {
$return_value = -1; $return_value = -1;
if (preg_match('/^[0-9]+GB$/', $value)) { if (preg_match('/^[0-9]+GB$/', $formatted_size)) {
$return_value = substr($value, 0, -2) * PMA_pow(1024, 3); $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 3);
} elseif (preg_match('/^[0-9]+MB$/', $value)) { } elseif (preg_match('/^[0-9]+MB$/', $formatted_size)) {
$return_value = substr($value, 0, -2) * PMA_pow(1024, 2); $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 2);
} elseif (preg_match('/^[0-9]+K$/', $value)) { } elseif (preg_match('/^[0-9]+K$/', $formatted_size)) {
$return_value = substr($value, 0, -1) * PMA_pow(1024, 1); $return_value = substr($formatted_size, 0, -1) * PMA_pow(1024, 1);
} }
return $return_value; return $return_value;
}// end of the 'PMA_getBytes' function }// end of the 'PMA_extractValueFromFormattedSize' function
/** /**
* Writes localised date * Writes localised date

View File

@@ -86,12 +86,16 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
* returns the pbxt engine specific handling for * returns the pbxt engine specific handling for
* PMA_ENGINE_DETAILS_TYPE_SIZE variables. * PMA_ENGINE_DETAILS_TYPE_SIZE variables.
* *
* @param string $formatted_size the size expression (for example 8MB)
*
* @return string the formatted value and its unit * @return string the formatted value and its unit
*/ */
function resolveTypeSize($value) function resolveTypeSize($formatted_size)
{ {
if (preg_match('/^[0-9]+[a-zA-Z]+$/', $value)){ if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)){
$value = PMA_getBytes($value); $value = PMA_extractValueFromFormattedSize($formatted_size);
} else {
$value = $formatted_size;
} }
return PMA_formatByteDown($value); return PMA_formatByteDown($value);
} }