Added a hyperlinked bread crumb trail to top of every page.
authorjollytoad <jollytoad>
Thu, 15 Jul 2004 15:45:48 +0000 (15:45 +0000)
committerjollytoad <jollytoad>
Thu, 15 Jul 2004 15:45:48 +0000 (15:45 +0000)
Altered tabs styling to look nice with trail :)

classes/Misc.php
sqledit.php
themes/default/global.css

index 4474e74062112eec60ed325af2d995420046313c..b65eae6d7df88957d0bf13766b6bae1b10f70620 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.76 2004/07/15 09:55:00 jollytoad Exp $
+        * $Id: Misc.php,v 1.77 2004/07/15 15:45:48 jollytoad Exp $
         */
         
        class Misc {
                 * @param $activetab The name of the tab to be highlighted.
                 */
                function printTabs($tabs, $activetab) {
-                       global $misc;
+                       global $misc, $conf;
                        
-                       echo "<table class=\"navbar\" border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"3\"><tr>\n";
+                       echo "<table class=\"tabs\"><tr>\n";
                        
                        # FIXME: don't count hiden tags
                        $width = round(100 / count($tabs)).'%';
                        
                        foreach ($tabs as $tab_id => $tab) {
-                               $class = ($tab_id == $activetab) ? ' class="active"' : '';
+                               $active = ($tab_id == $activetab) ? ' active' : '';
                                
                                if (!isset($tab['hide']) || $tab['hide'] !== true)
-                                       echo "<td width=\"{$width}\"{$class}><a href=\"" . htmlspecialchars($tab['url']) . "\">{$tab['title']}</a></td>\n";
+                                       echo "<td width=\"{$width}\" class=\"tab{$active}\"><a href=\"" . $this->printVal($tab['url'], 'nbsp') . "\">{$tab['title']}</a></td>\n";
                        }
                        
                        echo "</tr></table>\n";
                                        return array();
                        }
                }
-               
+
                /**
                 * Display a navigation tab bar.
                 * @param $section The name of the tab bar.
                 * @param $activetab The tab to highlight and set as default for the bar.
+                * @param $trail A bread crumb trail, or true for default trail, false for no trail.
                 */
-               function printNav($section, $activetab) {
+               function printNav($section, $activetab, $trail = true) {
                        global $data;
                        
+                       echo "<div class=\"nav\">\n";
+                       
+                       if ($trail === true) {
+                               $this->printTrail($this->getTrail($section));
+                       }
+                       elseif (is_array($trail)) {
+                               $this->printTrail($trail);
+                       }
+                       
                        switch ($section) {
                                case 'database':
                                case 'schema':
                                                $_SESSION['webdbLastTab'][$section] = $activetab;
                                        }
                        }
+                       
+                       echo "</div>\n";
                }
-               
+
                /**
                 * Get the URL for the last active tab of a particular tab bar.
                 */
                        
                        return isset($tab['url']) ? $tab['url'] : null;
                }
-               
+
+               /**
+                * Display a bread crumb trail.
+                */
+               function printTrail($trail = array()) {
+                       global $lang;
+                       
+                       echo "<div class=\"trail\">";
+                       
+                       foreach ($trail as $crumb) {
+                               echo "<span class=\"crumb\"><a";
+                               
+                               if (isset($crumb['url']))
+                                       echo ' href="' . $this->printVal($crumb['url'], 'nbsp') . '"';
+                               
+                               if (isset($crumb['title']))
+                                       echo " title=\"{$crumb['title']}\"";
+                               
+                               echo ">" . htmlspecialchars($crumb['text']) . "</a></span>{$lang['strseparator']}";
+                       }
+                       
+                       echo "</div>\n";
+               }
+
+               /**
+                * Create a bread crumb trail of the object hierarchy.
+                * @param $object The type of object at the end of the trail.
+                */
+               function getTrail($object = null) {
+                       global $lang, $conf;
+                       
+                       $trail = array();
+                       $vars = '';
+                       $done = false;
+                       
+                       $trail['server'] = array(
+                               'title' => $lang['strserver'],
+                               'text'  => $conf['servers'][$_SESSION['webdbServerID']]['desc'],
+                               'url'   => 'redirect.php?section=server',
+                       );
+                       if ($object == 'server') $done = true;
+                       
+                       if (isset($_REQUEST['database']) && !$done) {
+                               $vars = 'database='.urlencode($_REQUEST['database']).'&';
+                               $trail['database'] = array(
+                                       'title' => $lang['strdatabase'],
+                                       'text'  => $_REQUEST['database'],
+                                       'url'   => "redirect.php?section=database&{$vars}",
+                               );
+                       }
+                       if ($object == 'database') $done = true;
+                       
+                       if (isset($_REQUEST['schema']) && !$done) {
+                               $vars .= 'schema='.urlencode($_REQUEST['schema']).'&';
+                               $trail['schema'] = array(
+                                       'title' => $lang['strschema'],
+                                       'text'  => $_REQUEST['schema'],
+                                       'url'   => "redirect.php?section=schema&{$vars}",
+                               );
+                       }
+                       if ($object == 'schema') $done = true;
+                       
+                       if (!$done) {
+                               switch ($object) {
+                                       case 'table':
+                                               $vars .= 'table='.urlencode($_REQUEST['table']);
+                                               $trail['table'] = array(
+                                                       'title' => $lang['strtable'],
+                                                       'text'  => $_REQUEST['table'],
+                                                       'url'   => "redirect.php?section=table&{$vars}",
+                                               );
+                                               break;
+                                       case 'view':
+                                               $vars .= 'view='.urlencode($_REQUEST['view']);
+                                               $trail['view'] = array(
+                                                       'title' => $lang['strview'],
+                                                       'text'  => $_REQUEST['view'],
+                                                       'url'   => "redirect.php?section=view&{$vars}",
+                                               );
+                                               break;
+                                       default:
+                                               if (isset($_REQUEST[$object])) {
+                                                       $trail['table'] = array(
+                                                               'text'  => $_REQUEST[$object],
+                                                       );
+                                               }
+                               }
+                       }
+                       
+                       return $trail;
+               }
+
                /**
                 * Do multi-page navigation.  Displays the prev, next and page options.
                 * @param $page the page currently viewed
index e40ea066506bca45f3635295605e15a95d5b38c2..e8e52fc6af09a23db426875b5d698b8f40bd8375 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.20 2004/07/15 10:06:24 soranzo Exp $
+        * $Id: sqledit.php,v 1.21 2004/07/15 15:45:48 jollytoad Exp $
         */
 
        // Include application functions
@@ -61,7 +61,7 @@
                if (!isset($_GET['term'])) $_GET['term'] = '';
                if (!isset($_GET['filter'])) $_GET['filter'] = '';
 
-               $misc->printNav('popup','find');
+               $misc->printNav('popup','find', false);
                echo "<h2>{$lang['strfind']}</h2>\n";
                
                echo "<form action=\"database.php\" method=\"get\" target=\"detail\">\n<p>";
 
                if (!isset($_REQUEST['query'])) $_REQUEST['query'] = '';
 
-               $misc->printNav('popup','sql');
+               $misc->printNav('popup','sql', false);
                echo "<h2>{$lang['strsql']}</h2>\n";
 
                echo "<form action=\"sql.php\" method=\"post\" target=\"detail\">\n<p>";
index 2d62370b79bfff424c3f2dc5c212140213d7391f..8e566b706f0f685dca02257967bdba387d89971e 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Default style sheet
  *
- * $Id: global.css,v 1.22 2004/07/14 10:01:33 jollytoad Exp $
+ * $Id: global.css,v 1.23 2004/07/15 15:45:48 jollytoad Exp $
  */
 
 /** ELEMENTS */
@@ -183,6 +183,34 @@ td.opbutton2
        text-align: center;
 }
 
+.trail, .tab
+{
+       border: 2px solid #E6E6CC;
+       background-color: #F3F3E9;
+       padding: 2px 1em;
+}
+
+.trail, .tabs
+{
+       margin-bottom: 2px;
+}
+
+.tabs
+{
+       width: 100%;
+       border-collapse: collapse;
+}
+
+.tab
+{
+       text-align: center;
+}
+
+.tabs .active
+{
+       background-color: #E6E6CC;
+}
+
 a,a:active 
 {
        color: #989973;
@@ -246,7 +274,7 @@ a.navlink:active, a.toplink:active
        text-decoration: none;
 }
 
-.navbar .active a
+.active a
 {
        font-weight: bold;
 }