source: branches/feature-module-update/html/test/uehara/tree.php @ 16582

Revision 16582, 4.8 KB checked in by nanasess, 17 years ago (diff)

ライセンス表記変更

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23require_once("../../require.php");
24
25class LC_Page{
26    function LC_Page() {
27    }
28}
29
30$top_dir = USER_PATH;
31
32$objPage = new LC_Page();
33$objView = new SC_UserView("./templates");
34$objQuery = new SC_Query();
35
36// 現在の階層を取得
37if($_POST['mode'] != "") {
38    $now_dir = $_POST['now_file'];
39} else {
40    // 初期表示はルートディレクトリ(user_data/upload/)を表示
41    $now_dir = $top_dir;
42}
43
44// ファイル管理クラス
45$objUpFile = new SC_UploadFile($now_dir, $now_dir);
46// ファイル情報の初期化
47lfInitFile();
48
49switch($_POST['mode']) {
50
51// ファイル表示
52case 'view':
53    // エラーチェック
54    $arrErr = lfErrorCheck();
55    if(!is_array($arrErr)) {
56   
57        // 選択されたファイルがディレクトリなら移動
58        if(is_dir($_POST['select_file'])) {
59            ///$now_dir = $_POST['select_file'];
60            // ツリー遷移用のjavascriptを埋め込む
61            $arrErr['view'] = "※ ディレクトリを表示することは出来ません。";
62           
63        } else {
64            // javascriptで別窓表示(テンプレート側に渡す)
65            $file_url = ereg_replace(USER_PATH, "", $_POST['select_file']);
66            $objPage->tpl_javascript = "win02('./file_view.php?file=". $file_url ."', 'user_data', '600', '400');";
67        }
68    }
69    break;
70// ファイルダウンロード
71case 'download':
72
73    // エラーチェック
74    $arrErr = lfErrorCheck();
75    if(!is_array($arrErr)) {
76        if(is_dir($_POST['select_file'])) {
77            // ディレクトリの場合はjavascriptエラー
78            $arrErr['download'] = "※ ディレクトリをダウンロードすることは出来ません。";
79        } else {
80            // ファイルダウンロード
81            sfDownloadFile($_POST['select_file']);
82            exit;           
83        }
84    }
85    break;
86// ファイル削除
87case 'delete':
88    // エラーチェック
89    $arrErr = lfErrorCheck();
90    if(!is_array($arrErr)) {
91        sfDeleteDir($_POST['select_file']);
92    }
93    break;
94// ファイル作成
95case 'create':
96    // エラーチェック
97    $arrErr = lfCreateErrorCheck();
98    if(!is_array($arrErr)) {
99        $create_dir = ereg_replace("/$", "", $now_dir);
100        // ファイル作成
101        if(!sfCreateFile($create_dir."/".$_POST['create_file'], 0755)) {
102            // 作成エラー
103            $arrErr['create'] = "※ ".$_POST['create_file']."の作成に失敗しました。";
104        } else {
105            $objPage->tpl_javascript = "alert('フォルダを作成しました。');";
106        }
107    }
108    break;
109// ファイルアップロード
110case 'upload':
111    // 画像保存処理
112    $ret = $objUpFile->makeTempFile('upload_file', false);
113    if($ret != "") {
114        $arrErr['upload_file'] = $ret;
115    } else {
116        $objPage->tpl_javascript = "alert('ファイルをアップロードしました。');";
117    }
118    break;
119// フォルダ移動
120case 'move':
121    $now_dir = $_POST['tree_select_file'];
122    break;
123// 初期表示
124default :
125    break;
126}
127
128
129// 現在のディレクトリ配下のファイル一覧を取得
130$objPage->arrFileList = sfGetFileList($now_dir);
131$objPage->tpl_now_file = $now_dir;
132$objPage->arrErr = $arrErr;
133$objPage->arrParam = $_POST;
134$objPage->arrTree = sfGetFileTree($top_dir, $_POST['tree_status']);
135$objPage->$tpl_onload .= "fnTreeView('tree', arrTree, '$now_dir')";
136
137$objView->assignobj($objPage);
138$objView->display("tree.tpl");
139
140//-----------------------------------------------------------------------------------------------------------------------------------
141
142/*
143 * 関数名:lfErrorCheck()
144 * 説明 :エラーチェック
145 */
146function lfErrorCheck() {
147    $objErr = new SC_CheckError($_POST);
148    $objErr->doFunc(array("ファイル", "select_file"), array("SELECT_CHECK"));
149   
150    return $objErr->arrErr;
151}
152
153/*
154 * 関数名:lfCreateErrorCheck()
155 * 説明 :ファイル作成処理エラーチェック
156 */
157function lfCreateErrorCheck() {
158    $objErr = new SC_CheckError($_POST);
159    $objErr->doFunc(array("作成ファイル", "create_file"), array("EXIST_CHECK", "FILE_NAME_CHECK_BY_NOUPLOAD"));
160   
161    return $objErr->arrErr;
162}
163
164/*
165 * 関数名:lfInitFile()
166 * 説明 :ファイル情報の初期化
167 */
168function lfInitFile() {
169    global $objUpFile;
170    $objUpFile->addFile("アップロードファイル", 'upload_file', array(), FILE_SIZE, true, 0, 0, false);
171}
172?>
Note: See TracBrowser for help on using the repository browser.