Add docs.

This commit is contained in:
Michal Čihař
2010-04-29 14:10:11 +02:00
parent a5750bb3bf
commit e4a399fc6a
3 changed files with 27 additions and 12 deletions

View File

@@ -12,10 +12,15 @@ if (! defined('PHPMYADMIN')) {
$ID_KEY = 'APC_UPLOAD_PROGRESS'; $ID_KEY = 'APC_UPLOAD_PROGRESS';
/**
* Returns upload status.
*
* This is implementation for APC extension.
*/
function PMA_getUploadStatus($id) { function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id) == "") { if (trim($id) == "") {
return; return;
} }
@@ -30,7 +35,7 @@ function PMA_getUploadStatus($id) {
); );
} }
$ret = $_SESSION[$SESSION_KEY][$id]; $ret = $_SESSION[$SESSION_KEY][$id];
if (! PMA_import_apcCheck() || $ret['finished']) { if (! PMA_import_apcCheck() || $ret['finished']) {
return $ret; return $ret;
} }
@@ -40,7 +45,7 @@ function PMA_getUploadStatus($id) {
$ret['finished'] = (bool)$status['done']; $ret['finished'] = (bool)$status['done'];
$ret['total'] = $status['total']; $ret['total'] = $status['total'];
$ret['complete'] = $status['current']; $ret['complete'] = $status['current'];
if ($ret['total'] > 0) { if ($ret['total'] > 0) {
$ret['percent'] = $ret['complete'] / $ret['total'] * 100; $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
} }
@@ -51,7 +56,7 @@ function PMA_getUploadStatus($id) {
$_SESSION[$SESSION_KEY][$id] = $ret; $_SESSION[$SESSION_KEY][$id] = $ret;
} }
return $ret; return $ret;
} }

View File

@@ -12,10 +12,15 @@ if (! defined('PHPMYADMIN')) {
$ID_KEY = 'noplugin'; $ID_KEY = 'noplugin';
/**
* Returns upload status.
*
* This is implementation when no webserver support exists, so it returns just zeroes.
*/
function PMA_getUploadStatus($id) { function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id) == "") { if (trim($id) == "") {
return; return;
} }

View File

@@ -11,14 +11,19 @@ if (! defined('PHPMYADMIN')) {
$ID_KEY = "UPLOAD_IDENTIFIER"; $ID_KEY = "UPLOAD_IDENTIFIER";
/**
* Returns upload status.
*
* This is implementation for uploadprogress extension.
*/
function PMA_getUploadStatus($id) { function PMA_getUploadStatus($id) {
global $SESSION_KEY; global $SESSION_KEY;
global $ID_KEY; global $ID_KEY;
if (trim($id) == "") { if (trim($id) == "") {
return; return;
} }
if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) { if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
$_SESSION[$SESSION_KEY][$id] = array( $_SESSION[$SESSION_KEY][$id] = array(
'id' => $id, 'id' => $id,
@@ -30,11 +35,11 @@ function PMA_getUploadStatus($id) {
); );
} }
$ret = $_SESSION[$SESSION_KEY][$id]; $ret = $_SESSION[$SESSION_KEY][$id];
if (! PMA_import_uploadprogressCheck() || $ret['finished']) { if (! PMA_import_uploadprogressCheck() || $ret['finished']) {
return $ret; return $ret;
} }
$status = uploadprogress_get_info($id); $status = uploadprogress_get_info($id);
if ($status) { if ($status) {
@@ -45,7 +50,7 @@ function PMA_getUploadStatus($id) {
} }
$ret['total'] = $status['bytes_total']; $ret['total'] = $status['bytes_total'];
$ret['complete'] = $status['bytes_uploaded']; $ret['complete'] = $status['bytes_uploaded'];
if ($ret['total'] > 0) { if ($ret['total'] > 0) {
$ret['percent'] = $ret['complete'] / $ret['total'] * 100; $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
} }
@@ -59,9 +64,9 @@ function PMA_getUploadStatus($id) {
'plugin' => $ID_KEY 'plugin' => $ID_KEY
); );
} }
$_SESSION[$SESSION_KEY][$id] = $ret; $_SESSION[$SESSION_KEY][$id] = $ret;
return $ret; return $ret;
} }
?> ?>