Skip to content

Commit

Permalink
Refactor to remove display_import.inc.php
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Delisle <[email protected]>
  • Loading branch information
Marc Delisle committed Aug 13, 2015
1 parent b7a2884 commit 75da81b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 70 deletions.
9 changes: 7 additions & 2 deletions db_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@
require 'libraries/db_common.inc.php';
require 'libraries/db_info.inc.php';

$import_type = 'database';
require 'libraries/display_import.inc.php';
require 'libraries/display_import.lib.php';
$response = PMA_Response::getInstance();
$response->addHTML(
PMA_getImportDisplay(
'database', $db, $table, $max_upload_size
)
);
64 changes: 0 additions & 64 deletions libraries/display_import.inc.php

This file was deleted.

59 changes: 59 additions & 0 deletions libraries/display_import.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,62 @@ function PMA_getHtmlForImportWithPlugin($upload_id)
return $html;
}

/**
* Gets HTML to display import dialogs
*
* @param String $import_type Import type: server|database|table
* @param String $db Selected DB
* @param String $table Selected Table
* @param int $max_upload_size Max upload size
*
* @return string $html
*/
function PMA_getImportDisplay($import_type, $db, $table, $max_upload_size)
{
global $SESSION_KEY;
require_once './libraries/file_listing.lib.php';
require_once './libraries/plugin_interface.lib.php';
// this one generates also some globals
require_once './libraries/display_import_ajax.lib.php';

/* Scan for plugins */
/* @var $import_list ImportPlugin[] */
$import_list = PMA_getPlugins(
"import",
'libraries/plugins/import/',
$import_type
);

/* Fail if we didn't find any plugin */
if (empty($import_list)) {
PMA_Message::error(
__(
'Could not load import plugins, please check your installation!'
)
)->display();
exit;
}

if (PMA_isValid($_REQUEST['offset'], 'numeric')) {
$offset = $_REQUEST['offset'];
}
if (isset($_REQUEST['timeout_passed'])) {
$timeout_passed = $_REQUEST['timeout_passed'];
}
if (isset($_REQUEST['local_import_file'])) {
$local_import_file = $_REQUEST['local_import_file'];
}

$timeout_passed_str = isset($timeout_passed)? $timeout_passed : null;
$offset_str = isset($offset)? $offset : null;
return PMA_getHtmlForImport(
$upload_id,
$import_type,
$db,
$table,
$max_upload_size,
$import_list,
$timeout_passed_str,
$offset_str
);
}
9 changes: 7 additions & 2 deletions server_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
*/
require 'libraries/server_common.inc.php';

$import_type = 'server';
require 'libraries/display_import.inc.php';
require 'libraries/display_import.lib.php';
$response = PMA_Response::getInstance();
$response->addHTML(
PMA_getImportDisplay(
'server', $db, $table, $max_upload_size
)
);
9 changes: 7 additions & 2 deletions tbl_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@

require_once 'libraries/tbl_info.inc.php';

$import_type = 'table';
require_once 'libraries/display_import.inc.php';
require 'libraries/display_import.lib.php';
$response = PMA_Response::getInstance();
$response->addHTML(
PMA_getImportDisplay(
'table', $db, $table, $max_upload_size
)
);

0 comments on commit 75da81b

Please sign in to comment.