/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.100.2.1 2005/05/11 15:48:03 chriskl Exp $
+ * $Id: Misc.php,v 1.100.2.2 2005/05/20 10:14:12 jollytoad Exp $
*/
class Misc {
'urlvars' => array('subject' => 'database'),
'hide' => (!$data->hasSchemas()),
'help' => 'pg.schema',
+ 'tree' => false,
),
'sql' => array (
'title' => $lang['strsql'],
'url' => 'database.php',
'urlvars' => array('subject' => 'database', 'action' => 'sql'),
'help' => 'pg.sql',
+ 'tree' => false,
),
'find' => array (
'title' => $lang['strfind'],
'url' => 'database.php',
'urlvars' => array('subject' => 'database', 'action' => 'find'),
+ 'tree' => false,
),
'variables' => array (
'title' => $lang['strvariables'],
'urlvars' => array('subject' => 'database', 'action' => 'variables'),
'hide' => (!$data->hasVariables()),
'help' => 'pg.variable',
+ 'tree' => false,
),
'processes' => array (
'title' => $lang['strprocesses'],
'urlvars' => array('subject' => 'database', 'action' => 'processes'),
'hide' => (!$data->hasProcesses()),
'help' => 'pg.process',
+ 'tree' => false,
),
'admin' => array (
'title' => $lang['stradmin'],
'url' => 'database.php',
'urlvars' => array('subject' => 'database', 'action' => 'admin'),
+ 'tree' => false,
),
'privileges' => array (
'title' => $lang['strprivileges'],
'urlvars' => array('subject' => 'database'),
'hide' => (!isset($data->privlist['database'])),
'help' => 'pg.privilege',
+ 'tree' => false,
),
'languages' => array (
'title' => $lang['strlanguages'],
'url' => 'database.php',
'urlvars' => array('subject' => 'database', 'action' => 'export'),
'hide' => (!$this->isDumpEnabled()),
+ 'tree' => false,
),
);
// Add plugin tabs
'urlvars' => array('subject' => 'schema'),
'hide' => (!$data->hasSchemas()),
'help' => 'pg.privilege',
+ 'tree' => false,
),
);
* 'branch' - URL for child nodes (tree XML)
* 'expand' - the action to return XML for the subtree
* 'nodata' - message to display when node has no children
+ * 'nohead' - suppress headers and opening <tree> tag
+ * 'nofoot' - suppress closing </tree> tag
*/
function printTreeXML(&$treedata, &$attrs) {
global $conf, $lang;
- header("Content-Type: text/xml");
- header("Cache-Control: no-cache");
- echo "<?xml version=\"1.0\"?>\n";
-
- echo "<tree>\n";
+ if (!isset($attrs['nohead']) || $attrs['nohead'] === false) {
+ header("Content-Type: text/xml");
+ header("Cache-Control: no-cache");
+
+ echo "<?xml version=\"1.0\"?>\n";
+
+ echo "<tree>\n";
+ }
if ($treedata->recordCount() > 0) {
while (!$treedata->EOF) {
echo "<tree text=\"{$msg}\" onaction=\"this.parentNode.reload()\" icon=\"", $this->icon('error'), "\"/>\n";
}
- echo "</tree>\n";
+ if (!isset($attrs['nofoot']) || $attrs['nofoot'] === false) {
+ echo "</tree>\n";
+ }
+ }
+
+ function &adjustTabsForTree(&$tabs) {
+ include_once('classes/ArrayRecordSet.php');
+
+ foreach ($tabs as $i => $tab) {
+ if ((isset($tab['hide']) && $tab['hide'] === true) || (isset($tab['tree']) && $tab['tree'] === false)) {
+ unset($tabs[$i]);
+ }
+ }
+ return new ArrayRecordSet($tabs);
}
function icon($icon) {
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.66.2.2 2005/05/19 15:35:49 chriskl Exp $
+ * $Id: database.php,v 1.66.2.3 2005/05/20 10:14:12 jollytoad Exp $
*/
// Include application functions
}
function doTree() {
- global $misc, $data, $lang, $PHP_SELF;
+ global $misc, $data, $lang, $PHP_SELF, $slony;
$schemas = &$data->getSchemas();
),
'nofoot' => true
);
-
+
$misc->printTreeXML($schemas, $attrs);
- $tabs = array();
+ $tabs = $misc->getNavTabs('database');
$tabs['slony'] = array (
'title' => 'Slony',
'url' => 'plugin_slony.php',
'hide' => (!$slony->isEnabled()),
'help' => ''
);
-
- $items =& new ArrayRecordSet($tabs);
-
+
+ $items =& $misc->adjustTabsForTree($tabs);
+
$attrs = array(
'text' => noEscape(field('title')),
'icon' => field('icon', 'folder'),
function doSubTree() {
global $misc, $data, $lang, $slony;
- include_once('classes/ArrayRecordSet.php');
$tabs = $misc->getNavTabs('schema');
- // Remove Privileges link
- unset($tabs['privileges']);
-
- // Remove hidden links
- foreach ($tabs as $i => $tab) {
- if (isset($tab['hide']) && $tab['hide'] === true)
- unset($tabs[$i]);
- }
-
$tabs['slony'] = array (
'title' => 'Slony',
'url' => 'plugin_slony.php',
'hide' => (!$slony->isEnabled()),
'help' => ''
);
-
-
- $items =& new ArrayRecordSet($tabs);
+
+ $items =& $misc->adjustTabsForTree($tabs);
$reqvars = $misc->getRequestVars('schema');