TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-06-2008, 02:24 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default Step by step tree menu

Good day to you all,
Its been a will that I'm working on some different.
This code is used as a menu.

The following script :
- Reads recursively through a given directory.
- For each folder it count the number of files,.
- Add a "space" in front of the text for each level.

I need to make it also do :
- For each last level of each folder, change the image, in the way it display.
- Each folder collapse, expand.

I know how to :
- make table collapse and expand, see 2nd code. It need to be integrated in 1st code.
- How to make level identified by "space", see 1st code


PHP Code:

<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">

<?php

  
function CountDir($aDir$aRecurse)
  {
    
$Count 0;

    
$d dir($aDir);

    while (
$Entry $d->Read())
    {
      if (!((
$Entry == "..") || ($Entry == ".")))
      {
        if (
Is_Dir($aDir '/' $Entry))
        {
          if (
$aRecurse)
          {
            
$Count += CountDir($aDir '/' $Entry$aRecurse);
          }
        }
        else
        {
          
$Count++;
        }
      }
    }
    
    return 
$Count;
  }



function 
getDirectory$path '.'$level ){

$myFile "http://test.com/Sidebar_icon/icon_change.txt";
$fh fopen($myFile'r');
$outputt fgets($fh);
$output str_replace("../..""http://test.com/V_0-1"$outputt );
fclose($fh);


    
$ignore = array( 'cgi-bin''.''..' );
    
// Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.

    
$dh = @opendir$path );
    
// Open the directory to the handle $dh
    
    
while( false !== ( $file readdir$dh ) ) ){
    
// Loop through the directory
    
        
if( !in_array$file$ignore ) ){
        
// Check that this file is not to be ignored
            
            
$spaces str_repeat'&nbsp;', ( $level ) );
            
// Just to add spacing to the list, to better
            // show the directory tree.
            
            
$rest substr($file0, -4);

            if( 
is_dir"$path/$file) ){
            
// Its a directory, so we need to keep reading down...

echo '<tr><td align="left"><a href="http://test.com/V_0-1/Art/images22.php?folder='.$path.'/'.$file.'" align="left" class="white00" target="image">'.$spaces.'<img src="'.$output.'" border="0"> '.$file.'</a> - '.CountDir($path.'/'.$fileFalse).' </td></tr>';





                
getDirectory"$path/$file", ($level+1) );
                
// Re-call this same function but on a new directory.
                // this is what makes function recursive.
            
            
} else {
            


                
// Just print out the filename
            
            
}
        }
    }
    
closedir$dh );
    
// Close the directory handle
}

getDirectory"Pictures/Pics/Pic-S" );
// Get contents of the "files/includes" folder  

?>

</table>


Code two is from Dynamic Drive script
http://http://www.dynamicdrive.com/d...chcontent2.htm


Thanks !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 06-06-2008, 04:19 AM   #2 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default

Dynamic Drive DHTML scripts- Switch Content Script
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:57 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design