[phpwebapp-commits] CVS: web_app/boxes/editMenus test_1.php,1.1.1.1,1.2 test.php,1.3,1.4 include_men
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2003-08-11 17:07:48
|
Update of /cvsroot/phpwebapp/web_app/boxes/editMenus In directory sc8-pr-cvs1:/tmp/cvs-serv29261/boxes/editMenus Modified Files: test_1.php test.php include_menus.js fun.editMenus.php editMenus.php class.XMLMenus.php class.Menus.php class.MenuTopElem.php class.MenuElem.php Log Message: * added some comments (that are handled by phpDocumentor) for dividing the code into packages and subpackages * replaced .gif images by .png images Index: test_1.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/test_1.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** test_1.php 21 Feb 2003 08:15:47 -0000 1.1.1.1 --- test_1.php 11 Aug 2003 16:17:52 -0000 1.2 *************** *** 1,7 **** <?php ! //include "../../../application.php"; define("EDITMENUS_PATH", ""); ! include EDITMENUS_PATH."class.Menus.php"; ! include "class.XMLMenus.php"; $xmlMenus = new XMLMenus("sample_menu/sample_Menus.xml"); --- 1,13 ---- <?php ! /** ! * @package boxes ! * @subpackage editMenus ! */ ! ! /** */ ! //include "../../../webapp.php"; define("EDITMENUS_PATH", ""); ! include_once EDITMENUS_PATH."class.Menus.php"; ! include_once "class.XMLMenus.php"; $xmlMenus = new XMLMenus("sample_menu/sample_Menus.xml"); Index: test.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/test.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test.php 16 Jul 2003 12:05:23 -0000 1.3 --- test.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,4 **** <?php ! //include "../../../application.php"; define("EDITMENUS_PATH", ""); include EDITMENUS_PATH."class.Menus.php"; --- 1,10 ---- <?php ! /** ! * @package boxes ! * @subpackage editMenus ! */ ! ! /** */ ! //include "../../../webapp.php"; define("EDITMENUS_PATH", ""); include EDITMENUS_PATH."class.Menus.php"; Index: include_menus.js =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/include_menus.js,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** include_menus.js 16 Jul 2003 09:28:00 -0000 1.2 --- include_menus.js 11 Aug 2003 16:17:53 -0000 1.3 *************** *** 45,49 **** itemPad = 3; ! imgSrc = "{{./}}tri.gif"; imgSiz = 8; --- 45,49 ---- itemPad = 3; ! imgSrc = "{{./}}tri.png"; imgSiz = 8; Index: fun.editMenus.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/fun.editMenus.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fun.editMenus.php 16 Jul 2003 12:05:23 -0000 1.3 --- fun.editMenus.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,3 **** --- 1,9 ---- <?php + /** + * @package boxes + * @subpackage editMenus + */ + + /** */ function editMenus_rewriteFiles() { Index: editMenus.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/editMenus.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** editMenus.php 16 Jul 2003 12:05:23 -0000 1.3 --- editMenus.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,3 **** --- 1,7 ---- <?php + /** + * @package boxes + * @subpackage editMenus + */ class editMenus extends WebObject { Index: class.XMLMenus.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/class.XMLMenus.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** class.XMLMenus.php 16 Jul 2003 09:28:00 -0000 1.2 --- class.XMLMenus.php 11 Aug 2003 16:17:53 -0000 1.3 *************** *** 1,4 **** <?php ! class XMLMenus { --- 1,7 ---- <?php ! /** ! * @package boxes ! * @subpackage editMenus ! */ class XMLMenus { Index: class.Menus.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/class.Menus.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** class.Menus.php 16 Jul 2003 12:05:23 -0000 1.3 --- class.Menus.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,9 **** <?php ! include EDITMENUS_PATH."class.MenuElem.php"; ! include EDITMENUS_PATH."class.MenuTopElem.php"; ! ///////////////////////////////////////////////////// ! // Class Menu represents all the menus of a page. ! // class Menus extends MenuElem { --- 1,12 ---- <?php ! include_once EDITMENUS_PATH."class.MenuElem.php"; ! include_once EDITMENUS_PATH."class.MenuTopElem.php"; ! /** ! * Class Menu represents all the menus of a page. ! * ! * @package boxes ! * @subpackage editMenus ! */ class Menus extends MenuElem { Index: class.MenuTopElem.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/class.MenuTopElem.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** class.MenuTopElem.php 16 Jul 2003 12:05:23 -0000 1.3 --- class.MenuTopElem.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,7 **** <?php ! ! ///////////////////////////////////////////////////// ! // Class MenuTopElem represents a top element of a menu. ! // class MenuTopElem extends MenuElem { --- 1,9 ---- <?php ! /** ! * Class MenuTopElem represents a top element of a menu. ! * ! * @package boxes ! * @subpackage editMenus ! */ class MenuTopElem extends MenuElem { Index: class.MenuElem.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/class.MenuElem.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** class.MenuElem.php 16 Jul 2003 12:05:23 -0000 1.3 --- class.MenuElem.php 11 Aug 2003 16:17:53 -0000 1.4 *************** *** 1,223 **** <?php ! if ( !defined("class_MenuElem") ) ! //test so that it is not included multiple times { ! define("class_MenuElem", 1); ! ///////////////////////////////////////////////////// ! // Class MenuElem represents an element of a menu. ! // ! class MenuElem { ! var $id; //identifies this menu element ! var $description; //text that will be shown in the menu ! var $action; //what will be done when this element is selected (typically a JS function call) ! var $parent; //parent of this element in the hierarchy of the menu ! var $children; //array of subelements ! ! function MenuElem($id =UNDEFINED, $descr ="menu element", $act ="") ! { ! $this->id = $id ; ! $this->description = $descr; ! $this->action = $act; ! $this->children = array(); ! } ! /** builds a menu element from a DOMXML node */ ! function build_from_dom($elem) ! { ! //get the attributes ! $this->id = $elem->getattr("id"); ! $this->description = $elem->getattr("description"); ! $this->action = $elem->getattr("action"); ! if ($this->description=="") $this->description = $this->id; ! if ($this->action=="") $this->action = $this->id; ! //add the child elements ! $children = $elem->children(); ! while ( list($i,$child) = each($children) ) { ! if ($child->name=="MenuElem") ! { ! $sub_elem = new MenuElem; ! $sub_elem->build_from_dom($child); ! $this->addChild($sub_elem); ! } } } ! function addChild(&$ch) ! { ! $this->children[] = $ch; ! $ch->parent = &$this; ! } ! function nrChildren() ! { ! return sizeof($this->children); ! } ! function hasChildren() ! { ! $nr_ch = $this->nrChildren(); ! return ($nr_ch <> 0); ! } ! /** ! * set the ids of the children (if unset) ! * used by the function that loads the menu from an xml file ! */ ! function set_children_id() { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = &$this->children[$i]; ! if ($child->id==UNDEFINED) ! { ! $child->id = $this->id . "_" . ($i+1); ! } ! $child->set_children_id(); } } ! /** returns an id for a new child */ ! function new_child_id() { ! $max_id = $this->id."_0"; ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $id = $this->children[$i]->id; ! if ($id > $max_id) $max_id = $id; ! } ! $max_id++; ! return $max_id; } ! /** sets the action that is used when the menu is being edited */ ! function setEditAction() { ! $id = $this->id; ! $descr = $this->description; ! $action = $this->action; ! $this->action = "edit(\\\"$id\\\", \\\"$descr\\\", \\\"$action\\\")"; ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $child = &$this->children[$i]; ! $child->setEditAction(); ! } } ! function change($id, $change_func) { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = &$this->children[$i]; ! if ($child->id==$id) ! { ! $change_func($this, $child); ! return true; ! } ! $changed = $child->change($id, $change_func); ! if ($changed) return true; } ! ! return false; } ! /////////// output functions ///////////// ! /** returns the menu element as an xml string indented by $indent */ ! function to_xml($indent) ! { ! $xml_menu = $indent.'<MenuElem id="'.$this->id."\"\n" ! . "\t\t".$indent.'description="'.$this->description."\"\n" ! . "\t\t".$indent.'action="'.$this->action."\">\n"; ! $xml_menu .= $this->children_to_xml("\t".$indent); ! $xml_menu .= $indent."</MenuElem>\n"; ! return $xml_menu; ! } ! /** returns the children as an xml string indented by $indent */ ! function children_to_xml($indent) { ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $child = $this->children[$i]; ! $xml_menu .= $child->to_xml($indent); ! } ! return $xml_menu; } ! /** ! * returns the element and all its subelements ! * in an easily readable text format ! */ ! function to_text($ident) //debug { ! $txt_menu = $ident."> ".$this->id." -> ".$this->description." -> ".$this->action."\n"; ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $child = $this->children[$i]; ! $txt_menu .= $child->to_text("\t".$ident); ! } ! return $txt_menu; } ! /** ! * prints the element and all its subelements ! * in an easily readable text format ! */ ! function print_text($ident) //debug { ! print $ident."> ".$this->id." -> ".$this->description." -> ".$this->action."\n"; ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $child = $this->children[$i]; ! print $child->print_text("\t".$ident); ! } } ! /** ! * returns the branch starting with this element ! * in the JavaScript format required by hierMenus ! */ ! function to_arrMenus($menu_name) ! { ! if ( !$this->hasChildren() ) return ""; ! $js_menu = $menu_name." = new Array(\n"; ! $nrCh = $this->nrChildren(); ! for ($i=0; $i < $nrCh-1; $i++) ! { ! $ch = $this->children[$i]; ! $js_menu .= "\t\"" . $ch->description . "\", \"" . $ch->action."\", " ! . ($ch->hasChildren() ? "1" : "0") . ",\n"; ! } ! //last child $ch = $this->children[$i]; $js_menu .= "\t\"" . $ch->description . "\", \"" . $ch->action."\", " ! . ($ch->hasChildren() ? "1" : "0") . "\n"; //without a comma ! $js_menu .= ");\n\n"; ! $js_menu .= $this->children_to_arrMenus($menu_name."_"); ! ! return $js_menu; } ! /** ! * transforms all the children to JavaScript code ! * and returns it as a string, used by to_arrMenus() etc. ! */ ! function children_to_arrMenus($menu_name) { ! for ($i=0; $i < $this->nrChildren(); $i++) ! { ! $ch = &$this->children[$i]; ! $ch_menu_name = $menu_name . ($i + 1); ! $js_menu .= $ch->to_arrMenus($ch_menu_name); ! } ! return $js_menu; } } ! ! } //end if !defined ?> --- 1,219 ---- <?php ! /** ! * Class MenuElem represents an element of a menu. ! * ! * @package boxes ! * @subpackage editMenus ! */ ! class MenuElem { ! var $id; //identifies this menu element ! var $description; //text that will be shown in the menu ! var $action; //what will be done when this element is selected (typically a JS function call) ! var $parent; //parent of this element in the hierarchy of the menu ! var $children; //array of subelements ! function MenuElem($id =UNDEFINED, $descr ="menu element", $act ="") { ! $this->id = $id ; ! $this->description = $descr; ! $this->action = $act; ! $this->children = array(); ! } ! /** builds a menu element from a DOMXML node */ ! function build_from_dom($elem) ! { ! //get the attributes ! $this->id = $elem->getattr("id"); ! $this->description = $elem->getattr("description"); ! $this->action = $elem->getattr("action"); ! if ($this->description=="") $this->description = $this->id; ! if ($this->action=="") $this->action = $this->id; ! //add the child elements ! $children = $elem->children(); ! while ( list($i,$child) = each($children) ) ! { ! if ($child->name=="MenuElem") { ! $sub_elem = new MenuElem; ! $sub_elem->build_from_dom($child); ! $this->addChild($sub_elem); } } + } ! function addChild(&$ch) ! { ! $this->children[] = $ch; ! $ch->parent = &$this; ! } ! function nrChildren() ! { ! return sizeof($this->children); ! } ! function hasChildren() ! { ! $nr_ch = $this->nrChildren(); ! return ($nr_ch <> 0); ! } ! /** ! * set the ids of the children (if unset) ! * used by the function that loads the menu from an xml file ! */ ! function set_children_id() ! { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = &$this->children[$i]; ! if ($child->id==UNDEFINED) { ! $child->id = $this->id . "_" . ($i+1); } + $child->set_children_id(); } + } ! /** returns an id for a new child */ ! function new_child_id() ! { ! $max_id = $this->id."_0"; ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $id = $this->children[$i]->id; ! if ($id > $max_id) $max_id = $id; } + $max_id++; + return $max_id; + } ! /** sets the action that is used when the menu is being edited */ ! function setEditAction() ! { ! $id = $this->id; ! $descr = $this->description; ! $action = $this->action; ! $this->action = "edit(\\\"$id\\\", \\\"$descr\\\", \\\"$action\\\")"; ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = &$this->children[$i]; ! $child->setEditAction(); } + } ! function change($id, $change_func) ! { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = &$this->children[$i]; ! if ($child->id==$id) { ! $change_func($this, $child); ! return true; } ! $changed = $child->change($id, $change_func); ! if ($changed) return true; } + + return false; + } ! /////////// output functions ///////////// ! /** returns the menu element as an xml string indented by $indent */ ! function to_xml($indent) ! { ! $xml_menu = $indent.'<MenuElem id="'.$this->id."\"\n" ! . "\t\t".$indent.'description="'.$this->description."\"\n" ! . "\t\t".$indent.'action="'.$this->action."\">\n"; ! $xml_menu .= $this->children_to_xml("\t".$indent); ! $xml_menu .= $indent."</MenuElem>\n"; ! return $xml_menu; ! } ! /** returns the children as an xml string indented by $indent */ ! function children_to_xml($indent) ! { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = $this->children[$i]; ! $xml_menu .= $child->to_xml($indent); } + return $xml_menu; + } ! /** ! * returns the element and all its subelements ! * in an easily readable text format ! */ ! function to_text($ident) //debug ! { ! $txt_menu = $ident."> ".$this->id." -> ".$this->description." -> ".$this->action."\n"; ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = $this->children[$i]; ! $txt_menu .= $child->to_text("\t".$ident); } + return $txt_menu; + } ! /** ! * prints the element and all its subelements ! * in an easily readable text format ! */ ! function print_text($ident) //debug ! { ! print $ident."> ".$this->id." -> ".$this->description." -> ".$this->action."\n"; ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $child = $this->children[$i]; ! print $child->print_text("\t".$ident); } + } ! /** ! * returns the branch starting with this element ! * in the JavaScript format required by hierMenus ! */ ! function to_arrMenus($menu_name) ! { ! if ( !$this->hasChildren() ) return ""; ! $js_menu = $menu_name." = new Array(\n"; ! $nrCh = $this->nrChildren(); ! for ($i=0; $i < $nrCh-1; $i++) ! { $ch = $this->children[$i]; $js_menu .= "\t\"" . $ch->description . "\", \"" . $ch->action."\", " ! . ($ch->hasChildren() ? "1" : "0") . ",\n"; } + //last child + $ch = $this->children[$i]; + $js_menu .= "\t\"" . $ch->description . "\", \"" . $ch->action."\", " + . ($ch->hasChildren() ? "1" : "0") . "\n"; //without a comma + $js_menu .= ");\n\n"; + $js_menu .= $this->children_to_arrMenus($menu_name."_"); ! return $js_menu; ! } ! ! /** ! * transforms all the children to JavaScript code ! * and returns it as a string, used by to_arrMenus() etc. ! */ ! function children_to_arrMenus($menu_name) ! { ! for ($i=0; $i < $this->nrChildren(); $i++) { ! $ch = &$this->children[$i]; ! $ch_menu_name = $menu_name . ($i + 1); ! $js_menu .= $ch->to_arrMenus($ch_menu_name); } + return $js_menu; } ! } ?> |