00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 ?>