[15688] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[21867] | 5 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15688] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
[15688] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15688] | 26 | |
---|
| 27 | /** |
---|
| 28 | * ヘッダ, フッタ編集 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20345] | 34 | class LC_Page_Admin_Design_Header extends LC_Page_Admin_Ex { |
---|
[15688] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_mainpage = 'design/header.tpl'; |
---|
| 47 | $this->header_row = 13; |
---|
| 48 | $this->footer_row = 13; |
---|
[20538] | 49 | $this->tpl_subno = 'header'; |
---|
| 50 | $this->tpl_mainno = 'design'; |
---|
[22100] | 51 | $this->tpl_maintitle = t('TPL_MAINTITLE_003'); |
---|
| 52 | $this->tpl_subtitle = t('LC_Page_Admin_Design_Header_002'); |
---|
[20560] | 53 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 54 | $this->arrDeviceType = $masterData->getMasterData('mtb_device_type'); |
---|
[15688] | 55 | } |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | * Page のプロセス. |
---|
| 59 | * |
---|
| 60 | * @return void |
---|
| 61 | */ |
---|
| 62 | function process() { |
---|
[19661] | 63 | $this->action(); |
---|
| 64 | $this->sendResponse(); |
---|
| 65 | } |
---|
[15688] | 66 | |
---|
[19661] | 67 | /** |
---|
| 68 | * Page のアクション. |
---|
| 69 | * |
---|
| 70 | * @return void |
---|
| 71 | */ |
---|
| 72 | function action() { |
---|
[21591] | 73 | |
---|
[20859] | 74 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 75 | $this->lfInitParam($objFormParam); |
---|
| 76 | $objFormParam->setParam($_REQUEST); |
---|
| 77 | $objFormParam->convParam(); |
---|
| 78 | $this->arrErr = $objFormParam->checkError(); |
---|
| 79 | $is_error = (!SC_Utils_Ex::isBlank($this->arrErr)); |
---|
[19725] | 80 | |
---|
[20859] | 81 | $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC); |
---|
[20560] | 82 | |
---|
[20859] | 83 | switch ($this->getMode()) { |
---|
[21526] | 84 | // 登録 |
---|
| 85 | case 'regist': |
---|
| 86 | $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr); |
---|
| 87 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 88 | if ($this->doRegister($objFormParam)) { |
---|
[22100] | 89 | $this->tpl_onload = "alert('" . t('ALERT_004') . "');"; |
---|
[21526] | 90 | } |
---|
[20860] | 91 | } |
---|
[21526] | 92 | break; |
---|
[15688] | 93 | |
---|
[21526] | 94 | default: |
---|
| 95 | break; |
---|
[20859] | 96 | } |
---|
[15688] | 97 | |
---|
[20859] | 98 | if (!$is_error) { |
---|
| 99 | // テキストエリアに表示 |
---|
| 100 | $header_path = $this->getTemplatePath($this->device_type_id, 'header'); |
---|
| 101 | $footer_path = $this->getTemplatePath($this->device_type_id, 'footer'); |
---|
| 102 | if ($header_path === false || $footer_path === false) { |
---|
[22100] | 103 | $this->arrErr['err'] = t('LC_Page_Admin_Design_Header_003'); |
---|
[20859] | 104 | } else { |
---|
| 105 | $this->header_data = file_get_contents($header_path); |
---|
| 106 | $this->footer_data = file_get_contents($footer_path); |
---|
[15688] | 107 | } |
---|
[20859] | 108 | } else { |
---|
| 109 | // 画面にエラー表示しないため, ログ出力 |
---|
| 110 | GC_Utils_Ex::gfPrintLog('Error: ' . print_r($this->arrErr, true)); |
---|
[15688] | 111 | } |
---|
| 112 | |
---|
[20859] | 113 | //サブタイトルの追加 |
---|
[20911] | 114 | $this->tpl_subtitle = $this->arrDeviceType[$this->device_type_id] . '>' . $this->tpl_subtitle; |
---|
[21591] | 115 | |
---|
[20859] | 116 | } |
---|
[15688] | 117 | |
---|
[20859] | 118 | /** |
---|
| 119 | * デストラクタ. |
---|
| 120 | * |
---|
| 121 | * @return void |
---|
| 122 | */ |
---|
| 123 | function destroy() { |
---|
| 124 | parent::destroy(); |
---|
[20275] | 125 | } |
---|
[15688] | 126 | |
---|
[20859] | 127 | /** |
---|
[20970] | 128 | * パラメーター情報の初期化 |
---|
[20859] | 129 | * |
---|
| 130 | * @param object $objFormParam SC_FormParamインスタンス |
---|
| 131 | * @return void |
---|
| 132 | */ |
---|
| 133 | function lfInitParam(&$objFormParam) { |
---|
[22100] | 134 | $objFormParam->addParam(t('PARAM_LABEL_DEVICE_TYPE_ID'), 'device_type_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 135 | $objFormParam->addParam(t('PARAM_LABEL_DIVISION_ALP'), 'division', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK')); |
---|
| 136 | $objFormParam->addParam(t('PARAM_LABEL_HEADER_DATA'), 'header'); |
---|
| 137 | $objFormParam->addParam(t('PARAM_LABEL_FOOTER_DATA'), 'footer'); |
---|
[15688] | 138 | } |
---|
| 139 | |
---|
[20859] | 140 | /** |
---|
| 141 | * エラーチェックを行う. |
---|
| 142 | * |
---|
| 143 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 144 | * @return array エラーメッセージの配列 |
---|
| 145 | */ |
---|
[20860] | 146 | function lfCheckError(&$objFormParam, &$arrErr) { |
---|
[20859] | 147 | $arrParams = $objFormParam->getHashArray(); |
---|
| 148 | $objErr = new SC_CheckError_Ex($arrParams); |
---|
| 149 | $objErr->arrErr =& $arrErr; |
---|
[22100] | 150 | $objErr->doFunc(array(t('PARAM_LABEL_DIVISION_ALP'), 'division', STEXT_LEN), array('EXIST_CHECK')); |
---|
[20859] | 151 | return $objErr->arrErr; |
---|
[20275] | 152 | } |
---|
| 153 | |
---|
[15688] | 154 | /** |
---|
[20859] | 155 | * 登録を実行する. |
---|
[15688] | 156 | * |
---|
[20859] | 157 | * ファイルの作成に失敗した場合は, エラーメッセージを出力する. |
---|
| 158 | * |
---|
| 159 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 160 | * @return integer|boolean 登録が成功した場合 true; 失敗した場合 false |
---|
[15688] | 161 | */ |
---|
[20859] | 162 | function doRegister(&$objFormParam) { |
---|
| 163 | $division = $objFormParam->getValue('division'); |
---|
| 164 | $contents = $objFormParam->getValue($division); |
---|
| 165 | $tpl_path = $this->getTemplatePath($objFormParam->getValue('device_type_id'), $division); |
---|
| 166 | if ($tpl_path === false |
---|
| 167 | || !SC_Helper_FileManager_Ex::sfWriteFile($tpl_path, $contents)) { |
---|
[22100] | 168 | $this->arrErr['err'] = t('LC_Page_Admin_Design_Header_004'); |
---|
[20859] | 169 | return false; |
---|
| 170 | } |
---|
| 171 | return true; |
---|
[15688] | 172 | } |
---|
[20859] | 173 | |
---|
| 174 | /** |
---|
| 175 | * テンプレートパスを取得する. |
---|
| 176 | * |
---|
| 177 | * @param integer $device_type_id 端末種別ID |
---|
[21481] | 178 | * @param string $division 'header' or 'footer' |
---|
[20859] | 179 | * @return string|boolean 成功した場合, テンプレートのパス; 失敗した場合 false |
---|
| 180 | */ |
---|
| 181 | function getTemplatePath($device_type_id, $division) { |
---|
| 182 | $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id) . '/' . $division . '.tpl'; |
---|
| 183 | if (file_exists($tpl_path)) { |
---|
| 184 | return $tpl_path; |
---|
| 185 | } else { |
---|
| 186 | return false; |
---|
| 187 | } |
---|
| 188 | } |
---|
[15688] | 189 | } |
---|