update from bryan encina that makes the pop-up SQL and Find feature default to the...
authorchriskl <chriskl>
Mon, 15 Dec 2003 07:59:22 +0000 (07:59 +0000)
committerchriskl <chriskl>
Mon, 15 Dec 2003 07:59:22 +0000 (07:59 +0000)
CREDITS
HISTORY
browser.php
links.js [new file with mode: 0644]
sqledit.php
topbar.php

diff --git a/CREDITS b/CREDITS
index fe96d3eb25296989ecf00dec3065046ac3dd8e81..ed4dcdf837c407c29167dc89e0400989051e78ea 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -42,3 +42,5 @@ Contributors
 - Mark Gibson (Pop-up SQL window)
 - Nicola Soranzo
 - Oliver Meyer & Sven Kiera (Table icons link to browse table)
+- Bryan Encina (SQL window improvements, bug fixes)
+
diff --git a/HISTORY b/HISTORY
index ea818a7c515e080daed0762d60780675778962c2..5b38724bb110197faf2381eac1cedca5b50a8eb0 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -8,6 +8,7 @@ Features
 * Database dump feature, which uses pg_dump
 * Large speed improvements by reducing number of database
   connections and using external style sheet.
+* SQL pop-up window now defaults to the current database
 
 Bugs
 * Object browser fixed for databases with no schemas
index ee3ab85ed7103f6c90629b8300fcb2e74000921f..fbf60e60bfcc12abae8fd7a3d412850d130c0d26 100644 (file)
@@ -5,7 +5,7 @@
         * if you click on a database it shows a list of database objects in that
         * database.
         *
-        * $Id: browser.php,v 1.29 2003/12/10 16:03:29 chriskl Exp $
+        * $Id: browser.php,v 1.30 2003/12/15 07:59:22 chriskl Exp $
         */
 
        // Include application functions
@@ -15,7 +15,7 @@
        include_once('classes/HTML_TreeMenu/TreeMenu.php');
 
        // Output header
-       $misc->printHeader('', "<script src=\"classes/HTML_TreeMenu/TreeMenu.js\" type=\"text/javascript\"></script>");
+       $misc->printHeader('', "<script src=\"classes/HTML_TreeMenu/TreeMenu.js\" type=\"text/javascript\"></script>\n<script src=\"links.js\" type=\"text/javascript\"></script>");
        $misc->printBody('browser');
        
        // Construct expanding tree
        while (!$databases->EOF) {
                // If database is selected, show folder, otherwise show document
                if (isset($_REQUEST['database']) && $_REQUEST['database'] == $databases->f[$data->dbFields['dbname']]) {
+                       // Very ugly hack to work around the fact that the PEAR HTML_Tree can't have links with embedded
+                       // apostrophes create the get string we need to append
+                       $jsLink = '?database=' . addslashes(htmlspecialchars(urlencode($databases->f[$data->dbFields['dbname']]) . '&' . SID));
+                       $jsLink = "javascript:updateLinks(' + \"'{$jsLink}'\" + ')";
                        $db_node = &new HTML_TreeNode(array(
                                                                'text' => addslashes($misc->printVal($databases->f[$data->dbFields['dbname']])), 
-                                                               'link' => addslashes(htmlspecialchars('database.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]) . '&' . SID)), 
+                                                               'link' => $jsLink,
                                                                'icon' => "../../../images/themes/{$conf['theme']}/database.png", 
                                                                'expandedIcon' => "../../../images/themes/{$conf['theme']}/database.png",
                                                                'expanded' => true,
                        $root->addItem($db_node);
 
                } else {
+                       // Very ugly hack to work around the fact that the PEAR HTML_Tree can't have links with embedded
+                       // apostrophes create the get string we need to append
+                       $jsLink = '?database=' . addslashes(htmlspecialchars(urlencode($databases->f[$data->dbFields['dbname']]) . '&' . SID));
+                       $jsLink = "javascript:updateLinks(' + \"'{$jsLink}'\" + ')";
                        $db_node = &new HTML_TreeNode(array(
                                                                'text' => addslashes($misc->printVal($databases->f[$data->dbFields['dbname']])), 
-                                                               'link' => addslashes(htmlspecialchars("{$_SERVER['PHP_SELF']}?database=" . urlencode($databases->f[$data->dbFields['dbname']]) . '&' . SID)), 
+                                                               'link' => $jsLink,
                                                                'icon' => "../../../images/themes/{$conf['theme']}/database.png", 
                                                                'expandedIcon' => "../../../images/themes/{$conf['theme']}/database.png",
                                                                'expanded' => false,
diff --git a/links.js b/links.js
new file mode 100644 (file)
index 0000000..cc7c353
--- /dev/null
+++ b/links.js
@@ -0,0 +1,14 @@
+/**
+ * Function for updating browser frame and topbar frame so that sqledit window 
+ * pops up with properly selected database.
+ *
+ * $Id: links.js,v 1.1 2003/12/15 07:59:22 chriskl Exp $
+ */
+function updateLinks(getVars) {
+       var topbarLink = 'topbar.php' + getVars
+       var browserLink = 'browser.php' + getVars
+               
+       parent.frames.topbar.location = topbarLink;
+       parent.frames.browser.location = browserLink;
+}
+
index 18af9871b46b7063d028ad4849b33fee80d32f98..f87b9cede8fcb28a49014e18c4446103c8b568be 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.8 2003/12/10 16:03:29 chriskl Exp $
+        * $Id: sqledit.php,v 1.9 2003/12/15 07:59:22 chriskl Exp $
         */
 
        // Include application functions
@@ -27,7 +27,7 @@
                        while (!$databases->EOF) {
                                $dbname = $databases->f[$data->dbFields['dbname']];
                                echo "<option value=\"", htmlspecialchars($dbname), "\"",
-                               (isset($_REQUEST['database']) && $dbname == $_REQUEST['database']) ? ' selected="selected"' : '', ">",
+                               ((isset($_REQUEST['database']) && $dbname == $_REQUEST['database']) || (isset($_REQUEST['seldatabase']) && $dbname == $_REQUEST['seldatabase'])) ? ' selected="selected"' : '', ">",
                                        htmlspecialchars($dbname), "</option>\n";
                                $databases->moveNext();
                        }
index 4510790701883989eb257fe8df6e8fd41320e344..eb91844edadab4634b116a87aad6622031450295 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Top menu for phpPgAdmin
         *
-        * $Id: topbar.php,v 1.18 2003/09/17 09:03:15 chriskl Exp $
+        * $Id: topbar.php,v 1.19 2003/12/15 07:59:22 chriskl Exp $
         */
 
        // Include application functions
@@ -11,6 +11,7 @@
        
        $misc->printHeader();
        $misc->printBody('topbar');
+       $dbselected = isset($_REQUEST['database']) ? '&seldatabase=' . $_REQUEST['database'] : '';
 ?>
 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="topbar">
        <tr>
@@ -38,8 +39,8 @@
 <?php if ($conf['show_reports']) : ?>
                        <a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
 <?php endif; ?>
-                       <a class="toplink" href="sqledit.php" target="sqledit" onclick="window.open('sqledit.php?action=sql&<?php echo SID ?>','sqledit','toolbar=no,width=600,height=400,resizable=yes,scrollbars=no').focus(); return false;"><?php echo $lang['strsql'] ?></a> |
-                       <a class="toplink" href="sqledit.php" target="sqledit" onclick="window.open('sqledit.php?action=find&<?php echo SID ?>','sqledit','toolbar=no,width=600,height=400,resizable=yes,scrollbars=no').focus(); return false;"><?php echo $lang['strfind'] ?></a> |
+                       <a class="toplink" href="sqledit.php" target="sqledit" onclick="window.open('sqledit.php?action=sql<?php echo $dbselected ?>&<?php echo SID ?>','sqledit','toolbar=no,width=600,height=400,resizable=yes,scrollbars=no').focus(); return false;"><?php echo $lang['strsql'] ?></a> |
+                       <a class="toplink" href="sqledit.php" target="sqledit" onclick="window.open('sqledit.php?action=find<?php echo $dbselected ?>&<?php echo SID ?>','sqledit','toolbar=no,width=600,height=400,resizable=yes,scrollbars=no').focus(); return false;"><?php echo $lang['strfind'] ?></a> |                  
                        <a class="toplink" href="logout.php" target="_parent"><?php echo $lang['strlogout'] ?></a>
                </td>
        </tr>