/lib/pear/HTML/docs/example.php

https://bitbucket.org/valmy/openx · PHP · 105 lines · 50 code · 14 blank · 41 comment · 0 complexity · 567517e0d66310184dad9c68ef32e22c MD5 · raw file

  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$
  37. //error_reporting(E_ALL | E_STRICT);
  38. //require_once('HTML/TreeMenu.php');
  39. require_once('../TreeMenu.php');
  40. $icon = 'folder.gif';
  41. $expandedIcon = 'folder-expanded.gif';
  42. $menu = new HTML_TreeMenu();
  43. $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')"));
  44. $node1_1 = &$node1->addItem(new HTML_TreeNode(array('text' => "Second level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  45. $node1_1_1 = &$node1_1->addItem(new HTML_TreeNode(array('text' => "Third level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  46. $node1_1_1_1 = &$node1_1_1->addItem(new HTML_TreeNode(array('text' => "Fourth level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  47. $node1_1_1_1->addItem(new HTML_TreeNode(array('text' => "Fifth level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'cssClass' => 'treeMenuBold')));
  48. $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 2", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  49. $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 3", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  50. $menu->addItem($node1);
  51. $menu->addItem($node1);
  52. // Create the presentation class
  53. $treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => '../images', 'defaultClass' => 'treeMenuDefault'));
  54. $listBox = &new HTML_TreeMenu_Listbox($menu, array('linkTarget' => '_self'));
  55. //$treeMenuStatic = &new HTML_TreeMenu_staticHTML($menu, array('images' => '../images', 'defaultClass' => 'treeMenuDefault', 'noTopLevelImages' => true));
  56. ?>
  57. <html>
  58. <head>
  59. <style type="text/css">
  60. body {
  61. font-family: Georgia;
  62. font-size: 11pt;
  63. }
  64. .treeMenuDefault {
  65. font-style: italic;
  66. }
  67. .treeMenuBold {
  68. font-style: italic;
  69. font-weight: bold;
  70. }
  71. </style>
  72. <script src="../TreeMenu.js" language="JavaScript" type="text/javascript"></script>
  73. </head>
  74. <body>
  75. <script language="JavaScript" type="text/javascript">
  76. <!--
  77. a = new Date();
  78. a = a.getTime();
  79. //-->
  80. </script>
  81. <?$treeMenu->printMenu()?><br /><br />
  82. <?$listBox->printMenu()?>
  83. <script language="JavaScript" type="text/javascript">
  84. <!--
  85. b = new Date();
  86. b = b.getTime();
  87. document.write("Time to render tree: " + ((b - a) / 1000) + "s");
  88. //-->
  89. </script>
  90. </body>
  91. </html>