Move code to a function

Signed-off-by: Marc Delisle <marc@infomarc.info>
This commit is contained in:
Marc Delisle 2015-12-08 12:15:33 -05:00
parent 76b572d4bb
commit c7ec8d7240
3 changed files with 54 additions and 34 deletions

View File

@ -52,6 +52,11 @@ define('PMA_MINIMUM_COMMON', 1);
require_once 'libraries/common.inc.php';
require_once 'libraries/display_import_ajax.lib.php';
list(
$SESSION_KEY,
$upload_id,
$plugins
) = PMA_uploadProgressSetup();
/*
if (defined('SESSIONUPLOAD')) {

View File

@ -642,8 +642,13 @@ function PMA_getImportDisplay($import_type, $db, $table, $max_upload_size)
global $SESSION_KEY;
include_once './libraries/file_listing.lib.php';
include_once './libraries/plugin_interface.lib.php';
// this one generates also some globals
include_once './libraries/display_import_ajax.lib.php';
list(
$SESSION_KEY,
$upload_id,
$plugins
) = PMA_uploadProgressSetup();
/* Scan for plugins */
/* @var $import_list ImportPlugin[] */

View File

@ -10,45 +10,55 @@ if (! defined('PHPMYADMIN')) {
}
/**
* constant for differentiating array in $_SESSION variable
*/
$SESSION_KEY = '__upload_status';
* Sets up some variables for upload progress
*
* @return array()
*
*/
function PMA_uploadProgressSetup()
{
/**
* constant for differentiating array in $_SESSION variable
*/
$SESSION_KEY = '__upload_status';
/**
* sets default plugin for handling the import process
*/
$_SESSION[$SESSION_KEY]["handler"] = "";
/**
* sets default plugin for handling the import process
*/
$_SESSION[$SESSION_KEY]["handler"] = "";
/**
* unique ID for each upload
*/
$upload_id = uniqid("");
/**
* unique ID for each upload
*/
$upload_id = uniqid("");
/**
* list of available plugins
*
* Each plugin has own checkfunction in display_import_ajax.lib.php
* and own file with functions in upload_#KEY#.php
*/
$plugins = array(
// PHP 5.4 session-based upload progress is problematic, see bug 3964
//"session",
"progress",
"apc",
"noplugin"
);
/**
* list of available plugins
*
* Each plugin has own checkfunction in display_import_ajax.lib.php
* and own file with functions in upload_#KEY#.php
*/
$plugins = array(
// PHP 5.4 session-based upload progress is problematic, see bug 3964
//"session",
"progress",
"apc",
"noplugin"
);
// select available plugin
foreach ($plugins as $plugin) {
$check = "PMA_Import_" . $plugin . "Check";
// select available plugin
foreach ($plugins as $plugin) {
$check = "PMA_Import_" . $plugin . "Check";
if ($check()) {
$upload_class = 'PMA\libraries\plugins\import\upload\Upload' . ucwords(
$plugin
);
$_SESSION[$SESSION_KEY]["handler"] = $upload_class;
break;
if ($check()) {
$upload_class = 'PMA\libraries\plugins\import\upload\Upload' . ucwords(
$plugin
);
$_SESSION[$SESSION_KEY]["handler"] = $upload_class;
break;
}
}
return array($SESSION_KEY, $upload_id, $plugins);
}
/**