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-2010 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_PATH . "pages/LC_Page.php");
require_once(DATA_PATH . "module/Tar.php");
require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_FileManager_Ex.php");
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Design_Template.php 18735 2010-06-22 08:53:31Z nanasess $
$this->tpl_subnavi = 'design/subnavi.tpl';
$this->tpl_subno = 'template';
$this->tpl_subtitle = 'テンプレート設定';
$this->arrForm = array();
$this->tpl_select = TEMPLATE_NAME;
ini_set("max_execution_time", 300);
$this->uniqid = $objSession->getUniqId();
if ($objForm->checkError()) {
SC_Utils_Ex::sfDispError('');
$template_code = $objForm->getValue('template_code');
$this->tpl_select = $template_code;
if($template_code == "") {
$template_code = "default";
// XXX コンパイルファイルのクリア処理を行う
$objView->_smarty->clear_compiled_tpl();
if ($objForm->checkError()) {
//現在使用中のテンプレートとデフォルトのテンプレートは削除できないようにする
$template_code = $objForm->getValue('template_code_temp');
if ($template_code == TEMPLATE_NAME || $template_code == DEFAULT_TEMPLATE_NAME) {
$this->tpl_onload = "alert('選択中のテンプレートは削除出来ません');";
$template_code = $objForm->getValue('template_code_temp');
$from_dir = USER_TEMPLATE_PATH . $template_code . "/";
$to_dir = SMARTY_TEMPLATES_DIR . $template_code . "/_packages/";
$this->now_template = TEMPLATE_NAME;
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
if (isset ($_POST['mode'])) return $_POST['mode'];
'template_code', 'template_code', STEXT_LEN, '',
array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK")
$objForm->setParam($_POST);
'template_code_temp', 'template_code_temp', STEXT_LEN, '',
array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK")
$objForm->setParam($_POST);
'template_code_temp', 'template_code_temp', STEXT_LEN, '',
array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK")
$objForm->setParam($_POST);
$sqlval['name'] = "\"" . $template_code . "\"";
$objQuery->update("mtb_constants", $sqlval, "id = ?", array('TEMPLATE_NAME'));
$masterData = new SC_DB_MasterData_Ex();
$mtb_constants = $masterData->getDBMasterData("mtb_constants");
$masterData->clearCache("mtb_constants");
$masterData->createCache("mtb_constants", $mtb_constants, true,
array("id", "remarks", "rank"));
$css_path = USER_PATH . "css/common.css";
$pt = '/(@import url\("\.\.\/packages\/.+\/css\/import\.css"\);)/';
$rp = '@import url("../packages/'. $template_code. '/css/import.css");';
$fp = fopen($css_path,"w");
$filepath = USER_TEMPLATE_PATH. $template_code. "/sql/update_bloc.sql";
if($fp = fopen($filepath, "r")) {
$sql_split = split(";", $sql);
foreach($sql_split as $key => $val){
$objQuery->delete('dtb_templates', 'template_code = ?', array($template_code));
$templates_dir = SMARTY_TEMPLATES_DIR. $template_code. "/";
SC_Utils_Ex::sfDelFile($templates_dir);
$templates_c_dir = DATA_PATH. "Smarty/templates_c/". $template_code. "/";
SC_Utils_Ex::sfDelFile($templates_c_dir);
$user_dir = USER_TEMPLATE_PATH. $template_code. "/";
SC_Utils_Ex::sfDelFile($user_dir);
$arrRet = $objQuery->select('*', 'dtb_templates');
if (empty($arrRet)) return array();
* テンプレート変更時に既に存在するキャンペーンのテンプレートがない場合はテンプレートを生成する
//すべてのキャンペーンのテンプレートファイルを確認
$sql = "SELECT directory_name,cart_flg FROM dtb_campaign WHERE del_flg = 0";
$result = $objQuery->getAll( $sql );
//デザインテンプレートディレクトリにファイルが存在するか確認
foreach( $result as $key => $val ){
//index.phpが存在すればキャンペーンのテンプレートがあると判定
$campaign_template_file_path = SMARTY_TEMPLATES_DIR. $template_code . "/". CAMPAIGN_TEMPLATE_DIR . $val['directory_name'] . "/" . CAMPAIGN_TEMPLATE_ACTIVE . "site_frame.tpl";
$this->lfCreateTemplate(SMARTY_TEMPLATES_DIR. $template_code . "/" . CAMPAIGN_TEMPLATE_DIR , $val['directory_name'],$val['cart_flg'] );
$objFileManager = new SC_Helper_FileManager_Ex();
$create_dir = $dir . $file;
$create_active_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE;
$create_end_dir = $create_dir . "/" . CAMPAIGN_TEMPLATE_END;
$default_dir = TEMPLATE_DIR . CAMPAIGN_TEMPLATE_DIR;
$default_active_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_ACTIVE;
$default_end_dir = $default_dir . "/" . CAMPAIGN_TEMPLATE_END;
$ret = $objFileManager->sfCreateFile($create_dir, 0755);
$ret = $objFileManager->sfCreateFile($create_active_dir, 0755);
$ret = $objFileManager->sfCreateFile($create_end_dir, 0755);
$ret = $objFileManager->sfCreateFile(CAMPAIGN_PATH . $file);
copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "index.php", CAMPAIGN_PATH . $file . "/index.php");
copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "application.php", CAMPAIGN_PATH . $file . "/application.php");
copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "complete.php", CAMPAIGN_PATH . $file . "/complete.php");
copy(HTML_PATH . CAMPAIGN_TEMPLATE_DIR . "entry.php", CAMPAIGN_PATH . $file . "/entry.php");
// デフォルトテンプレート作成(キャンペーン中)
SC_Utils_Ex::sfWriteFile($header, $create_active_dir. "header.tpl", "w");
$contents .= "\n" . '<!--{*ログインフォーム*}-->' . "\n";
$contents .= '<!--{*会員登録フォーム*}-->'. "\n";
SC_Utils_Ex::sfWriteFile($contents, $create_active_dir. "contents.tpl", "w");
SC_Utils_Ex::sfWriteFile($footer, $create_active_dir. "footer.tpl", "w");
$site_frame = $header. "\n";
$site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/navi.js"></script>'. "\n";
$site_frame .= '<script type="text/javascript" src="<!--{$TPL_DIR}-->js/site.js"></script>'. "\n";
$site_frame .= '<!--{include file=$tpl_mainpage}-->'. "\n";
$site_frame .= $footer. "\n";
SC_Utils_Ex::sfWriteFile($site_frame, $create_active_dir. "site_frame.tpl", "w");
/* デフォルトテンプレート作成(キャンペーン終了) */
SC_Utils_Ex::sfWriteFile($header, $create_end_dir. "header.tpl", "w");
SC_Utils_Ex::sfWriteFile($contents, $create_end_dir. "contents.tpl", "w");
SC_Utils_Ex::sfWriteFile($footer, $create_end_dir. "footer.tpl", "w");
* 関数名:lfGetFileContents()
Documentation generated on Fri, 24 Feb 2012 13:58:44 +0900 by Seasoft
|