Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / import / upload / UploadProgress.class.php
blob1a507763d2d8f71e45a00d1f8a666abe4861174c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides upload functionalities for the import plugins
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /* Get the transformations interface */
13 require_once 'libraries/plugins/UploadInterface.int.php';
15 /**
16 * Implementation for upload progress
18 * @package PhpMyAdmin
20 class UploadProgress implements UploadInterface
22 /**
23 * Gets the specific upload ID Key
25 * @return string ID Key
27 public static function getIdKey()
29 return 'UPLOAD_IDENTIFIER';
32 /**
33 * Returns upload status.
35 * This is implementation for upload progress
37 * @param string $id upload id
39 * @return array|null
41 public static function getUploadStatus($id)
43 global $SESSION_KEY;
45 if (trim($id) == "") {
46 return null;
49 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
50 $_SESSION[$SESSION_KEY][$id] = array(
51 'id' => $id,
52 'finished' => false,
53 'percent' => 0,
54 'total' => 0,
55 'complete' => 0,
56 'plugin' => UploadProgress::getIdKey()
59 $ret = $_SESSION[$SESSION_KEY][$id];
61 if (! PMA_import_progressCheck() || $ret['finished']) {
62 return $ret;
65 $status = uploadprogress_get_info($id);
67 if ($status) {
68 if ($status['bytes_uploaded'] == $status['bytes_total']) {
69 $ret['finished'] = true;
70 } else {
71 $ret['finished'] = false;
73 $ret['total'] = $status['bytes_total'];
74 $ret['complete'] = $status['bytes_uploaded'];
76 if ($ret['total'] > 0) {
77 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
79 } else {
80 $ret = array(
81 'id' => $id,
82 'finished' => true,
83 'percent' => 100,
84 'total' => $ret['total'],
85 'complete' => $ret['total'],
86 'plugin' => UploadProgress::getIdKey()
90 $_SESSION[$SESSION_KEY][$id] = $ret;
91 return $ret;