From: ioguix Date: Wed, 2 May 2007 16:12:06 +0000 (+0000) Subject: extending browser's tree under table's and view's node X-Git-Tag: REL_4-2-BETA-1~124 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=8e5e05d138b777442f7439fc841936855bbb49ad;p=phppgadmin.git extending browser's tree under table's and view's node --- diff --git a/classes/Misc.php b/classes/Misc.php index 308db30d..727aff28 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -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 { @@ -780,6 +780,7 @@ 'url' => 'tblproperties.php', 'urlvars' => array('subject' => 'table', 'table' => field('table')), 'icon' => 'Columns', + 'branch'=> true, ), 'indexes' => array ( 'title' => $lang['strindexes'], @@ -787,6 +788,7 @@ 'urlvars' => array('subject' => 'table', 'table' => field('table')), 'help' => 'pg.index', 'icon' => 'Indexes', + 'branch'=> true, ), 'constraints' => array ( 'title' => $lang['strconstraints'], @@ -794,6 +796,7 @@ 'urlvars' => array('subject' => 'table', 'table' => field('table')), 'help' => 'pg.constraint', 'icon' => 'Constraints', + 'branch'=> true, ), 'triggers' => array ( 'title' => $lang['strtriggers'], @@ -801,6 +804,7 @@ 'urlvars' => array('subject' => 'table', 'table' => field('table')), 'help' => 'pg.trigger', 'icon' => 'Triggers', + 'branch'=> true, ), 'rules' => array ( 'title' => $lang['strrules'], @@ -808,6 +812,7 @@ 'urlvars' => array('subject' => 'table', 'table' => field('table')), 'help' => 'pg.rule', 'icon' => 'Rules', + 'branch'=> true, ), 'info' => array ( 'title' => $lang['strinfo'], @@ -827,12 +832,14 @@ '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, ), ); @@ -843,6 +850,7 @@ 'url' => 'viewproperties.php', 'urlvars' => array('subject' => 'view', 'view' => field('view')), 'icon' => 'Columns', + 'branch'=> true, ), 'definition' => array ( 'title' => $lang['strdefinition'], @@ -856,6 +864,7 @@ 'urlvars' => array('subject' => 'view', 'view' => field('view')), 'help' => 'pg.rule', 'icon' => 'Rules', + 'branch'=> true, ), 'privileges' => array ( 'title' => $lang['strprivileges'], @@ -869,6 +878,7 @@ 'url' => 'viewproperties.php', 'urlvars' => array('subject' => 'view', 'view' => field('view'), 'action' => 'export'), 'icon' => 'Export', + 'hide' => true, ), ); diff --git a/constraints.php b/constraints.php index bf3e9ad6..5eb9ea71 100644 --- a/constraints.php +++ b/constraints.php @@ -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 @@ -488,6 +488,38 @@ "\">{$lang['straddfk']}

\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'], ""); diff --git a/indexes.php b/indexes.php index da3aa474..4de43c68 100644 --- a/indexes.php +++ b/indexes.php @@ -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 @@ -311,6 +311,32 @@ echo "

href}&table=", urlencode($_REQUEST['table']), "\">{$lang['strcreateindex']}

\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'], ""); if ($action == 'create_index' || $action == 'save_create_index') diff --git a/rules.php b/rules.php index 7d6abb3f..b0602de0 100644 --- 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 @@ -165,6 +165,24 @@ echo "

href}&{$subject}={$object}&subject={$subject}\">{$lang['strcreaterule']}

\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(); diff --git a/tables.php b/tables.php index b096c341..576e6176 100644 --- a/tables.php +++ b/tables.php @@ -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 @@ -909,10 +909,10 @@ $reqvars, array('table' => field('relname')) ), - 'branch' => url('tblproperties.php', + 'branch' => url('tables.php', $reqvars, array ( - 'action' => 'tree', + 'action' => 'subtree', 'table' => field('relname') ) ) @@ -922,7 +922,39 @@ 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(); diff --git a/triggers.php b/triggers.php index 47f3686b..e81bdfae 100644 --- a/triggers.php +++ b/triggers.php @@ -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 @@ -329,6 +329,25 @@ echo "

href}&table=", urlencode($_REQUEST['table']), "\">{$lang['strcreatetrigger']}

\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(); diff --git a/views.php b/views.php index 8ae4d521..39d6f32e 100644 --- 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 @@ -545,7 +545,7 @@ $misc->printMsg($msg); $views = $data->getViews(); - + $columns = array( 'view' => array( 'title' => $lang['strview'], @@ -615,29 +615,48 @@ $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();