Directory listing help
Posted: Wed Jan 22, 2003 10:22 am
I am creating a javascript menu on my page that lists only the directories under the current directory, and their contents. I have the following code:
<script>
// Decide if the names are links or just the icons
USETEXTLINKS = 1 //replace 0 with 1 for hyperlinks
// Decide if the tree is to start all open or just showing the root folders
STARTALLOPEN = 0 //replace 0 with 1 to show the whole tree
// Decide if the tree is to to be shown on a separate frame of its own
USEFRAMES = 0
// Remove the folder and link icons and keep only the +/- icons
USEICONS = 1
// where do the icons live?
ICONPATH = /ra-apps/documentation/vorfa/js/'
// Make the folder and link labels wrap into multiple lines
WRAPTEXT = 0
// Folders reopen toprevious state across page loads
PERSERVESTATE = 1
foldersTree = gFld("<b>Doctor Deliverable</b>", "<?php echo "$PHP_SELF"; ?>")
<?php
$root_directory="/ra-apps/documentation/vorfa/Deliverables/Doctor Deliverable";
$directory_command = "find ./";
$output=array();
exec($directory_command,$output);
$files=array();
$d_s=array();
$last_d="";
$first_time_thru=true;
foreach($output as $line) {
$file=basename($line);
$directory=dirname($line);
if ($directory != $last_d) {
// if this is the first time thru, turn flag off,
// else we need to add the previously generated
// arrays to our master list
if (!$first_time_thru) {
array_push($d_s,
array($last_d => $files));
$files=array();
}
}
array_push($files, $file);
$last_d=$directory;
$first_time_thru=false;
}
ksort($d_s);
foreach($d_s as $line) {
$directory=key($line);
$files=$line[$directory];
$_link_dir=urlencode($directory);
?>
level1 = insFld(foldersTree, gFld("<?php echo $directory; ?>", ""))
<?php
foreach($files as $file) {
?>
insDoc(level1, gLnk("R", "<?php echo $file;?>", "<?php echo "$directory/$file"; ?>"))
<?php
}
}
?>
</script>
But this isn't giving me exactly what I want. For example, I have the following directory structure:
Doctor Deliverable/
CVS/
Doctor Search, View/
Architecture/
CVS/
Use Cases/
Visual Design/
index.php
I am using javascript to construct my menu, and what I want is when you view the page, the Doctor Deliverable menu is open, and it displays the Doctor Search, View directory. You then click that and it shows the Architecture, Use Cases and Visual Design directores. I don't want to show the CVS directories if possible. Can someone help?
<script>
// Decide if the names are links or just the icons
USETEXTLINKS = 1 //replace 0 with 1 for hyperlinks
// Decide if the tree is to start all open or just showing the root folders
STARTALLOPEN = 0 //replace 0 with 1 to show the whole tree
// Decide if the tree is to to be shown on a separate frame of its own
USEFRAMES = 0
// Remove the folder and link icons and keep only the +/- icons
USEICONS = 1
// where do the icons live?
ICONPATH = /ra-apps/documentation/vorfa/js/'
// Make the folder and link labels wrap into multiple lines
WRAPTEXT = 0
// Folders reopen toprevious state across page loads
PERSERVESTATE = 1
foldersTree = gFld("<b>Doctor Deliverable</b>", "<?php echo "$PHP_SELF"; ?>")
<?php
$root_directory="/ra-apps/documentation/vorfa/Deliverables/Doctor Deliverable";
$directory_command = "find ./";
$output=array();
exec($directory_command,$output);
$files=array();
$d_s=array();
$last_d="";
$first_time_thru=true;
foreach($output as $line) {
$file=basename($line);
$directory=dirname($line);
if ($directory != $last_d) {
// if this is the first time thru, turn flag off,
// else we need to add the previously generated
// arrays to our master list
if (!$first_time_thru) {
array_push($d_s,
array($last_d => $files));
$files=array();
}
}
array_push($files, $file);
$last_d=$directory;
$first_time_thru=false;
}
ksort($d_s);
foreach($d_s as $line) {
$directory=key($line);
$files=$line[$directory];
$_link_dir=urlencode($directory);
?>
level1 = insFld(foldersTree, gFld("<?php echo $directory; ?>", ""))
<?php
foreach($files as $file) {
?>
insDoc(level1, gLnk("R", "<?php echo $file;?>", "<?php echo "$directory/$file"; ?>"))
<?php
}
}
?>
</script>
But this isn't giving me exactly what I want. For example, I have the following directory structure:
Doctor Deliverable/
CVS/
Doctor Search, View/
Architecture/
CVS/
Use Cases/
Visual Design/
index.php
I am using javascript to construct my menu, and what I want is when you view the page, the Doctor Deliverable menu is open, and it displays the Doctor Search, View directory. You then click that and it shows the Architecture, Use Cases and Visual Design directores. I don't want to show the CVS directories if possible. Can someone help?