HTML_TreeMenu
[ class tree: HTML_TreeMenu ] [ index: HTML_TreeMenu ] [ all elements ]

Source for file example.php

Documentation is available at example.php

  1. <?php
  2. // +-----------------------------------------------------------------------+
  3. // | Copyright (c) 2002-2005, Richard Heyes, Harald Radi                   |
  4. // | All rights reserved.                                                  |
  5. // |                                                                       |
  6. // | Redistribution and use in source and binary forms, with or without    |
  7. // | modification, are permitted provided that the following conditions    |
  8. // | are met:                                                              |
  9. // |                                                                       |
  10. // | o Redistributions of source code must retain the above copyright      |
  11. // |   notice, this list of conditions and the following disclaimer.       |
  12. // | o Redistributions in binary form must reproduce the above copyright   |
  13. // |   notice, this list of conditions and the following disclaimer in the |
  14. // |   documentation and/or other materials provided with the distribution.| 
  15. // | o The names of the authors may not be used to endorse or promote      |
  16. // |   products derived from this software without specific prior written  |
  17. // |   permission.                                                         |
  18. // |                                                                       |
  19. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  20. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  21. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  22. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  23. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  24. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  25. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  26. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  27. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  28. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  29. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  30. // |                                                                       |
  31. // +-----------------------------------------------------------------------+
  32. // | Author: Richard Heyes <http://www.phpguru.org/>                       |
  33. // |         Harald Radi <harald.radi@nme.at>                              |
  34. // +-----------------------------------------------------------------------+
  35. //
  36. // $Id: example.php 181173 2005-03-02 02:16:51Z richard $
  37. //error_reporting(E_ALL | E_STRICT);
  38.     //require_once('HTML/TreeMenu.php');
  39.     require_once('../TreeMenu.php');
  40.  
  41.     $icon         'folder.gif';
  42.     $expandedIcon 'folder-expanded.gif';
  43.  
  44.     $menu  = new HTML_TreeMenu();
  45.  
  46.     $node1   = new HTML_TreeNode(array('text' => "First level"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon'expanded' => true)array('onclick' => "alert('foo'); return false"'onexpand' => "alert('Expanded')"));
  47.     $node1_1 &$node1->addItem(new HTML_TreeNode(array('text' => "Second level"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon)));
  48.     $node1_1_1 &$node1_1->addItem(new HTML_TreeNode(array('text' => "Third level"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon)));
  49.     $node1_1_1_1 &$node1_1_1->addItem(new HTML_TreeNode(array('text' => "Fourth level"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon)));
  50.     $node1_1_1_1->addItem(new HTML_TreeNode(array('text' => "Fifth level"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon'cssClass' => 'treeMenuBold')));
  51.  
  52.     $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 2"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon)));
  53.     $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 3"'link' => "test.php"'icon' => $icon'expandedIcon' => $expandedIcon)));
  54.  
  55.     $menu->addItem($node1);
  56.     $menu->addItem($node1);
  57.     
  58.     // Create the presentation class
  59.     $treeMenu &new HTML_TreeMenu_DHTML($menuarray('images' => '../images''defaultClass' => 'treeMenuDefault'));
  60.     $listBox  &new HTML_TreeMenu_Listbox($menuarray('linkTarget' => '_self'));
  61.     //$treeMenuStatic = &new HTML_TreeMenu_staticHTML($menu, array('images' => '../images', 'defaultClass' => 'treeMenuDefault', 'noTopLevelImages' => true));
  62. ?>
  63. <html>
  64. <head>
  65.     <style type="text/css">
  66.         body {
  67.             font-family: Georgia;
  68.             font-size: 11pt;
  69.         }
  70.         
  71.         .treeMenuDefault {
  72.             font-style: italic;
  73.         }
  74.         
  75.         .treeMenuBold {
  76.             font-style: italic;
  77.             font-weight: bold;
  78.         }
  79.     </style>
  80.     <script src="../TreeMenu.js" language="JavaScript" type="text/javascript"></script>
  81. </head>
  82. <body>
  83.  
  84. <script language="JavaScript" type="text/javascript">
  85. <!--
  86.     a = new Date();
  87.     a = a.getTime();
  88. //-->
  89. </script>
  90.  
  91. <?$treeMenu->printMenu()?><br /><br />
  92. <?$listBox->printMenu()?>
  93.  
  94. <script language="JavaScript" type="text/javascript">
  95. <!--
  96.     b = new Date();
  97.     b = b.getTime();
  98.     
  99.     document.write("Time to render tree: " + ((b - a) / 1000) + "s");
  100. //-->
  101. </script>
  102.  
  103.  
  104. </body>
  105. </html>

Documentation generated on Mon, 11 Mar 2019 15:40:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.