Index: temp/trunk/html/test/uehara/test.php
===================================================================
--- temp/trunk/html/test/uehara/test.php	(revision 8763)
+++ temp/trunk/html/test/uehara/test.php	(revision 8764)
@@ -1,11 +1,23 @@
 <?php
+
+$default_dir = "/home/web/test.ec-cube.net/html/user_data/";
+$arrCnt = split('/', $default_dir);
+$default_rank = count($arrCnt);
 
 $arrTree = array();
 $cnt = 0;
-sfGetFileTree("/home/web/test.ec-cube.net/html/user_data/");
+
+sfGetFileTree($default_dir);
 print_r($arrTree);
-/*
+
+/* 
+ * ´Ø¿ôÌ¾¡§sfGetFileTree()
+ * ÀâÌÀ¡¡¡§¥Ä¥ê¡¼À¸À®ÍÑÇÛÎó¼èÆÀ(javascript¤ËÅÏ¤¹ÍÑ)
+ * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê
+ */
 function sfGetFileTree($dir) {
 	global $arrTree;
+	global $cnt;
+	global $default_rank;
 
 	if(file_exists($dir)) {
@@ -13,35 +25,25 @@
 			while (false !== ($item = readdir($handle))) {
 				if ($item != "." && $item != "..") {
-					if (is_dir("$dir/$item")) {
-						$arrResult[$cnt]['file_name'] = "$dir/$item";
-						$cnt++;
-						sfGetFileTree("$dir/$item");
-					}
-				}
-				$cnt++;
-			}
-		}
-		closedir($handle);
-		//$arrResult[$cnt]['file_name'] = "$dir/$item";
-	}
-
-	return $arrResult;
-}
-*/
-
-function sfGetFileTree($dir) {
-	global $arrTree;
-	if(file_exists($dir)) {
-		if ($handle = opendir("$dir")) {
-			$cnt = 0;
-			while (false !== ($item = readdir($handle))) {
-				if ($item != "." && $item != "..") {
 					// Ê¸Ëö¤Î/¤ò¼è¤ê½ü¤¯
 					$dir = ereg_replace("/$", "", $dir);
+					$path = $dir/$item;
 					// ¥Ç¥£¥ì¥¯¥È¥ê¤Î¤ß¼èÆÀ
-					if (is_dir("$dir/$item")) {
-						$arrTree[]['file_name'] = "$dir/$item";
+					if (is_dir($path)) {
+						$path;
+						if(sfDirChildExists($path)) {
+							$file_type = "_parent";
+						} else {
+							$file_type = "_child";	
+						}
+						
+						// ³¬ÁØ¤ò³ä¤ê½Ð¤¹
+						$arrCnt = split('/', $path);
+						$rank = count($arrCnt);
+						$rank = $rank - $default_rank;
+						
+						// javascript¤Î¥Ä¥ê¡¼À¸À®ÍÑ¤ÎÇÛÎó¤òºîÀ®
+						$arrTree[] = array($cnt, $file_type, $path, $rank);
 						// ²¼ÁØ¥Ç¥£¥ì¥¯¥È¥ê¼èÆÀ¤Î°Ù¡¢ºÆµ¢Åª¤Ë¸Æ¤Ó½Ð¤¹
-						sfGetFileTree("$dir/$item");
+						sfGetFileTree($path);
 					}
 				}
@@ -53,4 +55,26 @@
 }
 
-
+/* 
+ * ´Ø¿ôÌ¾¡§sfDirChildExists()
+ * ÀâÌÀ¡¡¡§»ØÄê¤·¤¿¥Ç¥£¥ì¥¯¥È¥êÇÛ²¼¤Ë¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¤«
+ * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê
+ */
+function sfDirChildExists($dir) {
+	if(file_exists($dir)) {
+		// ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç²¼ÁØ¥Õ¥¡¥¤¥ë¤ÎÁíÎÌ¤ò¼èÆÀ
+		if (is_dir($dir)) {
+		    $handle = opendir($dir);
+		    while ($file = readdir($handle)) {
+				// ¹ÔËö¤Î/¤ò¼è¤ê½ü¤¯
+				$dir = ereg_replace("/$", "", $dir);
+				$path = $dir."/".$file;
+		        if ($file != '..' && $file != '.') {
+					return true;
+		        }
+		    }
+		}
+	}
+    
+	return false;
+}
 ?>
