Source for file LC_Page_Admin_Design_UpDown.php
Documentation is available at LC_Page_Admin_Design_UpDown.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 DATA_REALDIR. 'module/Tar.php';
require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_FileManager_Ex.php';
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Design_UpDown.php 21185 2011-08-11 10:37:10Z shutta $
$this->tpl_mainpage = 'design/up_down.tpl';
$this->tpl_subno = 'up_down';
$this->tpl_mainno = 'design';
$this->tpl_maintitle = 'デザイン管理';
$this->tpl_subtitle = 'テンプレート追加';
$this->arrForm = array();
ini_set("max_execution_time", 300);
$masterData = new SC_DB_MasterData_Ex();
$this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
$objFormParam = new SC_FormParam_Ex();
$objFormParam->setParam($_REQUEST);
$objFormParam->convParam();
$this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC);
switch($this->getMode()) {
$this->arrErr = $this->lfCheckError($objFormParam, $objUpFile);
if (SC_Utils_Ex::isBlank($this->arrErr)) {
if ($this->doUpload($objFormParam, $objUpFile)) {
$this->tpl_onload = "alert('テンプレートファイルをアップロードしました。');";
$objFormParam->setValue('template_name', '');
$objFormParam->setValue('template_code', '');
$this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle;
$this->arrForm = $objFormParam->getFormParamList();
* @param object $objForm SC_FormParamのインスタンス
* @return object SC_UploadFileのインスタンス
$pkg_dir = SMARTY_TEMPLATES_REALDIR . $objForm->getValue('template_code');
$objUpFile = new SC_UploadFile_Ex(TEMPLATE_TEMP_REALDIR, $pkg_dir);
$objUpFile->addFile("テンプレートファイル", 'template_file', array(), TEMPLATE_SIZE, true, 0, 0, false);
* @param SC_FormParam $objFormParam SC_FormParamのインスタンス
$objFormParam->addParam("テンプレートコード", "template_code", STEXT_LEN, 'a', array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK"));
$objFormParam->addParam("テンプレート名", "template_name", STEXT_LEN, 'KVa', array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK"));
$objFormParam->addParam("端末種別ID", "device_type_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
* @param object $objFormParam SC_FormParamのインスタンス
* @param object $objUpFile SC_UploadFileのインスタンス
* @return array エラー情報を格納した連想配列, エラーが無ければ(多分)nullを返す
$arrErr = $objFormParam->checkError();
$template_code = $objFormParam->getValue('template_code');
if (file_exists(USER_TEMPLATE_REALDIR . $template_code)) {
$arrErr['template_code'] = "※ 同名のファイルがすでに存在します。<br/>";
$arrIgnoreCode = array('admin',
MOBILE_DEFAULT_TEMPLATE_NAME,
SMARTPHONE_DEFAULT_TEMPLATE_NAME,
if (in_array($template_code, $arrIgnoreCode)) {
$arrErr['template_code'] = "※ このテンプレートコードは使用できません。<br/>";
$objQuery = & SC_Query_Ex::getSingletonInstance();
$count = $objQuery->count("dtb_templates", "template_code = ?", array($template_code));
$arrErr['template_code'] = "※ すでに登録されているテンプレートコードです。<br/>";
* ファイルが壊れていることも考慮して, 展開可能かチェックする.
$tar = new Archive_Tar($_FILES['template_file']['tmp_name'], true);
$arrArchive = $tar->listContent();
$arrErr['template_file'] = "※ テンプレートファイルが解凍できません。許可されている形式は、tar/tar.gzです。<br />";
$make_temp_error = $objUpFile->makeTempFile('template_file', false);
if (!SC_Utils_Ex::isBlank($make_temp_error)) {
$arrErr['template_file'] = $make_temp_error;
* DBおよびファイルシステムにテンプレートパッケージを追加する.
* エラーが発生した場合は, エラーを出力し, false を返す.
* @param object $objFormParam SC_FormParamのインスタンス
* @param object $objUpFile SC_UploadFileのインスタンス
* @return boolean 成功した場合 true; 失敗した場合 false
function doUpload($objFormParam, $objUpFile) {
$template_code = $objFormParam->getValue('template_code');
$template_name = $objFormParam->getValue('template_name');
$device_type_id = $objFormParam->getValue('device_type_id');
$template_dir = SMARTY_TEMPLATES_REALDIR . $template_code;
$compile_dir = DATA_REALDIR . "Smarty/templates_c/" . $template_code;
$objQuery = & SC_Query_Ex::getSingletonInstance();
$arrValues = array('template_code' => $template_code,
'device_type_id' => $device_type_id,
'template_name' => $template_name,
'create_date' => 'CURRENT_TIMESTAMP',
'update_date' => 'CURRENT_TIMESTAMP');
$objQuery->insert('dtb_templates', $arrValues);
if (!mkdir($template_dir)) {
$this->arrErr['err'] = "※ テンプレートフォルダが作成できませんでした。<br/>";
if (!mkdir($compile_dir)) {
$this->arrErr['err'] = "※ Smarty コンパイルフォルダが作成できませんでした。<br/>";
$objUpFile->moveTempFile();
if (!SC_Helper_FileManager_Ex::unpackFile($template_dir . "/" . $_FILES['template_file']['name'])) {
$this->arrErr['err'] = "※ テンプレートファイルの解凍に失敗しました。<br/>";
$from_dir = SMARTY_TEMPLATES_REALDIR . $template_code . "/_packages/";
$to_dir = USER_REALDIR . "packages/" . $template_code . "/";
if (!SC_Utils_Ex::recursiveMkdir($to_dir)) {
$this->arrErr['err'] = "※ " . $to_dir . " の作成に失敗しました。<br/>";
SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
Documentation generated on Fri, 24 Feb 2012 14:01:19 +0900 by Seasoft
|