/**
* 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,
),
);
/**
* 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>");
/**
* 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&{$misc->href}&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')
/**
* 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&{$misc->href}&{$subject}={$object}&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();
/**
* 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();
/**
* 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&{$misc->href}&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();
/**
* 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();