From 05e4e16b8a70d5a9d1f21a659f19ee5f55bfba36 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 13 Apr 2010 08:51:07 -0400 Subject: [PATCH] Improve function and variables names --- libraries/common.lib.php | 20 ++++++++++---------- libraries/engines/pbxt.lib.php | 10 +++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e4a00d2da..f8dcc6029 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -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 * - * @param double $value the value that should be converted to bytes + * @param string $size the size expression (for example 8MB) * @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; - if (preg_match('/^[0-9]+GB$/', $value)) { - $return_value = substr($value, 0, -2) * PMA_pow(1024, 3); - } elseif (preg_match('/^[0-9]+MB$/', $value)) { - $return_value = substr($value, 0, -2) * PMA_pow(1024, 2); - } elseif (preg_match('/^[0-9]+K$/', $value)) { - $return_value = substr($value, 0, -1) * PMA_pow(1024, 1); + if (preg_match('/^[0-9]+GB$/', $formatted_size)) { + $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 3); + } elseif (preg_match('/^[0-9]+MB$/', $formatted_size)) { + $return_value = substr($formatted_size, 0, -2) * PMA_pow(1024, 2); + } elseif (preg_match('/^[0-9]+K$/', $formatted_size)) { + $return_value = substr($formatted_size, 0, -1) * PMA_pow(1024, 1); } return $return_value; -}// end of the 'PMA_getBytes' function +}// end of the 'PMA_extractValueFromFormattedSize' function /** * Writes localised date diff --git a/libraries/engines/pbxt.lib.php b/libraries/engines/pbxt.lib.php index db407134f..06425394c 100644 --- a/libraries/engines/pbxt.lib.php +++ b/libraries/engines/pbxt.lib.php @@ -86,12 +86,16 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine * returns the pbxt engine specific handling for * PMA_ENGINE_DETAILS_TYPE_SIZE variables. * + * @param string $formatted_size the size expression (for example 8MB) + * * @return string the formatted value and its unit */ - function resolveTypeSize($value) + function resolveTypeSize($formatted_size) { - if (preg_match('/^[0-9]+[a-zA-Z]+$/', $value)){ - $value = PMA_getBytes($value); + if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)){ + $value = PMA_extractValueFromFormattedSize($formatted_size); + } else { + $value = $formatted_size; } return PMA_formatByteDown($value); }