Location: PHPKode > scripts > Accessible nested DHTML menus > accessible-nested-dhtml-menus/example2.php
<?php
/*
File system browser - an example of how to use the menu.  
Just change the path appropriately.  This example just lists files in the directory
but it should be obvious how it could be extended to a full-featured file
management tool.

Author: Mick Sear
eCreate, July 2005
License: LGPL - This means you can use it in your apps (commercial as well as 
non-commercial, but this message must be kept intact, source code must be provided to 
clients, and changes to the code must be marked as by yourselves.
*/

error_reporting("E_ALL");

include("MenuNode.php"); //The class holding menu structure
include("FSMenu.php"); //The class that creates a menu by recursing through a file system
include("mcs_templater_class.php"); //This is my own basic templating - just uses a hash of placeholder names and content.


//Start directory for the menu
$startDir = "/home/ecreate/public_html/webcanvas/htmlarea";

$fs = new FSMenu($startDir);
$out['menu'] = $fs->display();
$out['javascript'] = $fs->getJavascript();

//...and that's it.  The menu will be displayed.  
//The javascript goes in the head of the page, so I guess this class is best suited for templated pages.


//Show the files in the selected directory.
$dir = addslashes($_GET['dir']);
$dir = $startDir.$dir;
$out['content'] .= "<h3>Showing dir: ".$dir."</h3>";

$d = opendir($dir);
while (false !== ($entry = readdir($d))) {
   $out['content'] .= $entry."<br />";
}


//Uncomment to see the internal menu array structure
/*$out['debug'] = "<pre>";
$out['debug'] .= print_r($fs->menu->elements);
$out['debug'] .= "</pre>";*/  


//Initialise template and replace placeholders with content.
$template = new ms_template("template.htm", $out, "<!--::", "::-->");
$template->parse_template();
$template->display();
?>
Return current item: Accessible nested DHTML menus