extending browser's tree under table's and view's node
authorioguix <ioguix>
Wed, 2 May 2007 16:12:06 +0000 (16:12 +0000)
committerioguix <ioguix>
Wed, 2 May 2007 16:12:06 +0000 (16:12 +0000)
classes/Misc.php
constraints.php
indexes.php
rules.php
tables.php
triggers.php
views.php

index 308db30d027e2f02ef82f3befb6b145132853367..727aff28188a3189a68be0c8b666cb0e8c6a4beb 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.147 2007/04/24 15:31:29 soranzo Exp $
+        * $Id: Misc.php,v 1.148 2007/05/02 16:12:07 ioguix Exp $
         */
         
        class Misc {
                                                        'url'   => 'tblproperties.php',
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table')),
                                                        'icon'  => 'Columns',
+                                                       'branch'=> true,
                                                ),
                                                'indexes' => array (
                                                        'title' => $lang['strindexes'],
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table')),
                                                        'help'  => 'pg.index',
                                                        'icon'  => 'Indexes',
+                                                       'branch'=> true,
                                                ),
                                                'constraints' => array (
                                                        'title' => $lang['strconstraints'],
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table')),
                                                        'help'  => 'pg.constraint',
                                                        'icon'  => 'Constraints',
+                                                       'branch'=> true,
                                                ),
                                                'triggers' => array (
                                                        'title' => $lang['strtriggers'],
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table')),
                                                        'help'  => 'pg.trigger',
                                                        'icon'  => 'Triggers',
+                                                       'branch'=> true,
                                                ),
                                                'rules' => array (
                                                        'title' => $lang['strrules'],
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table')),
                                                        'help'  => 'pg.rule',
                                                        'icon'  => 'Rules',
+                                                       'branch'=> true,
                                                ),
                                                'info' => array (
                                                        'title' => $lang['strinfo'],
                                                        'url'   => 'tblproperties.php',
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table'), 'action' => 'import'),
                                                        'icon'  => 'Import',
+                                                       'hide'  => true,
                                                ),
                                                'export' => array (
                                                        'title' => $lang['strexport'],
                                                        'url'   => 'tblproperties.php',
                                                        'urlvars' => array('subject' => 'table', 'table' => field('table'), 'action' => 'export'),
                                                        'icon'  => 'Export',
+                                                       'hide'  => true,
                                                ),
                                        );
                                
                                                        'url'   => 'viewproperties.php',
                                                        'urlvars' => array('subject' => 'view', 'view' => field('view')),
                                                        'icon'  => 'Columns',
+                                                       'branch'=> true,
                                                ),
                                                'definition' => array (
                                                        'title' => $lang['strdefinition'],
                                                        'urlvars' => array('subject' => 'view', 'view' => field('view')),
                                                        'help'  => 'pg.rule',
                                                        'icon'  => 'Rules',
+                                                       'branch'=> true,
                                                ),
                                                'privileges' => array (
                                                        'title' => $lang['strprivileges'],
                                                        'url'   => 'viewproperties.php',
                                                        'urlvars' => array('subject' => 'view', 'view' => field('view'), 'action' => 'export'),
                                                        'icon'  => 'Export',
+                                                       'hide'  => true,
                                                ),
                                        );
                                
index bf3e9ad646964c37ea63bdb854e1c030c8ec94b8..5eb9ea7134a3254df069dec01ba93995b94c5e65 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List constraints on a table
         *
-        * $Id: constraints.php,v 1.45 2007/04/22 00:41:58 mr-russ Exp $
+        * $Id: constraints.php,v 1.46 2007/05/02 16:12:06 ioguix Exp $
         */
 
        // Include application functions
                        "\">{$lang['straddfk']}</a></p>\n";
        }
 
+       function doTree() {
+               global $misc, $data;
+
+               $constraints = $data->getConstraints($_REQUEST['table']);
+               
+               $reqvars = $misc->getRequestVars('schema');
+
+               function getIcon($f) {
+                       switch($f['contype']) {
+                               case 'u':
+                                       return 'UniqueConstraint';
+                               case 'c':
+                                       return 'CheckConstraint';
+                               case 'f':
+                                       return 'ForeignKey';
+                               case 'p':
+                                       return 'PrimaryKey';
+                               
+                       }
+               }
+       
+               $attrs = array(
+                       'text'   => field('conname'),
+                       'icon'   => callback('getIcon'),
+               );
+
+               $misc->printTreeXML($constraints, $attrs);
+               exit;
+       }
+
+       if ($action == 'tree') doTree();
+
        $misc->printHeader($lang['strtables'] . ' - ' . $_REQUEST['table'] . ' - ' . $lang['strconstraints'],
                "<script src=\"indexes.js\" type=\"text/javascript\"></script>");
 
index da3aa47400cbce8cc386527bffa2ef9c97c0265e..4de43c6800d4b48a83ac1288b7d05f0868d85c45 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List indexes on a table
         *
-        * $Id: indexes.php,v 1.39 2007/01/15 15:48:17 soranzo Exp $
+        * $Id: indexes.php,v 1.40 2007/05/02 16:12:07 ioguix Exp $
         */
 
        // Include application functions
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create_index&amp;{$misc->href}&amp;table=", urlencode($_REQUEST['table']), "\">{$lang['strcreateindex']}</a></p>\n";              
        }
 
+       function doTree() {
+               global $misc, $data;
+
+               $indexes = $data->getIndexes($_REQUEST['table']);
+
+               $reqvars = $misc->getRequestVars('table');
+
+               function getIcon($f) {
+                       if ($f['indisprimary'] == 't')
+                               return 'PrimaryKey';
+                       if ($f['indisunique'] == 't')
+                               return 'UniqueConstraint';
+                       return 'Index';
+               }
+
+               $attrs = array(
+                       'text'   => field('indname'),
+                       'icon'   => callback('getIcon'),
+               );
+
+               $misc->printTreeXML($indexes, $attrs);
+               exit;
+       }
+
+       if ($action == 'tree') doTree();
+
        $misc->printHeader($lang['strindexes'], "<script src=\"indexes.js\" type=\"text/javascript\"></script>");
 
        if ($action == 'create_index' || $action == 'save_create_index')
index 7d6abb3fb6bba6148082fee7493821495b87d4d7..b0602de044fe590417e591d5848db71f0cbc0966 100644 (file)
--- a/rules.php
+++ b/rules.php
@@ -3,7 +3,7 @@
        /**
         * List rules on a table OR view
         *
-        * $Id: rules.php,v 1.27 2006/06/17 23:50:19 xzilla Exp $
+        * $Id: rules.php,v 1.28 2007/05/02 16:12:07 ioguix Exp $
         */
 
        // Include application functions
                echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_rule&amp;{$misc->href}&amp;{$subject}={$object}&amp;subject={$subject}\">{$lang['strcreaterule']}</a></p>\n";
        }
 
+       function doTree() {
+               global $misc, $data;
+
+               $rules = $data->getRules($_REQUEST[$_REQUEST['subject']]);
+
+               $reqvars = $misc->getRequestVars($_REQUEST['subject']);
+
+               $attrs = array(
+                       'text'   => field('rulename'),
+                       'icon'   => 'Rule',
+               );
+
+               $misc->printTreeXML($rules, $attrs);
+               exit;
+       }
+
+       if ($action == 'tree') doTree();
+       
        // Different header if we're view rules or table rules
        $misc->printHeader($_REQUEST[$_REQUEST['subject']] . ' - ' . $lang['strrules']);
        $misc->printBody();
index b096c3415d5f74691cdd2a0d1da1cd2ccae2df69..576e61768d76fe77a7ce601112e0fe75f2d07fa8 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.93 2007/04/24 14:49:00 soranzo Exp $
+        * $Id: tables.php,v 1.94 2007/05/02 16:12:07 ioguix Exp $
         */
 
        // Include application functions
                                                        $reqvars,
                                                        array('table' => field('relname'))
                                                ),
-                       'branch' => url('tblproperties.php',
+                       'branch' => url('tables.php',
                                                        $reqvars,
                                                        array (
-                                                               'action' => 'tree',
+                                                               'action' => 'subtree',
                                                                'table' => field('relname')
                                                        )
                                                )       
                exit;
        }
        
+       function doSubTree() {
+               global $misc, $data;
+
+               $tabs = $misc->getNavTabs('table');
+               $items = $misc->adjustTabsForTree($tabs);
+               $reqvars = $misc->getRequestVars('table');
+
+               $attrs = array(
+                       'text'   => noEscape(field('title')),
+                       'icon'   => field('icon'),
+                       'action' => url(
+                               field('url'),
+                               $reqvars,
+                               array('table' => $_REQUEST['table'])
+                       ),
+                       'branch' => ifempty(
+                               field('branch'), '', url(
+                                       field('url'),
+                                       $reqvars,
+                                       array(
+                                               'action' => 'tree',
+                                               'table' => $_REQUEST['table']
+                                       )
+                               )
+                       ),
+               );
+
+               $misc->printTreeXML($items, $attrs);
+               exit;
+       }
+       
        if ($action == 'tree') doTree();
+       if ($action == 'subtree') dosubTree();
        
        $misc->printHeader($lang['strtables']);
        $misc->printBody();
index 47f3686bae086a8a33e00ba8ab7e47f55d2e5edd..e81bdfae16306ef454f20d5a1ccb256ad6003b48 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List triggers on a table
         *
-        * $Id: triggers.php,v 1.31 2007/01/15 15:48:17 soranzo Exp $
+        * $Id: triggers.php,v 1.32 2007/05/02 16:12:07 ioguix Exp $
         */
 
        // Include application functions
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create&amp;{$misc->href}&amp;table=", urlencode($_REQUEST['table']), "\">{$lang['strcreatetrigger']}</a></p>\n";
        }
 
+       function doTree() {
+
+               global $misc, $data;
+
+               $triggers = $data->getTriggers($_REQUEST['table']);
+
+               $reqvars = $misc->getRequestVars('table');
+               
+               $attrs = array(
+                       'text'   => field('tgname'),
+                       'icon'   => 'Trigger',
+               );
+
+               $misc->printTreeXML($triggers, $attrs);
+               exit;
+       }
+
+       if ($action == 'tree') doTree();
+
        $misc->printHeader($lang['strtables'] . ' - ' . $_REQUEST['table'] . ' - ' . $lang['strtriggers']);
        $misc->printBody();
 
index 8ae4d52196819e55b42f29b01b9d1614a7574df6..39d6f32eab8474b559be7ce6df7b78d94a71cf8f 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.67 2007/04/24 14:49:00 soranzo Exp $
+        * $Id: views.php,v 1.68 2007/05/02 16:12:07 ioguix Exp $
         */
 
        // Include application functions
                $misc->printMsg($msg);
                
                $views = $data->getViews();
-               
+       
                $columns = array(
                        'view' => array(
                                'title' => $lang['strview'],
                $attrs = array(
                        'text'   => field('relname'),
                        'icon'   => 'View',
-                       'iconAction' => url('display.php',
-                                                       $reqvars,
-                                                       array('view' => field('relname'))
-                                               ),
+                       'iconAction' => url('display.php', $reqvars, array('view' => field('relname'))),
                        'toolTip'=> field('relcomment'),
-                       'action' => url('redirect.php',
-                                                       $reqvars,
-                                                       array('view' => field('relname'))
-                                               ),
-                       'branch' => url('viewproperties.php',
-                                                       $reqvars,
-                                                       array (
-                                                               'action' => 'tree',
-                                                               'view' => field('relname')
-                                                       )
-                                               )
+                       'action' => url('redirect.php', $reqvars, array('view' => field('relname'))),
+                       'branch' => url('views.php', $reqvars,
+                               array (
+                                       'action' => 'subtree',
+                                       'view' => field('relname')
+                               )
+                       )
                );
                
                $misc->printTreeXML($views, $attrs);
                exit;
        }
        
+       function doSubTree() {
+               global $misc, $data;
+
+               $tabs = $misc->getNavTabs('view');
+               $items = $misc->adjustTabsForTree($tabs);
+               $reqvars = $misc->getRequestVars('view');
+
+               $attrs = array(
+                       'text'   => noEscape(field('title')),
+                       'icon'   => field('icon'),
+                       'action' => url(field('url'),   $reqvars, field('urlvars'),     array('view' => $_REQUEST['view'])),
+                       'branch' => ifempty( 
+                               field('branch'), '', url(field('url'), field('urlvars'), $reqvars,
+                                       array(
+                                               'action' => 'tree',
+                                               'view' => $_REQUEST['view']
+                                       )
+                               )
+                       ),
+               );
+
+               $misc->printTreeXML($items, $attrs);
+               exit;
+       }
+       
        if ($action == 'tree') doTree();
+       if ($action == 'subtree') dosubTree();
        
        $misc->printHeader($lang['strviews']);
        $misc->printBody();