Updated printTreeXML inline with HEAD branch.
authorjollytoad <jollytoad>
Fri, 20 May 2005 10:14:12 +0000 (10:14 +0000)
committerjollytoad <jollytoad>
Fri, 20 May 2005 10:14:12 +0000 (10:14 +0000)
Fixed doTree().

classes/Misc.php
database.php

index 7fac66d3af5e178ea08d0050932956ed2f8d7879..e627a5b12b165c4d1bcae4a72eecf90974a3f02d 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * 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) {
index 1251f3ff140520df9ecee9ea18791c51fe17de61..466cda9f8db587e115c161c57840d8ad930872c4 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * 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');