- 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)
+
 
 * 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
 
         * 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
        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,
 
--- /dev/null
+/**
+ * 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;
+}
+
 
        /**
         * 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
                        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();
                        }
 
        /**
         * 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
        
        $misc->printHeader();
        $misc->printBody('topbar');
+       $dbselected = isset($_REQUEST['database']) ? '&seldatabase=' . $_REQUEST['database'] : '';
 ?>
 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="topbar">
        <tr>
 <?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>