class.MenuRoot.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003 This file  is part  of HGSM.   HGSM is a  web application  for keeping
00004 information about a hierarchical structure (in this case a grid).
00005 
00006 Copyright 2005, 2006 Dashamir Hoxha, dashohoxha@users.sourceforge.net
00007 
00008 HGSM is free software; you  can redistribute it and/or modify it under
00009 the terms of  the GNU General Public License as  published by the Free
00010 Software  Foundation; either  version 2  of the  License, or  (at your
00011 option) any later version.
00012 
00013 HGSM is  distributed in the hope  that it will be  useful, but WITHOUT
00014 ANY WARRANTY; without even  the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
00016 for more details.
00017 
00018 You  should have received  a copy  of the  GNU General  Public License
00019 along with HGSM; if not,  write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 */
00022 
00023 include_once dirname(__FILE__)."/class.MenuItem.php";
00024 
00028 class MenuRoot extends MenuItem
00029 {
00030   function MenuRoot($id ="MenuRoot")
00031     {
00032       MenuItem::MenuItem($id, 'MenuRoot', 'null');
00033     }
00034 
00036   function write_xml($fname)
00037     {
00038       write_file($fname, $this->to_xml());
00039     }
00040 
00042   function write_js($fname)
00043     {
00044       write_file($fname, $this->to_js());
00045     }
00046         
00048   function to_xml()
00049     {
00050       $xml_menu = "<?xml version='1.0'?>
00051 <!DOCTYPE menu SYSTEM 'menu.dtd'>
00052 
00053 <menu id='$this->id'>
00054 ";
00055       $xml_menu .= $this->children_to_xml("  ");
00056       $xml_menu .= "</menu>";
00057       return $xml_menu;
00058     }
00059 
00063   function to_js()
00064     {
00065       $js_arr = "// -*-C-*- \n\n"; 
00066       $js_arr .= "var MENU_ITEMS =\n[\n"; 
00067 
00068       for ($i=0; $i < $this->nr_children(); $i++)
00069         {
00070           $child = $this->children[$i];
00071           $indent = '  ';
00072           $js_arr .= $child->to_js_arr($indent);
00073         }
00074       $js_arr .= " ];\n";
00075       return $js_arr;
00076     }
00077 }
00078 ?>

Generated on Fri Jan 20 10:34:52 2006 for HGSM by  doxygen 1.4.5