Source for file LC_Page_Admin_Design_Bloc.php
Documentation is available at LC_Page_Admin_Design_Bloc.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_Design_Bloc.php 21185 2011-08-11 10:37:10Z shutta $
$this->tpl_mainpage = 'design/bloc.tpl';
$this->tpl_subno_edit = 'bloc';
$this->tpl_subno = 'bloc';
$this->tpl_mainno = 'design';
$this->tpl_maintitle = 'デザイン管理';
$this->tpl_subtitle = 'ブロック設定';
$masterData = new SC_DB_MasterData_Ex();
$this->arrDeviceType = $masterData->getMasterData('mtb_device_type');
$objFormParam = new SC_FormParam_Ex();
$objFormParam->setParam($_REQUEST);
$objFormParam->convParam();
$this->arrErr = $objFormParam->checkError();
$is_error = (!SC_Utils_Ex::isBlank($this->arrErr));
$this->bloc_id = $objFormParam->getValue('bloc_id');
$this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC);
$objLayout = new SC_Helper_PageLayout_Ex();
switch($this->getMode()) {
$this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objLayout);
if (SC_Utils_Ex::isBlank($this->arrErr)) {
$result = $this->doRegister($objFormParam, $objLayout);
SC_Response_Ex::reload(array('bloc_id' => $result,
'device_type_id' => $this->device_type_id,
if ($this->doDelete($objFormParam, $objLayout)) {
SC_Response_Ex::reload(array('device_type_id' => $this->device_type_id,
if (isset ($_GET['msg']) && $_GET['msg'] == 'on') {
$this->tpl_onload = "alert('登録が完了しました。');";
$this->arrBlocList = $objLayout->getBlocs($this->device_type_id);
// bloc_id が指定されている場合にはブロックデータの取得
if (!SC_Utils_Ex::isBlank($this->bloc_id)) {
$arrBloc = $this->getBlocTemplate($this->device_type_id, $this->bloc_id, $objLayout);
$objFormParam->setParam($arrBloc);
GC_Utils_Ex::gfPrintLog('Error: ' . print_r($this->arrErr, true));
$this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle;
$this->arrForm = $objFormParam->getFormParamList();
* @param object $objFormParam SC_FormParamインスタンス
$objFormParam->addParam("ブロックID", "bloc_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("端末種別ID", "device_type_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("ブロック名", "bloc_name", STEXT_LEN, 'KVa', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("ファイル名", "filename", STEXT_LEN, 'a', array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
$objFormParam->addParam("ブロックデータ", "bloc_html");
* @param integer $device_type_id 端末種別ID
* @param integer $bloc_id ブロックID
* @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
* @return array ブロック情報の配列
$arrBloc = $objLayout->getBlocs($device_type_id, 'bloc_id = ?', array($bloc_id));
if (SC_Utils_Ex::isAbsoluteRealPath($arrBloc[0]['tpl_path'])) {
$tpl_path = $arrBloc[0]['tpl_path'];
$tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id) . BLOC_DIR . $arrBloc[0]['tpl_path'];
* ファイルの作成に失敗した場合は, エラーメッセージを出力し,
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
* @return integer|boolean登録が成功した場合, 登録したブロックID;
function doRegister(&$objFormParam, &$objLayout) {
$arrParams = $objFormParam->getHashArray();
$objQuery = & SC_Query_Ex::getSingletonInstance();
$is_new = SC_Utils_Ex::isBlank($arrParams['bloc_id']);
$bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR;
$arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ?', array($arrParams['bloc_id']));
$exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
$arrValues = $objQuery->extractOnlyColsOf($table, $arrParams);
$arrValues['tpl_path'] = $arrParams['filename'] . '.tpl';
$arrValues['update_date'] = 'CURRENT_TIMESTAMP';
if ($is_new || SC_Utils_Ex::isBlank($arrExists)) {
$arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?',
array($arrValues['device_type_id']));
$arrValues['create_date'] = 'CURRENT_TIMESTAMP';
$objQuery->insert($table, $arrValues);
$objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?',
array($arrValues['bloc_id'], $arrValues['device_type_id']));
$bloc_path = $bloc_dir . $arrValues['tpl_path'];
if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $arrParams['bloc_html'])) {
$this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />';
return $arrValues['bloc_id'];
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
* @return boolean 登録が成功した場合 true; 失敗した場合 false
function doDelete(&$objFormParam, &$objLayout) {
$arrParams = $objFormParam->getHashArray();
$objQuery = & SC_Query_Ex::getSingletonInstance();
$arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ? AND deletable_flg = 1',
array($arrParams['bloc_id']));
if (!SC_Utils_Ex::isBlank($arrExists)) {
$objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?',
array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
$objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?',
array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
$bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR;
$exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
$this->arrErr['err'] = '※ ブロックの削除に失敗しました<br />';
* @param SC_FormParam $objFormParam SC_FormParam インスタンス
* @return array エラーメッセージの配列
function lfCheckError(&$objFormParam, &$arrErr, &$objLayout) {
$arrParams = $objFormParam->getHashArray();
$objErr = new SC_CheckError_Ex($arrParams);
$objErr->arrErr = & $arrErr;
$objErr->doFunc(array("ブロック名", "bloc_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
$objErr->doFunc(array('ファイル名', 'filename', STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK","FILE_NAME_CHECK_BY_NOUPLOAD"));
$arrValues = array($arrParams['filename']);
if (!SC_Utils_Ex::isBlank($arrParams['bloc_id'])) {
$where .= ' AND bloc_id <> ?';
$arrValues[] = $arrParams['bloc_id'];
$arrBloc = $objLayout->getBlocs($arrParams['device_type_id'], $where, $arrValues);
if (!SC_Utils_Ex::isBlank($arrBloc)) {
$objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。<br />';
Documentation generated on Fri, 24 Feb 2012 14:01:15 +0900 by Seasoft
|