Source for file LC_Page_Admin_Contents_FileManager.php
Documentation is available at LC_Page_Admin_Contents_FileManager.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_FileManager_Ex.php';
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Contents_FileManager.php 20970 2011-06-10 10:27:24Z Seasoft $
$this->tpl_mainpage = 'contents/file_manager.tpl';
$this->tpl_mainno = 'contents';
$this->tpl_subno = 'file';
$this->tpl_maintitle = 'コンテンツ管理';
$this->tpl_subtitle = 'ファイル管理';
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$objUpFile = new SC_UploadFile_Ex($objFormParam->getValue('now_dir'), $objFormParam->getValue('now_dir'));
$objFileManager = new SC_Helper_FileManager_Ex();
switch($this->getMode()) {
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$now_dir = $this->lfCheckSelectDir($objFormParam, $objFormParam->getValue('tree_select_file'));
$objFormParam->setValue('now_dir', $now_dir);
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$tpl_onload = "win02('./file_view.php?file=". $file_url . "', 'user_data', '600', '400');";
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
if(is_dir($objFormParam->getValue('select_file'))) {
$disp_error = "※ ディレクトリをダウンロードすることは出来ません。<br/>";
$objFileManager->sfDownloadFile($objFormParam->getValue('select_file'));
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$objFileManager->sfDeleteDir($objFormParam->getValue('select_file'));
$objFormParam = new SC_FormParam_Ex();
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$disp_error = "※ ". htmlspecialchars($objFormParam->getValue('create_file'), ENT_QUOTES). "の作成に失敗しました。<br/>";
$tpl_onload = "alert('フォルダを作成しました。');";
$ret = $objUpFile->makeTempFile('upload_file', false);
if (SC_Utils_Ex::isBlank($ret)) {
$tpl_onload = "alert('ファイルをアップロードしました。');";
$this->arrParam = $objFormParam->getHashArray();
// 現在の階層がルートディレクトリかどうかテンプレートに渡す
// 現在の階層より一つ上の階層をテンプレートに渡す
$this->arrFileList = $objFileManager->sfGetFileList($objFormParam->getValue('now_dir'));
// 現在の階層のディレクトリをテンプレートに渡す
$this->setDispParam('tpl_now_file', $objFormParam->getValue('now_dir'));
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
$objFormParam->addParam("選択ファイル", "select_file", MTEXT_LEN, 'a', array());
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
$objFormParam->addParam("選択ファイル", "select_file", MTEXT_LEN, 'a', array("SELECT_CHECK"));
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
$objFormParam->addParam("選択ファイル", "select_file", MTEXT_LEN, 'a', array());
$objFormParam->addParam("作成ファイル名", "create_file", MTEXT_LEN, 'a', array("EXIST_CHECK", "FILE_NAME_CHECK_BY_NOUPLOAD"));
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
$objFormParam->addParam("ルートディレクトリ", "top_dir", MTEXT_LEN, 'a', array());
$objFormParam->addParam("現在の階層ディレクトリ", "now_dir", MTEXT_LEN, 'a', array());
$objFormParam->addParam("現在の階層ファイル", "now_file", MTEXT_LEN, 'a', array());
$objFormParam->addParam("ツリー選択状態", "tree_status", MTEXT_LEN, 'a', array());
$objFormParam->addParam("ツリー選択ディレクトリ", "tree_select_file", MTEXT_LEN, 'a', array());
* @param object $objUpFile SC_UploadFileインスタンス
$objUpFile->addFile("ファイル", 'upload_file', array(), FILE_SIZE, true, 0, 0, false);
* @param array $_POST $_POST
* @return array $setParam テンプレートに渡す値
// Windowsの場合は, ディレクトリの区切り文字を\から/に変換する
$setParam['top_dir'] = (strpos(PHP_OS, 'WIN') === false) ? USER_REALDIR : str_replace('\\', '/', USER_REALDIR);
// 初期表示はルートディレクトリ(user_data/)を表示
if (SC_Utils_Ex::isBlank($this->getMode())) {
$setParam['now_dir'] = $setParam['top_dir'];
* @param object $objFileManager SC_Helper_FileManager_Exインスタンス
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
* @return boolean ディレクトリ作成できたかどうか
$create_dir = ereg_replace("/$", "", $objFormParam->getValue('now_dir'));
if($objFileManager->sfCreateFile($create_dir. "/". $objFormParam->getValue('create_file'), 0755)) {
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
* @return boolean ファイル表示するかどうか
$objFormParam->setValue('now_dir', $now_dir);
if (!strpos($objFormParam->getValue('select_file'), $objFormParam->getValue('top_dir'))) {
* 現在の階層の一つ上の階層のディレクトリをテンプレートに渡す
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
$parent_dir = $this->lfGetParentDir($objFormParam->getValue('now_dir'));
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
// Windows 環境で DIRECTORY_SEPARATOR が JavaScript に渡るとエスケープ文字と勘違いするので置換
$html_realdir = str_replace(DIRECTORY_SEPARATOR, '/', HTML_REALDIR);
$this->setDispParam('tpl_now_dir', SC_Utils_Ex::jsonEncode($arrNowDir));
* @param string $value エラー内容
if (SC_Utils_Ex::isBlank($this->arrErr[$key])) {
$this->arrErr[$key] = $value;
* @param string $tpl_onload javascript
$this->tpl_onload .= $tpl_onload;
* 選択ディレクトリがUSER_REALDIR以下かチェック
* @param object $objFormParam SC_FormParamインスタンス
* @param string $dir ディレクトリ
* @return string $select_dir 選択ディレクトリ
$top_dir = $objFormParam->getValue('top_dir');
if (preg_match("@^\Q". $top_dir. "\E@", $dir) > 0) {
// 相対パスがある場合、USER_REALDIRを返す.
// 相対パスがない場合、そのままディレクトリパスを返す.
// USER_REALDIR以下でない場合、USER_REALDIRを返す.
* @param string $dir 現在いるディレクトリ
* @return string $parent_dir 親ディレクトリ
foreach($arrDir as $val) {
* @param object $objFileManager SC_Helper_FileManager_Exインスタンス
* @param SC_FormParam $objFormParam SC_FormParamインスタンス
// ツリーを表示する divタグid, ツリー配列変数名, 現在ディレクトリ, 選択ツリーhidden名, ツリー状態hidden名, mode hidden名
$now_dir = $objFormParam->getValue('now_dir');
$treeView = "fnTreeView('tree', arrTree, '$now_dir', 'tree_select_file', 'tree_status', 'move');";
if (!empty($this->tpl_onload)) {
$tpl_onload .= $treeView;
$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']. ",";
$tpl_javascript .= "true);\n";
$tpl_javascript .= "false);\n";
* 現在の階層がルートディレクトリかどうかテンプレートに渡す
* @param object $objFormParam SC_FormParamインスタンス
$top_dir_check = ereg_replace("/$", "", $objFormParam->getValue('top_dir'));
$now_dir_check = ereg_replace("/$", "", $objFormParam->getValue('now_dir'));
if($top_dir_check == $now_dir_check) $is_top_dir = true;
Documentation generated on Fri, 24 Feb 2012 14:01:10 +0900 by Seasoft
|