From 22ddb6cee20fcf45e84e73e6c779e62d18fe72d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 27 Sep 2005 18:57:58 +0000 Subject: [PATCH] Sort file list on import tab, prepare generic framework to be used elsewhere (RFE #1303145). --- ChangeLog | 3 ++ libraries/display_import.lib.php | 39 +++++++++--------------- libraries/file_listing.php | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 25 deletions(-) create mode 100644 libraries/file_listing.php diff --git a/ChangeLog b/ChangeLog index 2bdcf1f43..2ffffcb2a 100755 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,9 @@ $Source$ * lang/*: Add missing messages, remove duplicates and no longer used. * libraries/sql_query_form.lib.php: Do not use strOr, drop file upload from normal SQL dialogs. + * libraries/display_import.lib.php, libraries/file_listing.php: Sort file + list on import tab, prepare generic framework to be used elsewhere (RFE + #1303145). 2005-09-26 Sebastian Mendel * libraries/database_interface.lib.php: fixed bug in PMA_DBI_fetch_*() diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php index f3ac4be1a..80c2c7108 100644 --- a/libraries/display_import.lib.php +++ b/libraries/display_import.lib.php @@ -2,6 +2,8 @@ /* $Id$ */ // vim: expandtab sw=4 ts=4 sts=4: +require_once('./libraries/file_listing.php'); + /* Scan for plugins */ $import_list = array(); $plugins_dir = './libraries/import/'; @@ -156,35 +158,22 @@ if (!empty($cfg['UploadDir'])) { if (!empty($compressions)) $compressions .= '|'; $compressions .= 'zip'; } - if ($handle = @opendir($cfg['UploadDir'])) { - $is_first = 0; - while ($file = @readdir($handle)) { - if (is_file($cfg['UploadDir'] . $file) && eregi('\.(' . $extensions . ')(\.(' .$compressions . '))?$', $file)) { - if ($is_first == 0) { - $is_upload_dir = true; - echo "
\n"; - echo ' ' . $strOr . '
 : ' . "\n"; - echo ' ' . "\n"; - } // end if (isfirst > 0) - @closedir($handle); - } else { + $matcher = '@\.(' . $extensions . ')(\.(' .$compressions . '))?$@'; + + $files = PMA_getFileSelectOptions($cfg['UploadDir'], $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : ''); + + if ($files === FALSE) { echo '
' . "\n"; echo ' ' . $strError . '
' . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n"; echo '
' . "\n"; + } elseif (!empty($files)) { + echo "
\n"; + echo ' ' . $strOr . '
 : ' . "\n"; + echo ' ' . "\n"; } } // end if (web-server upload directory) diff --git a/libraries/file_listing.php b/libraries/file_listing.php new file mode 100644 index 000000000..40e96d8b7 --- /dev/null +++ b/libraries/file_listing.php @@ -0,0 +1,52 @@ + $val) { + $result .= '