class.DBMenu.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 
00029 class DBMenu
00030 {
00031   var $root;             //root element of the menu
00032 
00033   function DBMenu()
00034     {
00035       $this->root = new MenuRoot;
00036       $goc = new MenuItem('goc', 'GOC DB', "select_goc()");
00037       $this->add_rocs(&$goc);
00038       $this->root->add_child(&$goc);
00039     }
00040 
00041   function add_rocs($goc)
00042     {
00043       $rs = WebApp::execQuery('SELECT ROC_id FROM ROCs');
00044       while (!$rs->EOF())
00045         {
00046           $id = $rs->Field('ROC_id');
00047 
00048           $roc = new MenuItem($id, $id, "select_roc(\'$id\')");
00049           $this->add_countries(&$roc);
00050           $goc->add_child(&$roc);
00051 
00052           $rs->MoveNext();
00053         }
00054     }
00055 
00056   function add_countries($roc)
00057     {
00058       $roc_id = $roc->id;
00059       $query = "SELECT country_id, name FROM countries WHERE ROC_id='$roc_id'";
00060       $rs = WebApp::execQuery($query);
00061 
00062       while (!$rs->EOF())
00063         {
00064           $id = $rs->Field('country_id');
00065           $name = $rs->Field('name');
00066 
00067           $country = new MenuItem($id, $name, "select_country(\'$id\')");
00068           $this->add_sites(&$country);
00069           $roc->add_child(&$country);
00070 
00071           $rs->MoveNext();
00072         }
00073     }
00074 
00075   function add_sites($country)
00076     {
00077       $c_id = $country->id;
00078       $query = "SELECT site_id FROM sites WHERE country_id='$c_id'";
00079       $rs = WebApp::execQuery($query);
00080 
00081       while (!$rs->EOF())
00082         {
00083           $id = $rs->Field('site_id');
00084 
00085           $site = new MenuItem($id, $id, "select_site(\'$id\')");
00086           $country->add_child(&$site);
00087 
00088           $rs->MoveNext();
00089         }
00090     }
00091 }
00092 ?>

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