Solved

URGENT, DIR to proper UL (unordered list) tree-like output

Posted on 2006-07-06
21
485 Views
Last Modified: 2007-12-19
The function (part of my big class)

//======================================================================================================
//                                                                  Directory 2 Listbox (array)
//                                                                              WWW.VISION.TO
//======================================================================================================
function VISION_TO_DIR2LISTBOX($DIR_Name=".",$allowed = ".php",$filter="_events.php|wp|class|functions",$filter_dir=1, $show_filesize=0)
{

      if($filter_dir == 0)
      {
      $filter_dir="class|includes|editor|fpdf|plugin|temp|sorter|template|images|extra|feeds|3rd|functions|files|wp|wysiwygpro|layout|styles|css|js|fonts";
    }
    $DIR = @dir($DIR_Name);
    while($this->entry = $DIR->read())
    {
    if ($this->entry != "." && $this->entry != "..")
    {
    if (eregi($allowed,$this->entry) && !eregi($filter,$this->entry) )
    {
    $this->option_value =$DIR_Name."/".$this->entry;
      if($show_filesize == 1)
      {
    $this->option =$DIR_Name."/".$this->entry." [".$this->VISION_TO_GET_FSIZE($DIR_Name."/".$this->entry)."]";
      }
      else
      {
    $this->option =$DIR_Name."/".$this->entry;      
      }
    $this->dynbox []= array($this->option_value, $this->option);
    }
    if (is_dir($DIR_Name."/".$this->entry) && !eregi($filter_dir,$DIR_Name."/".$this->entry) && $filter_dir != 1)
    {
    $this->VISION_TO_DIR2LISTBOX($DIR_Name."/".$this->entry, $allowed, $filter, $filter_dir, $show_filesize);
      }
      elseif(is_dir($DIR_Name."/".$this->entry) && $filter_dir == 1)
      {
    $this->VISION_TO_DIR2LISTBOX($DIR_Name."/".$this->entry, $allowed, $filter, $filter_dir, $show_filesize);      
      }
    }
    }
    $DIR->close();
    return $this->dynbox;
}
//======================================================================================================

The function above produces an array of filtered dir items ...
I need copy of this function that will produce UL nested tree like list ...
with classes  class='dir' (open, close folder)  and css class for files with links ...
two options expanded (all) and expand current dir only ...
(some breadcrum at the top to return or steep 'up' ...

Is there a better way to filter files ? i use eregi  ?
 

0
Comment
Question by:feha
  • 12
  • 9
21 Comments
 
LVL 40

Expert Comment

by:RQuadling
ID: 17049199
If you are using PHP 5, then the new SPL will do pretty much all of this for you.

Here are some of the examples from the source ...

=================tree.php===============
<?php

/** @file   tree.php
 * @brief   Program Tree view example
 * @ingroup Examples
 * @author  Marcus Boerger
 * @date    2003 - 2006
 *
 * Usage: php tree.php \<path\>
 *
 * Simply specify the path to tree with parameter \<path\>.
 */

// The following line only operates on classes which are converted to c already.
// But does not generate a graphical output.
//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {

if ($argc < 2) {
      echo <<<EOF
Usage: php ${_SERVER['PHP_SELF']} <path>

Displays a graphical tree for the given <path>.

<path> The directory for which to generate the tree graph.


EOF;
      exit(1);
}

if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");

echo $argv[1]."\n";
foreach(new DirectoryGraphIterator($argv[1]) as $file)
{
      echo $file . "\n";
}

?>

===========directorytree.php==============
<?php

/** @file   directorytree.php
 * @brief   Program Directory tree example
 * @ingroup Examples
 * @author  Marcus Boerger
 * @date    2003 - 2006
 *
 * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
 *
 * Simply specify the path to tree with parameter \<path\>.
 */

if ($argc < 2) {
      echo <<<EOF
Usage: php ${_SERVER['PHP_SELF']} <path>

Displays a graphical directory tree for the given <path>.

<path> The directory for which to generate the directory tree graph.


EOF;
      exit(1);
}

if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");

$length = $argc > 3 ? $argv[3] : -1;

echo $argv[1]."\n";
foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
//foreach(new DirectoryTreeIterator($argv[1]) as $file) {
      echo $file . "\n";
}

?>

==========directorytreeiterator.inc================
<?php

/** @file directorytreeiterator.inc
 * @ingroup Examples
 * @brief class DirectoryTreeIterator
 * @author  Marcus Boerger
 * @date    2003 - 2005
 *
 * SPL - Standard PHP Library
 */

/** @ingroup Examples
 * @brief   DirectoryIterator to generate ASCII graphic directory trees
 * @author  Marcus Boerger
 * @version 1.1
 */
class DirectoryTreeIterator extends RecursiveIteratorIterator
{
      /** Construct from a path.
       * @param $path directory to iterate
       */
      function __construct($path)
      {
            parent::__construct(
                  new RecursiveCachingIterator(
                        new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
                        ),
                        CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
                  ),
                  parent::SELF_FIRST
            );
      }

      /** @return the current element prefixed with ASCII graphics
       */      
      function current()
      {
            $tree = '';
            for ($l=0; $l < $this->getDepth(); $l++) {
                  $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : '  ';
            }
            return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
                   . $this->getSubIterator($l)->__toString();
      }

      /** Aggregates the inner iterator
       */      
      function __call($func, $params)
      {
            return call_user_func_array(array($this->getSubIterator(), $func), $params);
      }
}

?>


=============directorygraphiterator.inc=======================
<?php

/** @file directorygraphiterator.inc
 * @ingroup Examples
 * @brief class DirectoryGraphIterator
 * @author  Marcus Boerger
 * @date    2003 - 2005
 *
 * SPL - Standard PHP Library
 */

/** @ingroup Examples
 * @brief   A tree iterator that only shows directories.
 * @author  Marcus Boerger
 * @version 1.1
 */
class DirectoryGraphIterator extends DirectoryTreeIterator
{
      function __construct($path)
      {
            RecursiveIteratorIterator::__construct(
                  new RecursiveCachingIterator(
                        new ParentIterator(
                              new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
                              )
                        ),
                        CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
                  ),
                  parent::SELF_FIRST
            );
      }
}

?>

At the CLI, tree C:\ produces output like ...

c:\
|-APS
| |-doc
| \-lib
|-BATCH
|-CC Get MAC Address
|-DELL
|-Documents and Settings
| |-All Users
| | |-Application Data
| | | |-Adobe
| | | | \-Acrobat
| | | |   \-7.0
| | | |     \-Replicate
| | | |       \-Security
| | | |-Ahead
| | | | \-Nero Recode
| | | |-Apple Computer
| | | | \-QuickTime
| | | |-Data Connection Wizard
| | | |-Goland
| | | | \-Audio DVD Creator
| | | |   \-Project
| | | |-InstallShield
| | | | \-UpdateService
| | | |   \-Database
| | | |-Microsoft
| | | | |-AddIns
| | | | |-Crypto
| | | | | |-DSS
| | | | | | \-MachineKeys
| | | | | \-RSA
| | | | |   |-MachineKeys
etc.

and at the command prompt directorytree c:\ produces output of ...

c:\
|-a1.b64
|-a1.php
|-a1.txt
|-a2.b64
|-a2.txt
|-a3.b64
|-a3.txt
|-am.php
|-am2.php
|-anticon.php
|-anticon.php.bak
|-APS
| |-APS.lnk
| |-changelog.txt
| |-COPYING
| |-doc
| | |-ENCRYPTION.txt
| | |-greenball.gif
| | \-NTLM Authentication Scheme for HTTP.htm
| |-Install.txt
| |-lib
| | |-basic_auth.py
| | |-basic_auth.pyc
| | |-config.py
| | |-config.pyc
| | |-config_affairs.py
| | |-config_affairs.pyc
| | |-des.py
| | |-des.pyc
| | |-des_c.py
| | |-des_c.pyc
| | |-des_data.py
| | |-des_data.pyc
| | |-http_header.py
| | |-http_header.pyc
| | |-logger.py
| | |-logger.pyc
| | |-md4.py
| | |-md4.pyc
| | |-monitor_upstream.py
| | |-monitor_upstream.pyc
| | |-ntlm_auth.py
| | |-ntlm_auth.pyc
| | |-ntlm_messages.py
| | |-ntlm_messages.pyc
| | |-ntlm_procs.py
| | |-ntlm_procs.pyc
| | |-proxy_client.py
| | |-proxy_client.pyc
| | |-server.py
| | |-server.pyc
| | |-U32.py
etc.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17049205
Whilst not a direct answer, you may find that you can use the SPL a lot easier and quicker in getting your required output.

0
 
LVL 2

Author Comment

by:feha
ID: 17049340
Hi RQuading

Thank you, but I need something that can be used in PHP4 (both)
and my code is used in my commercial CMS so i can'i include any GPL etc ...

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17049353
The SPL is not available for PHP4.

Just so we have a clearer understanding, can you present some HTML output for what happens at the moment and what you would like to see. Use the same data both times (so please make sure it is consistent). Also, just include a few items.
0
 
LVL 2

Author Comment

by:feha
ID: 17049399
the current function does not produce any html output, it makes an array of dires and files to be used in select listbox and does well ...

what i need is using same array or a function
should produce a menu like structure ...
example
  <ul>
<li class="first"><a  href="../Home/index.php?pid=1" title="">Page 1 [Home]</a></li>
<li ><a  href="../Home/index.php?pid=7" title="">Page 2 [Home]</a></li>
<li ><a  href="../Home/index.php?pid=13" title="">Page 3 [Home]</a></li>
<li ><a  href="../Home/index.php?pid=19" title="">Page 4 [Home]</a></li>
<li class="last active_page"><a  href="../Home/index.php?pid=25" title="">Page 5 [Home]</a><ul>
<li ><a  href="../Home/index.php?pid=26" title="">Sub-Page 5.1 []</a></li>
<li class="active_page"><a  href="../Home/index.php?pid=28" title="">Sub-Page 5.3 []</a><ul>
<li class="last active_page"><a  class="current_page" href="../Home/index.php?pid=27" title="">Sub-Page 5.2 []</a></li>
</ul>
</li>
<li ><a  href="../Home/index.php?pid=29" title="">Sub-Page 5.4 []</a></li>
<li ><a  href="../Home/index.php?pid=30" title="">Sub-Page 5.5 []</a></li>
</ul>
</li>
</ul>


but represent dirs and files with links to files ...
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17049414
Ah. Right. Can you do a var_export(xxxxx) on that array? Saves having to work out what is contained.

 
0
 
LVL 2

Author Comment

by:feha
ID: 17049523
the function above produces ...

Array ( [0] => Array ( [0] => ./Adm_Edit_Pages.php [1] => ./Adm_Edit_Pages.php ) [1] => Array ( [0] => ./Adm_Module_Config.php [1] => ./Adm_Module_Config.php ) [2] => Array ( [0] => ./Adm_Pages.php [1] => ./Adm_Pages.php ) [3] => Array ( [0] => ./Adm_Page_List.php [1] => ./Adm_Page_List.php ) [4] => Array ( [0] => ./Adm_Page_Sections.php [1] => ./Adm_Page_Sections.php ) [5] => Array ( [0] => ./Files/index.php [1] => ./Files/index.php ) [6] => Array ( [0] => ./Functions/config_func.php [1] => ./Functions/config_func.php ) [7] => Array ( [0] => ./Functions/index.php [1] => ./Functions/index.php ) [8] => Array ( [0] => ./Functions/menu_func.php [1] => ./Functions/menu_func.php ) [9] => Array ( [0] => ./Functions/page_func.php [1] => ./Functions/page_func.php ) [10] => Array ( [0] => ./Functions/sync_func.php [1] => ./Functions/sync_func.php ) [11] => Array ( [0] => ./Images/Articles/index.php [1] => ./Images/Articles/index.php ) [12] => Array ( [0] => ./Images/BOX/index.php [1] => ./Images/BOX/index.php ) [13] => Array ( [0] => ./Images/Headers/index.php [1] => ./Images/Headers/index.php ) [14] => Array ( [0] => ./Images/Icons/index.php [1] => ./Images/Icons/index.php ) [15] => Array ( [0] => ./Images/index.php [1] => ./Images/index.php ) [16] => Array ( [0] => ./Images/Misc/index.php [1] => ./Images/Misc/index.php ) [17] => Array ( [0] => ./Images/News/index.php [1] => ./Images/News/index.php ) [18] => Array ( [0] => ./Images/Photos/index.php [1] => ./Images/Photos/index.php ) [19] => Array ( [0] => ./Includes/Adm_Page_Sections_inc.php [1] => ./Includes/Adm_Page_Sections_inc.php ) [20] => Array ( [0] => ./Includes/Current_Page_inc.php [1] => ./Includes/Current_Page_inc.php ) [21] => Array ( [0] => ./Includes/index.php [1] => ./Includes/index.php ) [22] => Array ( [0] => ./Includes/Page_Box_inc.php [1] => ./Includes/Page_Box_inc.php ) [23] => Array ( [0] => ./Includes/Page_Breadcrumb_inc.php [1] => ./Includes/Page_Breadcrumb_inc.php ) [24] => Array ( [0] => ./Includes/Page_Comments_inc.php [1] => ./Includes/Page_Comments_inc.php ) [25] => Array ( [0] => ./Includes/Page_Content_inc.php [1] => ./Includes/Page_Content_inc.php ) [26] => Array ( [0] => ./Includes/Page_Current_inc.php [1] => ./Includes/Page_Current_inc.php ) [27] => Array ( [0] => ./Includes/Page_Header_inc.php [1] => ./Includes/Page_Header_inc.php ) [28] => Array ( [0] => ./Includes/Page_Map_inc.php [1] => ./Includes/Page_Map_inc.php ) [29] => Array ( [0] => ./Includes/Page_Map_Sidebar_inc.php [1] => ./Includes/Page_Map_Sidebar_inc.php ) [30] => Array ( [0] => ./Includes/Page_Menu_Admin_inc.php [1] => ./Includes/Page_Menu_Admin_inc.php ) [31] => Array ( [0] => ./Includes/Page_Menu_inc.php [1] => ./Includes/Page_Menu_inc.php ) [32] => Array ( [0] => ./Includes/Page_Menu_Top_inc.php [1] => ./Includes/Page_Menu_Top_inc.php ) [33] => Array ( [0] => ./Includes/Page_Sections_inc.php [1] => ./Includes/Page_Sections_inc.php ) [34] => Array ( [0] => ./Includes/Page_Sidebar_inc.php [1] => ./Includes/Page_Sidebar_inc.php ) [35] => Array ( [0] => ./Includes/Page_Tools_inc.php [1] => ./Includes/Page_Tools_inc.php ) [36] => Array ( [0] => ./Includes/Print_Content_inc.php [1] => ./Includes/Print_Content_inc.php ) [37] => Array ( [0] => ./Includes/Print_Footer_inc.php [1] => ./Includes/Print_Footer_inc.php ) [38] => Array ( [0] => ./Includes/Print_Header_inc.php [1] => ./Includes/Print_Header_inc.php ) [39] => Array ( [0] => ./index.php [1] => ./index.php ) [40] => Array ( [0] => ./Print.php [1] => ./Print.php ) [41] => Array ( [0] => ./Site_Map.php [1] => ./Site_Map.php ) [42] => Array ( [0] => ./WYSIWYG.php [1] => ./WYSIWYG.php ) )

for files including dir path ...
0
 
LVL 2

Author Comment

by:feha
ID: 17049540
but you are free to change the function above to produce desired array in order to handle the menu requirements ...
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17049571
<?php
$a_list = VISION_TO_DIR2LISTBOX(....);// Insert appropriate parameters here.

$s_list_items = '';
foreach($a_list as $i_key => $a_list_entry)
      {
      $s_basename = basename($a_list_entry[0]);
      $s_list_items .= <<< END_LIST_ITEM
<li><a href="{$a_list_entry[0]}">{$s_basename}</a>
END_LIST_ITEM;
      }

$s_ul = <<< END_UL
<ul>
{$s_list_items}
</ul>
END_UL;

// $s_ul now contains the unorderd list.
?>

Using the data you provided, this is ...

<ul>
      <li><a href="./Adm_Edit_Pages.php">Adm_Edit_Pages.php</a>
      <li><a href="./Adm_Module_Config.php">Adm_Module_Config.php</a>
      <li><a href="./Adm_Pages.php">Adm_Pages.php</a>
      <li><a href="./Adm_Page_List.php">Adm_Page_List.php</a>
      <li><a href="./Adm_Page_Sections.php">Adm_Page_Sections.php</a>
      <li><a href="./Files/index.php">index.php</a>
      <li><a href="./Functions/config_func.php">config_func.php</a>
      <li><a href="./Functions/index.php">index.php</a>
      <li><a href="./Functions/menu_func.php">menu_func.php</a>
      <li><a href="./Functions/page_func.php">page_func.php</a>
      <li><a href="./Functions/sync_func.php">sync_func.php</a>
      <li><a href="./Images/Articles/index.php">index.php</a>
      <li><a href="./Images/BOX/index.php">index.php</a>
      <li><a href="./Images/Headers/index.php">index.php</a>
      <li><a href="./Images/Icons/index.php">index.php</a>
      <li><a href="./Images/index.php">index.php</a>
      <li><a href="./Images/Misc/index.php">index.php</a>
      <li><a href="./Images/News/index.php">index.php</a>
      <li><a href="./Images/Photos/index.php">index.php</a>
      <li><a href="./Includes/Adm_Page_Sections_inc.php">Adm_Page_Sections_inc.php</a>
      <li><a href="./Includes/Current_Page_inc.php">Current_Page_inc.php</a>
      <li><a href="./Includes/index.php">index.php</a>
      <li><a href="./Includes/Page_Box_inc.php">Page_Box_inc.php</a>
      <li><a href="./Includes/Page_Breadcrumb_inc.php">Page_Breadcrumb_inc.php</a>
      <li><a href="./Includes/Page_Comments_inc.php">Page_Comments_inc.php</a>
      <li><a href="./Includes/Page_Content_inc.php">Page_Content_inc.php</a>
      <li><a href="./Includes/Page_Current_inc.php">Page_Current_inc.php</a>
      <li><a href="./Includes/Page_Header_inc.php">Page_Header_inc.php</a>
      <li><a href="./Includes/Page_Map_inc.php">Page_Map_inc.php</a>
      <li><a href="./Includes/Page_Map_Sidebar_inc.php">Page_Map_Sidebar_inc.php</a>
      <li><a href="./Includes/Page_Menu_Admin_inc.php">Page_Menu_Admin_inc.php</a>
      <li><a href="./Includes/Page_Menu_inc.php">Page_Menu_inc.php</a>
      <li><a href="./Includes/Page_Menu_Top_inc.php">Page_Menu_Top_inc.php</a>
      <li><a href="./Includes/Page_Sections_inc.php">Page_Sections_inc.php</a>
      <li><a href="./Includes/Page_Sidebar_inc.php">Page_Sidebar_inc.php</a>
      <li><a href="./Includes/Page_Tools_inc.php">Page_Tools_inc.php</a>
      <li><a href="./Includes/Print_Content_inc.php">Print_Content_inc.php</a>
      <li><a href="./Includes/Print_Footer_inc.php">Print_Footer_inc.php</a>
      <li><a href="./Includes/Print_Header_inc.php">Print_Header_inc.php</a>
      <li><a href="./index.php">index.php</a>
      <li><a href="./Print.php">Print.php</a>
      <li><a href="./Site_Map.php">Site_Map.php</a>
      <li><a href="./WYSIWYG.php">WYSIWYG.php</a>
</ul>
0
 
LVL 2

Author Comment

by:feha
ID: 17049613
that is inproper output ...
(not xhtml ...)

i need to detect dirs too
ant make tree-like ouptut , the array above is not for that ...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:feha
ID: 17049678
example :
 
<ul>
<li class="dir"><a  href="../Home/" >Home</a></li>
<li class="dir"><a  href="/Functions/" >Functions</a></li>
<li ><a  href="/Admin/">Admin</a></li>
<li class="dir"><a  href="../Home2/" title="">Home2</a><ul>
<li class="file"><a  href="../Home2/index.php" title="">index</a></li>
<li class="dir"><a  href="../Home2/Dir2/" title="">Home2/Dir2</a><ul>
<li class="file"><a  class="current_page" href="../Home2/Dir2/index.php" title="">index</a></li>
</ul>
</li>
<li class="dir"><a  href="../Home3/" >Home3</a></li>
<li class="dir"><a  href="/Functions3/" >Functions3</a></li>
</ul>
</li>
</ul>
0
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
ID: 17050142
<?php
function RecursiveDirectoryTreeWalker
      (
      $s_dir = '.', // What directory are we examining.
      $s_include = '.php', // What to we want to include.
      $s_exclude = '_events.php|wp|class|functions', // What do we want to exclude.
      $s_exclude_dir = NULL, // What directories do we exclude. NULL => default.
      $b_recursive = True // Do we want recursion.
      )
      {
      // Assign default directory exclusion filter.
      $s_exclude_dir = !is_null($s_exclude_dir) ? $s_exclude_dir : 'class|includes|editor|fpdf|plugin|temp|sorter|template|images|extra|feeds|3rd|functions|files|wp|wysiwygpro|layout|styles|css|js|fonts';

      // Prepare results.
      $s_results = '';
      
      // Start iteration of chosen directory.
      $obj_dir = dir($s_dir);
      while($s_entry = $obj_dir->read())
            {
            // Shortcut for complete path.
            $s_working_entry = $s_dir . DIRECTORY_SEPARATOR . $s_entry;
            $s_working_href = rawurlencode(str_replace(array('/', '\\'), '/', $s_working_entry));

            // Exclude . and ..
            if (!in_array($s_entry, array('.', '..')))
                  {
                  // Is this a directory?
                  if (is_dir($s_working_entry))
                        {
                        // Is this directory filtered?
                        if (($s_exclude_dir !== '') && !eregi($s_exclude_dir, $s_entry))
                              {
                              // Construct the LI and A tag for the directory.
                              $s_results .= '<li class="dir"><a href="' . $s_working_href . '">' . $s_entry . '</a>';

                              // Are we recursing and is the current directory allowed to be recursed, assuming we want to filter directories.
                              if (True === $b_recursive)
                                    {
                                    $s_results .= RecursiveDirectoryTreeWalker($s_working_entry, $s_include, $s_exclude, $s_exclude_dir, $b_recursive);
                                    }
                              // Close the LI tag.
                              $s_results .= '</li>';
                              }
                        }
                  else
                        {
                        if (!eregi($s_exclude, $s_entry) && eregi($s_include, $s_entry))
                              {
                              // Construct LI and A tags.
                              $s_results .= '<li class="file"><a href="' . $s_working_href . '">' . $s_entry . '</a></li>';
                              }
                        }
                  }
            }

      // Close the directory.
      $obj_dir->close();

      // Return the XHTML but suppress empty UL.
      $s_results = $s_results == '' ? '' : "<ul>$s_results</ul>";
      return $s_results;
      }

$s_output = RecursiveDirectoryTreeWalker();
echo <<< END_HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
      <head><title>UL LI</title></head>
      <body>$s_output</body>
</html>
END_HTML;
?>

produces output like (FireFox cut and paste adds # and stuff for you!) ...

# AddBigChars.php
# AJAX Testing

    * fakeserver.php

# Amanda Ingram Specific Scripts

    * Make Combined List.php
    * Timeware absence colours.php

# AutomatedDataEntryValidation.php
# AverageCasingPriceCalculation.php
# b64.php
# Backups.php
# BackupScans.php
# base64encode length test.php
# basedate.php
# bench.php
# Bigchar data as urlencoded test.php
# BigChar.php
# bool.php
# call_user_func tests.php
# cb.php
# chars.php
# Copies of other pages

    * info.php

# Copy Scans.php
# CopyTest.php
# Cryption.php
# css.php
# d2.php
# d9.php
# dbz.php
# DecodeB64.php
# delbak.php
# demo1.php
# DOS
# Dump FON.php
# Dump TIFF.php
# Duration.php
# EE scripts

    * 2 submit buttons in the same form - Q_21838900.php
    * 28.php
    * array_multisort.php
    * bottombar.php
    * cookietest.php
    * cookietest2.php
    * dbconnect.php
    * DST Test 001.php
    * Get client datetime into PHP Q_21817337.php
    * headers.php
    * info.php
    * info.php4
    * login.php
    * ordered.php
    * pets.php
    * pets2.php
    * pets3.php
    * printf float.php
    * Q_21113446 - Resizing and word-wrapping dynamic text to fit an image.php
    * Q_21158362 - How to manage CD DVD Volume Management.php
    * Q_21164609 - Strip price.php

The XHTML is passing Tidy's tests and looks like ...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
      <head><title>UL LI</title></head>
      <body><ul><li class="file"><a href=".%2FAddBigChars.php">AddBigChars.php</a></li><li class="dir"><a href=".%2FAJAX%20Testing">AJAX Testing</a><ul><li class="file"><a href=".%2FAJAX%20Testing%2Ffakeserver.php">fakeserver.php</a></li></ul></li><li class="dir"><a href=".%2FAmanda%20Ingram%20Specific%20Scripts">Amanda Ingram Specific Scripts</a><ul><li class="file"><a href=".%2FAmanda%20Ingram%20Specific%20Scripts%2FMake%20Combined%20List.php">Make Combined List.php</a></li><li class="file"><a href=".%2FAmanda%20Ingram%20Specific%20Scripts%2FTimeware%20absence%20colours.php">Timeware absence colours.php</a></li></ul></li><li class="file"><a href=".%2FAutomatedDataEntryValidation.php">AutomatedDataEntryValidation.php</a></li><li class="file"><a href=".%2FAverageCasingPriceCalculation.php">AverageCasingPriceCalculation.php</a></li><li class="file"><a href=".%2Fb64.php">b64.php</a></li><li class="file"><a href=".%2FBackups.php">Backups.php</a></li><li class="file"><a href=".%2FBackupScans.php">BackupScans.php</a></li><li class="file"><a href=".%2Fbase64encode%20length%20test.php">base64encode length test.php</a></li><li class="file"><a href=".%2Fbasedate.php">basedate.php</a></li><li class="file"><a href=".%2Fbench.php">bench.php</a></li><li class="file"><a href=".%2FBigchar%20data%20as%20urlencoded%20test.php">Bigchar data as urlencoded test.php</a></li><li class="file"><a href=".%2FBigChar.php">BigChar.php</a></li><li class="file"><a href=".%2Fbool.php">bool.php</a></li><li class="file"><a href=".%2Fcall_user_func%20tests.php">call_user_func tests.php</a></li><li class="file"><a href=".%2Fcb.php">cb.php</a></li><li class="file"><a href=".%2Fchars.php">chars.php</a></li><li class="dir"><a href=".%2FCopies%20of%20other%20pages">Copies of other pages</a><ul><li class="file"><a href=".%2FCopies%20of%20other%20pages%2Finfo.php">info.php</a></li></ul></li><li class="file"><a href=".%2FCopy%20Scans.php">Copy Scans.php</a></li><li class="file"><a href=".%2FCopyTest.php">CopyTest.php</a></li><li class="file"><a href=".%2FCryption.php">Cryption.php</a></li><li class="file"><a href=".%2Fcss.php">css.php</a></li><li class="file"><a href=".%2Fd2.php">d2.php</a></li><li class="file"><a href=".%2Fd9.php">d9.php</a></li><li class="file"><a href=".%2Fdbz.php">dbz.php</a></li><li class="file"><a href=".%2FDecodeB64.php">DecodeB64.php</a></li><li class="file"><a href=".%2Fdelbak.php">delbak.php</a></li><li class="file"><a href=".%2Fdemo1.php">demo1.php</a></li><li class="dir"><a href=".%2FDOS">DOS</a></li><li class="file"><a href=".%2FDump%20FON.php">Dump FON.php</a></li><li class="file"><a href=".%2FDump%20TIFF.php">Dump TIFF.php</a></li><li class="file"><a href=".%2FDuration.php">Duration.php</a></li><li class="dir"><a href=".%2FEE%20scripts">EE scripts</a><ul><li class="file"><a href=".%2FEE%20scripts%2F2%20submit%20buttons%20in%20the%20same%20form%20-%20Q_21838900.php">2 submit buttons in the same form - Q_21838900.php</a></li><li class="file"><a href=".%2FEE%20scripts%2F28.php">28.php</a></li><li class="file"><a href=".%2FEE%20scripts%2Farray_multisort.php">array_multisort.php</a></li><li class="file"><a href=".%2FEE%20scripts%2Fbottombar.php">bottombar.php</a></li><li class="file"><a href=".%2FEE%20scripts%2Fcookietest.php">cookietest.php</a></li><li class="file"><a href=".%2FEE%20scripts%2Fcookietest2.php">cookietest2.php</a></li><li class="file"><a href=".%2FEE%20scripts%2Fdbconnect.php">dbconnect.php</a></li><li class="file"><a href=".%2FEE%20scripts%2FDST%20Test%20001.php">DST Test 001.php</a></li><li class="file"><a href=".%2FEE%20scripts%2FGet%20client%20datetime%20into%20PHP%20Q_21817337.php">Get client datetime into
[SNIP]
</body>

</html>
0
 
LVL 2

Author Comment

by:feha
ID: 17050208
RQuadling, great work
thank you very much
0
 
LVL 2

Author Comment

by:feha
ID: 17050276
when trying $b_recursive = true

Warning: dir(.\tee1_1): failed to open dir: Invalid argument in c:\inetpub\wwwroot\php4\dir2tree.php on line 18

Fatal error: Call to a member function on a non-object in c:\inetpub\wwwroot\php4\dir2tree.php on line 19

it is on my local windows server ...
0
 
LVL 2

Author Comment

by:feha
ID: 17050290
but if i add echo RecursiveDirectoryTreeWalker('CMS');
works well
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17050297
Nearly the entirity of that code can be written in a few SPL lines with PHP5. The code you say in the examples is supplied with the PHP source. That code is only used until the same class exists in SPL. Then the code is irrelevant.

As for the GPL license. I assumed that as long as you provide the source to any elements you use (i.e. allow your users to break it), then you were fine!

Basically, I can do what I like with it as long as ...

1 - I don't pretend that the original work is mine.
2 - I supply the same rights to my clients as I have.

0
 
LVL 2

Author Comment

by:feha
ID: 17050305
EXCELLENT :-)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17050313
Recursive is true by default.
Supplying a directory name overrides the default which is the current directory. This may be a better option for you otherwise ALL files are visible.

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 17050319
So. Is this all working now? Interleaved messages result in confusion.
0
 
LVL 2

Author Comment

by:feha
ID: 17050332
"As for the GPL license. I assumed that as long as you provide the source to any elements you use (i.e. allow your users to break it), then you were fine"

I have no problem to release changes, but some GPL requires that even my CMS project should be GPL ...
my CMS is commercial and not an open source ...

however i do have inmy system a folder 3rd  there are included all GPL etc ... not covered with my commercial license
this means my system will make use of it if you include GPL script or class in that folder ...
0
 
LVL 2

Author Comment

by:feha
ID: 17050549
BTW here is demo online
http://trinityhome.org/~visionto/Users/index.php

I'm working now on more advanced version ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now