/**
  * ディレクトリツリー生成
  *
  * @param  SC_Helper_FileManager_Ex       $objFileManager SC_Helper_FileManager_Exインスタンス
  * @param  SC_FormParam $objFormParam   SC_FormParamインスタンス
  * @return void
  */
 public function setDispTree($objFileManager, $objFormParam)
 {
     $tpl_onload = '';
     // ツリーを表示する divタグid, ツリー配列変数名, 現在ディレクトリ, 選択ツリーhidden名, ツリー状態hidden名, mode hidden名
     $now_dir = $objFormParam->getValue('now_dir');
     $treeView = "eccube.fileManager.viewFileTree('tree', arrTree, '{$now_dir}', 'tree_select_file', 'tree_status', 'move');";
     if (!empty($this->tpl_onload)) {
         $tpl_onload .= $treeView;
     } else {
         $tpl_onload = $treeView;
     }
     $this->setTplOnLoad($tpl_onload);
     $tpl_javascript = '';
     $arrTree = $objFileManager->sfGetFileTree($objFormParam->getValue('top_dir'), $objFormParam->getValue('tree_status'));
     $tpl_javascript .= "arrTree = new Array();\n";
     foreach ($arrTree as $arrVal) {
         $tpl_javascript .= 'arrTree[' . $arrVal['count'] . '] = new Array(' . $arrVal['count'] . ", '" . $arrVal['type'] . "', '" . $arrVal['path'] . "', " . $arrVal['rank'] . ',';
         if ($arrVal['open']) {
             $tpl_javascript .= "true);\n";
         } else {
             $tpl_javascript .= "false);\n";
         }
     }
     $this->setDispParam('tpl_javascript', $tpl_javascript);
 }
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     //---- 認証可否の判定
     $objSess = new SC_Session();
     SC_Utils_Ex::sfIsSuccess($objSess);
     // ルートディレクトリ
     $top_dir = USER_PATH;
     $objView = new SC_AdminView();
     $objQuery = new SC_Query();
     $objFileManager = new SC_Helper_FileManager_Ex();
     if (!isset($_POST['mode'])) {
         $_POST['mode'] = "";
     }
     // 現在の階層を取得
     if ($_POST['mode'] != "") {
         $now_dir = $_POST['now_file'];
     } else {
         // 初期表示はルートディレクトリ(user_data/)を表示
         $now_dir = $top_dir;
     }
     // ファイル管理クラス
     $objUpFile = new SC_UploadFile($now_dir, $now_dir);
     // ファイル情報の初期化
     $this->lfInitFile($objUpFile);
     switch ($_POST['mode']) {
         // ファイル表示
         case 'view':
             // エラーチェック
             $arrErr = $this->lfErrorCheck();
             if (!is_array($arrErr)) {
                 // 選択されたファイルがディレクトリなら移動
                 if (is_dir($_POST['select_file'])) {
                     ///$now_dir = $_POST['select_file'];
                     // ツリー遷移用のjavascriptを埋め込む
                     $arrErr['select_file'] = "※ ディレクトリを表示することは出来ません。<br/>";
                 } else {
                     // javascriptで別窓表示(テンプレート側に渡す)
                     // FIXME XSS対策すること
                     $file_url = ereg_replace(USER_PATH, "", $_POST['select_file']);
                     $this->tpl_onload = "win02('./file_view.php?file=" . $file_url . "', 'user_data', '600', '400');";
                 }
             }
             break;
             // ファイルダウンロード
         // ファイルダウンロード
         case 'download':
             // エラーチェック
             $arrErr = $this->lfErrorCheck();
             if (!is_array($arrErr)) {
                 if (is_dir($_POST['select_file'])) {
                     // ディレクトリの場合はjavascriptエラー
                     $arrErr['select_file'] = "※ ディレクトリをダウンロードすることは出来ません。<br/>";
                 } else {
                     // ファイルダウンロード
                     $objFileManager->sfDownloadFile($_POST['select_file']);
                     exit;
                 }
             }
             break;
             // ファイル削除
         // ファイル削除
         case 'delete':
             // エラーチェック
             $arrErr = $this->lfErrorCheck();
             if (!is_array($arrErr)) {
                 $objFileManager->sfDeleteDir($_POST['select_file']);
             }
             break;
             // ファイル作成
         // ファイル作成
         case 'create':
             // エラーチェック
             $arrErr = $this->lfCreateErrorCheck();
             if (!is_array($arrErr)) {
                 $create_dir = ereg_replace("/\$", "", $now_dir);
                 // ファイル作成
                 if (!$objFileManager->sfCreateFile($create_dir . "/" . $_POST['create_file'], 0755)) {
                     // 作成エラー
                     $arrErr['create_file'] = "※ " . $_POST['create_file'] . "の作成に失敗しました。<br/>";
                 } else {
                     $this->tpl_onload .= "alert('フォルダを作成しました。');";
                 }
             }
             break;
             // ファイルアップロード
         // ファイルアップロード
         case 'upload':
             // 画像保存処理
             $ret = $objUpFile->makeTempFile('upload_file', false);
             if ($ret != "") {
                 $arrErr['upload_file'] = $ret;
             } else {
                 $this->tpl_onload .= "alert('ファイルをアップロードしました。');";
             }
             break;
             // フォルダ移動
         // フォルダ移動
         case 'move':
             $now_dir = $this->lfCheckSelectDir($_POST['tree_select_file']);
             break;
             // 初期表示
         // 初期表示
         default:
             break;
     }
     // トップディレクトリか調査
     $is_top_dir = false;
     // 末尾の/をとる
     $top_dir_check = ereg_replace("/\$", "", $top_dir);
     $now_dir_check = ereg_replace("/\$", "", $now_dir);
     if ($top_dir_check == $now_dir_check) {
         $is_top_dir = true;
     }
     // 現在の階層より一つ上の階層を取得
     $parent_dir = $this->lfGetParentDir($now_dir);
     // 現在のディレクトリ配下のファイル一覧を取得
     $this->arrFileList = $objFileManager->sfGetFileList($now_dir);
     $this->tpl_is_top_dir = $is_top_dir;
     $this->tpl_parent_dir = $parent_dir;
     $this->tpl_now_dir = $now_dir;
     $this->tpl_now_file = basename($now_dir);
     $this->arrErr = isset($arrErr) ? $arrErr : "";
     $this->arrParam = $_POST;
     // ツリーを表示する divタグid, ツリー配列変数名, 現在ディレクトリ, 選択ツリーhidden名, ツリー状態hidden名, mode hidden名
     $treeView = "fnTreeView('tree', arrTree, '{$now_dir}', 'tree_select_file', 'tree_status', 'move');";
     if (!empty($this->tpl_onload)) {
         $this->tpl_onload .= $treeView;
     } else {
         $this->tpl_onload = $treeView;
     }
     // ツリー配列作成用 javascript
     if (!isset($_POST['tree_status'])) {
         $_POST['tree_status'] = "";
     }
     $arrTree = $objFileManager->sfGetFileTree($top_dir, $_POST['tree_status']);
     $this->tpl_javascript .= "arrTree = new Array();\n";
     foreach ($arrTree as $arrVal) {
         $this->tpl_javascript .= "arrTree[" . $arrVal['count'] . "] = new Array(" . $arrVal['count'] . ", '" . $arrVal['type'] . "', '" . $arrVal['path'] . "', " . $arrVal['rank'] . ",";
         if ($arrVal['open']) {
             $this->tpl_javascript .= "true);\n";
         } else {
             $this->tpl_javascript .= "false);\n";
         }
     }
     // 画面の表示
     $objView->assignobj($this);
     $objView->display(MAIN_FRAME);
 }