Changeset 8764 for temp/trunk


Ignore:
Timestamp:
2006/11/21 17:20:25 (20 years ago)
Author:
uehara
Message:

blank

Location:
temp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • temp/trunk/html/test/uehara/test.php

    r8763 r8764  
    11<?php 
     2 
     3$default_dir = "/home/web/test.ec-cube.net/html/user_data/"; 
     4$arrCnt = split('/', $default_dir); 
     5$default_rank = count($arrCnt); 
    26 
    37$arrTree = array(); 
    48$cnt = 0; 
    5 sfGetFileTree("/home/web/test.ec-cube.net/html/user_data/"); 
     9 
     10sfGetFileTree($default_dir); 
    611print_r($arrTree); 
    7 /* 
     12 
     13/*  
     14 * ´Ø¿ô̾¡§sfGetFileTree() 
     15 * ÀâÌÀ¡¡¡§¥Ä¥ê¡¼À¸À®ÍÑÇÛÎó¼èÆÀ(javascript¤ËÅϤ¹ÍÑ) 
     16 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê 
     17 */ 
    818function sfGetFileTree($dir) { 
    919    global $arrTree; 
     20    global $cnt; 
     21    global $default_rank; 
    1022 
    1123    if(file_exists($dir)) { 
     
    1325            while (false !== ($item = readdir($handle))) { 
    1426                if ($item != "." && $item != "..") { 
    15                     if (is_dir("$dir/$item")) { 
    16                         $arrResult[$cnt]['file_name'] = "$dir/$item"; 
    17                         $cnt++; 
    18                         sfGetFileTree("$dir/$item"); 
    19                     } 
    20                 } 
    21                 $cnt++; 
    22             } 
    23         } 
    24         closedir($handle); 
    25         //$arrResult[$cnt]['file_name'] = "$dir/$item"; 
    26     } 
    27  
    28     return $arrResult; 
    29 } 
    30 */ 
    31  
    32 function sfGetFileTree($dir) { 
    33     global $arrTree; 
    34     if(file_exists($dir)) { 
    35         if ($handle = opendir("$dir")) { 
    36             $cnt = 0; 
    37             while (false !== ($item = readdir($handle))) { 
    38                 if ($item != "." && $item != "..") { 
    3927                    // ʸËö¤Î/¤ò¼è¤ê½ü¤¯ 
    4028                    $dir = ereg_replace("/$", "", $dir); 
     29                    $path = $dir/$item; 
    4130                    // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¤ß¼èÆÀ 
    42                     if (is_dir("$dir/$item")) { 
    43                         $arrTree[]['file_name'] = "$dir/$item"; 
     31                    if (is_dir($path)) { 
     32                        $path; 
     33                        if(sfDirChildExists($path)) { 
     34                            $file_type = "_parent"; 
     35                        } else { 
     36                            $file_type = "_child";   
     37                        } 
     38                         
     39                        // ³¬Áؤò³ä¤ê½Ð¤¹ 
     40                        $arrCnt = split('/', $path); 
     41                        $rank = count($arrCnt); 
     42                        $rank = $rank - $default_rank; 
     43                         
     44                        // javascript¤Î¥Ä¥ê¡¼À¸À®ÍѤÎÇÛÎó¤òºîÀ® 
     45                        $arrTree[] = array($cnt, $file_type, $path, $rank); 
    4446                        // ²¼Áإǥ£¥ì¥¯¥È¥ê¼èÆÀ¤Î°Ù¡¢ºÆµ¢Åª¤Ë¸Æ¤Ó½Ð¤¹ 
    45                         sfGetFileTree("$dir/$item"); 
     47                        sfGetFileTree($path); 
    4648                    } 
    4749                } 
     
    5355} 
    5456 
    55  
     57/*  
     58 * ´Ø¿ô̾¡§sfDirChildExists() 
     59 * ÀâÌÀ¡¡¡§»ØÄꤷ¤¿¥Ç¥£¥ì¥¯¥È¥êÇÛ²¼¤Ë¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¤« 
     60 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê 
     61 */ 
     62function sfDirChildExists($dir) { 
     63    if(file_exists($dir)) { 
     64        // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç²¼ÁØ¥Õ¥¡¥¤¥ë¤ÎÁíÎ̤ò¼èÆÀ 
     65        if (is_dir($dir)) { 
     66            $handle = opendir($dir); 
     67            while ($file = readdir($handle)) { 
     68                // ¹ÔËö¤Î/¤ò¼è¤ê½ü¤¯ 
     69                $dir = ereg_replace("/$", "", $dir); 
     70                $path = $dir."/".$file; 
     71                if ($file != '..' && $file != '.') { 
     72                    return true; 
     73                } 
     74            } 
     75        } 
     76    } 
     77     
     78    return false; 
     79} 
    5680?> 
Note: See TracChangeset for help on using the changeset viewer.