Source for file LC_Page_Admin_Design_Template.php
Documentation is available at LC_Page_Admin_Design_Template.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_Template.php 20970 2011-06-10 10:27:24Z Seasoft $
$this->tpl_mainpage = 'design/template.tpl';
$this->tpl_subno = 'template';
$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);
$template_code = $objFormParam->getValue('template_code');
switch($this->getMode()) {
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
if ($this->doRegister($template_code, $this->device_type_id)) {
$this->tpl_select = $template_code;
$this->tpl_onload = "alert('登録が完了しました。');";
if ($objFormParam->checkError()) {
SC_Utils_Ex::sfDispError('');
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
if ($this->doDelete($template_code, $this->device_type_id)) {
$this->tpl_onload = "alert('削除が完了しました。');";
$this->arrErr = $objFormParam->checkError();
if (SC_Utils_Ex::isBlank($this->arrErr)) {
if ($this->doDownload($template_code) !== false) {
GC_Utils_Ex::gfPrintLog('Error: ' . print_r($this->arrErr, true));
$this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle;
* @param object $objFormParam SC_FormParamインスタンス
$objFormParam->addParam("端末種別ID", "device_type_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam('template_code', 'template_code', STEXT_LEN, 'a', array("EXIST_CHECK", "SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK"));
* @param string $template_code テンプレートコード
* @param integer $device_type_id 端末種別ID
$masterData = new SC_DB_MasterData_Ex();
$defineName = 'TEMPLATE_NAME';
switch ($device_type_id) {
$defineName = 'MOBILE_' . $defineName;
case DEVICE_TYPE_SMARTPHONE:
$defineName = 'SMARTPHONE_' . $defineName;
$arrData = array($defineName => var_export($template_code, true));
$masterData->updateMasterData('mtb_constants', array(), $arrData);
$masterData->createCache('mtb_constants', array(), true, array('id', 'remarks'));
* この SQL は, 各端末に合わせて実行する必要がある
* @param string $filepath SQLのファイルパス
$objQuery = & SC_Query_Ex::getSingletonInstance();
foreach($sql_split as $val){
* @param string $template_code テンプレートコード
* @param integer $device_type_id 端末種別ID
* @return boolean 成功した場合 true; 失敗した場合 false
function doDelete($template_code, $device_type_id) {
$this->arrErr['err'] = "※ デフォルトテンプレートと、選択中のテンプレートは削除出来ません<br />";
$objQuery = & SC_Query_Ex::getSingletonInstance();
$objQuery->delete('dtb_templates', 'template_code = ? AND device_type_id = ?',
array($template_code, $device_type_id));
$error = "※ テンプレートの削除ができませんでした<br />";
$templates_dir = SMARTY_TEMPLATES_REALDIR . $template_code. "/";
if (SC_Utils_Ex::sfDelFile($templates_dir) === false) {
$this->arrErr['err'] = $error;
$user_dir = USER_TEMPLATE_REALDIR. $template_code. "/";
if (SC_Utils_Ex::sfDelFile($user_dir) === false) {
$this->arrErr['err'] = $error;
$templates_c_dir = DATA_REALDIR. "Smarty/templates_c/". $template_code. "/";
if (SC_Utils_Ex::sfDelFile($templates_c_dir) === false) {
$this->arrErr['err'] = $error;
* 失敗した場合は, エラーメッセージを出力し, false を返す.
* @param string $template_code テンプレートコード
* @param integer $device_type_id 端末種別ID
* @return boolean 成功した場合 true; 失敗した場合 false
function doRegister($template_code, $device_type_id) {
$tpl_dir = USER_TEMPLATE_REALDIR . $template_code . '/';
$this->arrErr['err'] = '※ ' . $tpl_dir . 'が見つかりません<br />';
// 更新SQLファイルが存在する場合はブロック位置を更新
$sql_file = $tpl_dir . "sql/update_bloc.sql";
$objView = new SC_AdminView_Ex();
$objView->_smarty->clear_compiled_tpl();
* 指定のテンプレートをアーカイブし, ブラウザに出力する.
* 失敗した場合は, エラーメッセージを出力し, false を返す.
* @param string $template_code テンプレートコード
* @return boolean 成功した場合 true; 失敗した場合 false
$from_dir = USER_TEMPLATE_REALDIR . $template_code . "/";
$to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . "/_packages/";
if (SC_Utils_Ex::recursiveMkdir($to_dir) === false) {
$this->arrErr['err'] = '※ ディレクトリの作成に失敗しました<br />';
SC_Utils_Ex::sfCopyDir($from_dir, $to_dir);
if (SC_Helper_FileManager_Ex::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code, $template_code) === false) {
$this->arrErr['err'] = '※ アーカイブファイルの作成に失敗しました<br />';
* @param integer $device_type_id 端末種別ID
* @return array テンプレート情報の配列
$objQuery = & SC_Query_Ex::getSingletonInstance();
return $objQuery->select('*', 'dtb_templates', "device_type_id = ?", array($device_type_id));
* @param integer $device_type_id 端末種別ID
* @param boolean $isDefault デフォルトテンプレート名を返す場合 true
switch ($device_type_id) {
return $isDefault ? MOBILE_DEFAULT_TEMPLATE_NAME : MOBILE_TEMPLATE_NAME;
case DEVICE_TYPE_SMARTPHONE:
return $isDefault ? SMARTPHONE_DEFAULT_TEMPLATE_NAME : SMARTPHONE_TEMPLATE_NAME;
return $isDefault ? DEFAULT_TEMPLATE_NAME : TEMPLATE_NAME;
Documentation generated on Fri, 24 Feb 2012 14:01:19 +0900 by Seasoft
|