Added ability to printTreeXML to suppress header/footer of the XML doc, so that it...
authorjollytoad <jollytoad>
Mon, 16 May 2005 14:30:14 +0000 (14:30 +0000)
committerjollytoad <jollytoad>
Mon, 16 May 2005 14:30:14 +0000 (14:30 +0000)
classes/Misc.php

index 1cd892f76023a4ec7b0a7d6a6f0c565462ded079..6bafe1368a450574fd0154616b8663c9ed2c9b27 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.100 2005/05/02 15:47:25 chriskl Exp $
+        * $Id: Misc.php,v 1.101 2005/05/16 14:30:14 jollytoad Exp $
         */
         
        class Misc {
                 *        '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 icon($icon) {