diff options
author | Robert Treat | 2008-08-26 03:02:15 +0000 |
---|---|---|
committer | Robert Treat | 2008-08-26 03:02:15 +0000 |
commit | cf4f4225d218cb0aa48e9b90eb783f79a81ae3c6 (patch) | |
tree | c931252c5b7611dc12f74c0cbd18dffa47276227 | |
parent | 28a749657ab3c92c6a59bf6171cc3e7b8b1c3c84 (diff) |
add export option at the schema level. refs feature request #2011744
-rw-r--r-- | classes/Misc.php | 8 | ||||
-rw-r--r-- | dbexport.php | 9 | ||||
-rw-r--r-- | libraries/lib.inc.php | 1 | ||||
-rwxr-xr-x | schemas.php | 60 |
4 files changed, 75 insertions, 3 deletions
diff --git a/classes/Misc.php b/classes/Misc.php index 6986345c..1f1b8fc1 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -782,6 +782,14 @@ 'tree' => false, 'icon' => 'Privileges', ), + 'export' => array ( + 'title' => $lang['strexport'], + 'url' => 'schemas.php', + 'urlvars' => array('subject' => 'schema', 'action' => 'export'), + 'hide' => (!$this->isDumpEnabled()), + 'tree' => false, + 'icon' => 'Export', + ), ); case 'table': diff --git a/dbexport.php b/dbexport.php index c4630bb2..f429404d 100644 --- a/dbexport.php +++ b/dbexport.php @@ -1,6 +1,6 @@ <?php /** - * Does an export of a database or a table (via pg_dump) + * Does an export of a database, schema, or table (via pg_dump) * to the screen or as a download. * * $Id: dbexport.php,v 1.22 2007/03/25 03:15:09 xzilla Exp $ @@ -61,9 +61,12 @@ // Build command for executing pg_dump. '-i' means ignore version differences. $cmd = $exe . " -i"; - // Check for a specified table/view switch ($_REQUEST['subject']) { + case 'schema': + // This currently works for 8.2+ (due to the orthoganl -t -n issue introduced then) + $cmd .= " -n " . $misc->escapeShellArg('"'. $_REQUEST['schema'] . '"'); + break; case 'table': case 'view': // Obtain the pg_dump version number @@ -118,7 +121,7 @@ if (!$dumpall) { putenv('PGDATABASE=' . $_REQUEST['database']); } - + // Execute command and return the output to the screen passthru($cmd); } diff --git a/libraries/lib.inc.php b/libraries/lib.inc.php index aa0825fc..88aa4088 100644 --- a/libraries/lib.inc.php +++ b/libraries/lib.inc.php @@ -11,6 +11,7 @@ // Set error reporting level to max error_reporting(E_ALL); + ini_set('display_errors',true); // Application name $appName = 'phpPgAdmin'; diff --git a/schemas.php b/schemas.php index 77d60635..2cda5625 100755 --- a/schemas.php +++ b/schemas.php @@ -284,6 +284,63 @@ } /** + * Displays options for database download + */ + function doExport($msg = '') { + global $data, $misc; + global $lang; + + $misc->printTrail('schema'); + $misc->printTabs('schema','export'); + $misc->printMsg($msg); + + echo "<form action=\"dbexport.php\" method=\"post\">\n"; + echo "<table>\n"; + echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n"; + // Data only + echo "<tr><th class=\"data left\" rowspan=\"2\">"; + echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$lang['strdataonly']}</label></th>\n"; + echo "<td>{$lang['strformat']}</td>\n"; + echo "<td><select name=\"d_format\">\n"; + echo "<option value=\"copy\">COPY</option>\n"; + echo "<option value=\"sql\">SQL</option>\n"; + echo "</select>\n</td>\n</tr>\n"; + echo "<tr><td><label for=\"d_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /></td>\n</tr>\n"; + // Structure only + echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$lang['strstructureonly']}</label></th>\n"; + echo "<td><label for=\"s_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /></td>\n</tr>\n"; + // Structure and data + echo "<tr><th class=\"data left\" rowspan=\"3\">"; + echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$lang['strstructureanddata']}</label></th>\n"; + echo "<td>{$lang['strformat']}</td>\n"; + echo "<td><select name=\"sd_format\">\n"; + echo "<option value=\"copy\">COPY</option>\n"; + echo "<option value=\"sql\">SQL</option>\n"; + echo "</select>\n</td>\n</tr>\n"; + echo "<tr><td><label for=\"sd_clean\">{$lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /></td>\n</tr>\n"; + echo "<tr><td><label for=\"sd_oids\">{$lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /></td>\n</tr>\n"; + echo "</table>\n"; + + echo "<h3>{$lang['stroptions']}</h3>\n"; + echo "<p><input type=\"radio\" id=\"output1\" name=\"output\" value=\"show\" checked=\"checked\" /><label for=\"output1\">{$lang['strshow']}</label>\n"; + echo "<br/><input type=\"radio\" id=\"output2\" name=\"output\" value=\"download\" /><label for=\"output2\">{$lang['strdownload']}</label>\n"; + // MSIE cannot download gzip in SSL mode - it's just broken + if (!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))) { + echo "<br /><input type=\"radio\" id=\"output3\" name=\"output\" value=\"gzipped\" /><label for=\"output3\">{$lang['strdownloadgzipped']}</label>\n"; + } + echo "</p>\n"; + echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n"; + echo "<input type=\"hidden\" name=\"subject\" value=\"schema\" />\n"; + echo "<input type=\"hidden\" name=\"database\" value=\"", htmlspecialchars($_REQUEST['database']), "\" />\n"; + echo "<input type=\"hidden\" name=\"schema\" value=\"", htmlspecialchars($_REQUEST['schema']), "\" />\n"; + echo $misc->form; + echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n"; + echo "</form>\n"; + } + + + + /** * Generate XML for the browser tree. */ function doTree() { @@ -366,6 +423,9 @@ if (isset($_POST['drop'])) doDrop(false); else doDrop(true); break; + case 'export': + doExport(); + break; default: doDefault(); break; |