1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
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. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_PATH . "pages/admin/LC_Page_Admin.php"); |
---|
26 | |
---|
27 | /** ターゲットID 未使用 */ |
---|
28 | define('TARGET_ID_UNUSED', 0); |
---|
29 | |
---|
30 | /** |
---|
31 | * デザイン管理 のページクラス. |
---|
32 | * |
---|
33 | * ターゲットID 0:未使用 1:レフトナビ 2:ライトナビ 3:イン画面上部 4:メイン画面下部 5:画面上部 6:画面下部 7:ヘッダより上 8:フッタより下 9:HEADタグ内 10:ヘッダ内部 |
---|
34 | * @package Page |
---|
35 | * @author LOCKON CO.,LTD. |
---|
36 | * @version $Id$ |
---|
37 | */ |
---|
38 | class LC_Page_Admin_Design extends LC_Page_Admin { |
---|
39 | |
---|
40 | // }}} |
---|
41 | // {{{ functions |
---|
42 | |
---|
43 | /** |
---|
44 | * Page を初期化する. |
---|
45 | * |
---|
46 | * @return void |
---|
47 | */ |
---|
48 | function init() { |
---|
49 | parent::init(); |
---|
50 | $this->tpl_mainpage = 'design/index.tpl'; |
---|
51 | $this->tpl_subnavi = 'design/subnavi.tpl'; |
---|
52 | $this->tpl_subno = "layout"; |
---|
53 | $this->tpl_mainno = "design"; |
---|
54 | $this->tpl_subtitle = 'レイアウト編集'; |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Page のプロセス. |
---|
59 | * |
---|
60 | * @return void |
---|
61 | */ |
---|
62 | function process() { |
---|
63 | $this->action(); |
---|
64 | $this->sendResponse(); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * Page のアクション. |
---|
69 | * |
---|
70 | * @return void |
---|
71 | */ |
---|
72 | function action() { |
---|
73 | $objSess = new SC_Session(); |
---|
74 | $objLayout = new SC_Helper_PageLayout_Ex(); |
---|
75 | |
---|
76 | // 認証可否の判定 |
---|
77 | $objSess = new SC_Session(); |
---|
78 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
79 | |
---|
80 | // ページIDを取得 |
---|
81 | if (isset($_GET['page_id'])) { |
---|
82 | $page_id = $_GET['page_id']; |
---|
83 | }else if (isset($_POST['page_id'])){ |
---|
84 | $page_id = $_POST['page_id']; |
---|
85 | }else{ |
---|
86 | $page_id = 1; |
---|
87 | } |
---|
88 | |
---|
89 | // 編集可能ページを取得 |
---|
90 | $this->arrEditPage = $objLayout->lfgetPageData(); |
---|
91 | |
---|
92 | // ブロック配置用データを取得 |
---|
93 | $sel = ", pos.target_id, pos.bloc_id, pos.bloc_row ,pos.anywhere"; |
---|
94 | $from = ", dtb_blocposition AS pos"; |
---|
95 | $where = " where "; |
---|
96 | $where .= "( pos.anywhere = 1 OR (lay.page_id = ? AND "; |
---|
97 | $where .= "lay.page_id = pos.page_id AND exists (select bloc_id from dtb_bloc as blc where pos.bloc_id = blc.bloc_id) )) ORDER BY lay.page_id,pos.target_id, pos.bloc_row, pos.bloc_id "; |
---|
98 | // $where .= "((lay.page_id = ? AND "; |
---|
99 | // $where .= "lay.page_id = pos.page_id AND exists (select bloc_id from dtb_bloc as blc where pos.bloc_id = blc.bloc_id) )) ORDER BY lay.page_id,pos.target_id, pos.bloc_row, pos.bloc_id "; |
---|
100 | |
---|
101 | $arrData = array($page_id); |
---|
102 | $arrBlocPos = $this->lfgetLayoutData($sel, $from, $where, $arrData ); |
---|
103 | |
---|
104 | // データの存在チェックを行う |
---|
105 | $arrPageData = $objLayout->lfgetPageData("page_id = ?", array($page_id)); |
---|
106 | if (count($arrPageData) <= 0) { |
---|
107 | $exists_page = 0; |
---|
108 | }else{ |
---|
109 | $exists_page = 1; |
---|
110 | } |
---|
111 | $this->exists_page = $exists_page; |
---|
112 | |
---|
113 | // メッセージ表示 |
---|
114 | if (isset($_GET['msg']) && $_GET['msg'] == "on") { |
---|
115 | $this->complate_msg="alert('登録が完了しました。');"; |
---|
116 | } |
---|
117 | |
---|
118 | // ブロックを取得 |
---|
119 | $arrBloc = $this->lfgetBlocData(); |
---|
120 | |
---|
121 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
122 | |
---|
123 | // 新規ブロック作成 |
---|
124 | if ($_POST['mode'] == 'new_bloc') { |
---|
125 | $this->objDisplay->redirect($this->getLocation("./bloc.php")); |
---|
126 | exit; |
---|
127 | } |
---|
128 | |
---|
129 | // 新規ページ作成 |
---|
130 | if ($_POST['mode'] == 'new_page') { |
---|
131 | $this->objDisplay->redirect($this->getLocation("./main_edit.php")); |
---|
132 | exit; |
---|
133 | } |
---|
134 | |
---|
135 | // データ登録処理 |
---|
136 | if ($_POST['mode'] == 'confirm' or $_POST['mode'] == 'preview') { |
---|
137 | $page_id = $_POST['page_id']; |
---|
138 | if ($_POST['mode'] == 'preview') { |
---|
139 | $page_id = '0'; |
---|
140 | } |
---|
141 | $masterData = new SC_DB_MasterData_Ex(); |
---|
142 | $arrTarget = $masterData->getMasterData("mtb_target"); |
---|
143 | |
---|
144 | // 更新用にデータを整える |
---|
145 | $arrUpdBlocData = array(); |
---|
146 | $arrTargetFlip = array_flip($arrTarget); |
---|
147 | |
---|
148 | $upd_cnt = 1; |
---|
149 | $arrUpdData[$upd_cnt]['page_id'] = $page_id; |
---|
150 | |
---|
151 | // POSTのデータを使いやすいように修正 |
---|
152 | for($upd_cnt = 1; $upd_cnt <= $_POST['bloc_cnt']; $upd_cnt++){ |
---|
153 | if (!isset($_POST['id_'.$upd_cnt])) { |
---|
154 | break; |
---|
155 | } |
---|
156 | $arrUpdBlocData[$upd_cnt]['name'] = $_POST['name_'.$upd_cnt]; // ブロック名称 |
---|
157 | $arrUpdBlocData[$upd_cnt]['id'] = $_POST['id_'.$upd_cnt]; // ブロックID |
---|
158 | $arrUpdBlocData[$upd_cnt]['target_id'] = $arrTargetFlip[$_POST['target_id_'.$upd_cnt]]; // ターゲットID |
---|
159 | $arrUpdBlocData[$upd_cnt]['top'] = $_POST['top_'.$upd_cnt]; // TOP座標 |
---|
160 | $arrUpdBlocData[$upd_cnt]['anywhere'] = $_POST['anywhere_'.$upd_cnt]; // 全ページ適用か |
---|
161 | $arrUpdBlocData[$upd_cnt]['update_url'] = $_SERVER['HTTP_REFERER']; // 更新URL |
---|
162 | |
---|
163 | } |
---|
164 | |
---|
165 | // データの更新を行う |
---|
166 | $objQuery = new SC_Query(); // DB操作オブジェクト |
---|
167 | $arrRet = array(); // データ取得用 |
---|
168 | |
---|
169 | // delete実行 |
---|
170 | $del_sql = ""; |
---|
171 | $del_sql .= "DELETE FROM dtb_blocposition WHERE page_id = ? "; |
---|
172 | $arrRet = $objQuery->query($del_sql,array($page_id)); |
---|
173 | |
---|
174 | // ブロックの順序を取得し、更新を行う |
---|
175 | foreach($arrUpdBlocData as $key => $val){ |
---|
176 | if ($arrUpdBlocData[$key]['target_id'] == TARGET_ID_UNUSED) { |
---|
177 | continue; |
---|
178 | } |
---|
179 | |
---|
180 | // ブロックの順序を取得 |
---|
181 | $bloc_row = $this->lfGetRowID($arrUpdBlocData, $val); |
---|
182 | $arrUpdBlocData[$key]['bloc_row'] = $bloc_row; |
---|
183 | $arrUpdBlocData[$key]['page_id'] = $page_id; // ページID |
---|
184 | |
---|
185 | // insert文生成 |
---|
186 | $ins_sql = ""; |
---|
187 | $ins_sql .= "INSERT INTO dtb_blocposition "; |
---|
188 | $ins_sql .= " values ( "; |
---|
189 | $ins_sql .= " ? "; // ページID |
---|
190 | $ins_sql .= " ,? "; // ターゲットID |
---|
191 | $ins_sql .= " ,? "; // ブロックID |
---|
192 | $ins_sql .= " ,? "; // ブロックの並び順序 |
---|
193 | $ins_sql .= " ,(SELECT filename FROM dtb_bloc WHERE bloc_id = ?) "; // ファイル名称 |
---|
194 | $ins_sql .= " ,? "; // 全ページフラグ |
---|
195 | $ins_sql .= " ) "; |
---|
196 | |
---|
197 | // insertデータ生成 |
---|
198 | $arrInsData = array($page_id, |
---|
199 | $arrUpdBlocData[$key]['target_id'], |
---|
200 | $arrUpdBlocData[$key]['id'], |
---|
201 | $arrUpdBlocData[$key]['bloc_row'], |
---|
202 | $arrUpdBlocData[$key]['id'], |
---|
203 | $arrUpdBlocData[$key]['anywhere'] ? 1 : 0 |
---|
204 | ); |
---|
205 | $count = $objQuery->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); |
---|
206 | |
---|
207 | if($arrUpdBlocData[$key]['anywhere'] == 1){ |
---|
208 | $count = $objQuery->getOne("SELECT COUNT(*) FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); |
---|
209 | if($count != 0){ |
---|
210 | continue; |
---|
211 | }else{ |
---|
212 | } |
---|
213 | }else{ |
---|
214 | if($count > 0){ |
---|
215 | $objQuery->query("DELETE FROM dtb_blocposition WHERE anywhere = 1 AND bloc_id = ?",array($arrUpdBlocData[$key]['id'])); |
---|
216 | } |
---|
217 | } |
---|
218 | // SQL実行 |
---|
219 | $arrRet = $objQuery->query($ins_sql,$arrInsData); |
---|
220 | } |
---|
221 | |
---|
222 | // プレビュー処理 |
---|
223 | if ($_POST['mode'] == 'preview') { |
---|
224 | if ($page_id === "") { |
---|
225 | $this->objDisplay->redirect($this->getLocation(DIR_INDEX_URL)); |
---|
226 | exit; |
---|
227 | } |
---|
228 | $this->lfSetPreData($arrPageData, $objLayout); |
---|
229 | |
---|
230 | $_SESSION['preview'] = "ON"; |
---|
231 | |
---|
232 | $this->objDisplay->redirect($this->getLocation(URL_DIR . "preview/" . DIR_INDEX_URL, array("filename" => $arrPageData[0]["filename"]))); |
---|
233 | exit; |
---|
234 | |
---|
235 | }else{ |
---|
236 | $this->objDisplay->redirect($this->getLocation(DIR_INDEX_URL, |
---|
237 | array("page_id" => $page_id, |
---|
238 | "msg" => "on"))); |
---|
239 | exit; |
---|
240 | |
---|
241 | } |
---|
242 | } |
---|
243 | |
---|
244 | // データ削除処理 ベースデータでなければファイルを削除 |
---|
245 | if ($_POST['mode'] == 'delete' and !$objLayout->lfCheckBaseData($page_id)) { |
---|
246 | $objLayout->lfDelPageData($page_id); |
---|
247 | $this->objDisplay->redirect($this->getLocation(DIR_INDEX_URL)); |
---|
248 | exit; |
---|
249 | } |
---|
250 | |
---|
251 | // ブロック情報を画面配置用に編集 |
---|
252 | $tpl_arrBloc = array(); |
---|
253 | $cnt = 0; |
---|
254 | // 使用されているブロックデータを生成 |
---|
255 | foreach($arrBlocPos as $key => $val){ |
---|
256 | if ($val['page_id'] == $page_id) { |
---|
257 | $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); |
---|
258 | $cnt++; |
---|
259 | }else{ |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | // 未使用のブロックデータを追加 |
---|
264 | foreach($arrBloc as $key => $val){ |
---|
265 | if (!$this->lfChkBloc($val, $tpl_arrBloc)) { |
---|
266 | $val['target_id'] = TARGET_ID_UNUSED; // 未使用に追加する |
---|
267 | $tpl_arrBloc = $this->lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt); |
---|
268 | $cnt++; |
---|
269 | }else{ |
---|
270 | } |
---|
271 | } |
---|
272 | |
---|
273 | $this->tpl_arrBloc = $tpl_arrBloc; |
---|
274 | $this->bloc_cnt = count($tpl_arrBloc); |
---|
275 | $this->page_id = $page_id; |
---|
276 | |
---|
277 | // ページ名称を取得 |
---|
278 | $arrPageData = $objLayout->lfgetPageData(' page_id = ?', array($page_id)); |
---|
279 | $this->arrPageData = $arrPageData[0]; |
---|
280 | |
---|
281 | global $GLOBAL_ERR; |
---|
282 | $errCnt = 0; |
---|
283 | if ($GLOBAL_ERR != "") { |
---|
284 | $arrGlobalErr = explode("\n",$GLOBAL_ERR); |
---|
285 | $errCnt = count($arrGlobalErr) - 8; |
---|
286 | if ($errCnt < 0 ) { |
---|
287 | $errCnt = 0; |
---|
288 | } |
---|
289 | } |
---|
290 | $this->errCnt = $errCnt; |
---|
291 | } |
---|
292 | |
---|
293 | /** |
---|
294 | * デストラクタ. |
---|
295 | * |
---|
296 | * @return void |
---|
297 | */ |
---|
298 | function destroy() { |
---|
299 | parent::destroy(); |
---|
300 | } |
---|
301 | |
---|
302 | /** |
---|
303 | * 編集可能なページ情報を取得する. |
---|
304 | * |
---|
305 | * @param string $sel Select句文 |
---|
306 | * @param string $where Where句文 |
---|
307 | * @param array $arrVa Where句の絞込条件値 |
---|
308 | * @return array ページレイアウト情報の配列 |
---|
309 | */ |
---|
310 | function lfgetLayoutData($sel = '' , $from = '', $where = '', $arrVal = ''){ |
---|
311 | $objQuery = new SC_Query(); // DB操作オブジェクト |
---|
312 | $sql = ""; // データ取得SQL生成用 |
---|
313 | $arrRet = array(); // データ取得用 |
---|
314 | |
---|
315 | // SQL生成 |
---|
316 | |
---|
317 | $sql = ""; |
---|
318 | $sql .= " select "; |
---|
319 | $sql .= " lay.page_id "; |
---|
320 | $sql .= " ,lay.page_name "; |
---|
321 | $sql .= " ,lay.url "; |
---|
322 | $sql .= " ,lay.author "; |
---|
323 | $sql .= " ,lay.description "; |
---|
324 | $sql .= " ,lay.keyword "; |
---|
325 | $sql .= " ,lay.update_url "; |
---|
326 | $sql .= " ,lay.create_date "; |
---|
327 | $sql .= " ,lay.update_date "; |
---|
328 | |
---|
329 | // Select句の指定があれば追加 |
---|
330 | if ($sel != '') { |
---|
331 | $sql .= $sel; |
---|
332 | } |
---|
333 | |
---|
334 | $sql .= " from dtb_pagelayout AS lay "; |
---|
335 | // From句の指定があれば追加 |
---|
336 | if ($from != '') { |
---|
337 | $sql .= $from; |
---|
338 | } |
---|
339 | |
---|
340 | // where句の指定があれば追加 |
---|
341 | if ($where != '') { |
---|
342 | $sql .= $where; |
---|
343 | }else{ |
---|
344 | $sql .= " ORDER BY lay.page_id "; |
---|
345 | } |
---|
346 | |
---|
347 | $arrRet = $objQuery->getAll($sql, $arrVal); |
---|
348 | |
---|
349 | return $arrRet; |
---|
350 | } |
---|
351 | |
---|
352 | /** |
---|
353 | * ブロック情報を取得する. |
---|
354 | * |
---|
355 | * @param string $where Where句文 |
---|
356 | * @param array $arrVal Where句の絞込条件値 |
---|
357 | * @return array ブロック情報の配列 |
---|
358 | */ |
---|
359 | function lfgetBlocData($where = '', $arrVal = ''){ |
---|
360 | $objQuery = new SC_Query(); // DB操作オブジェクト |
---|
361 | $sql = ""; // データ取得SQL生成用 |
---|
362 | $arrRet = array(); // データ取得用 |
---|
363 | |
---|
364 | // SQL生成 |
---|
365 | $sql = ""; |
---|
366 | $sql .= " SELECT "; |
---|
367 | $sql .= " bloc_id"; |
---|
368 | $sql .= " ,bloc_name"; |
---|
369 | $sql .= " ,tpl_path"; |
---|
370 | $sql .= " ,filename"; |
---|
371 | $sql .= " ,update_date"; |
---|
372 | $sql .= " FROM "; |
---|
373 | $sql .= " dtb_bloc"; |
---|
374 | |
---|
375 | // where句の指定があれば追加 |
---|
376 | if ($where != '') { |
---|
377 | $sql .= " WHERE " . $where; |
---|
378 | } |
---|
379 | |
---|
380 | $sql .= " ORDER BY bloc_id"; |
---|
381 | |
---|
382 | $arrRet = $objQuery->getAll($sql, $arrVal); |
---|
383 | |
---|
384 | return $arrRet; |
---|
385 | } |
---|
386 | |
---|
387 | /** |
---|
388 | * ブロック情報の配列を生成する. |
---|
389 | * |
---|
390 | * @param array $arrBloc Bloc情報 |
---|
391 | * @param array $tpl_arrBloc データをセットする配列 |
---|
392 | * @param integer $cnt 配列番号 |
---|
393 | * @return array データをセットした配列 |
---|
394 | */ |
---|
395 | function lfSetBlocData($arrBloc, $val, $tpl_arrBloc, $cnt) { |
---|
396 | $masterData = new SC_DB_MasterData_Ex(); |
---|
397 | $arrTarget = $masterData->getMasterData("mtb_target"); |
---|
398 | |
---|
399 | $tpl_arrBloc[$cnt]['target_id'] = $arrTarget[$val['target_id']]; |
---|
400 | $tpl_arrBloc[$cnt]['bloc_id'] = $val['bloc_id']; |
---|
401 | $tpl_arrBloc[$cnt]['bloc_row'] = |
---|
402 | isset($val['bloc_row']) ? $val['bloc_row'] : ""; |
---|
403 | $tpl_arrBloc[$cnt]['anywhere'] = $val['anywhere']; |
---|
404 | if($val['anywhere'] == 1){ |
---|
405 | $tpl_arrBloc[$cnt]['anywhere_selected'] = 'checked="checked"'; |
---|
406 | } |
---|
407 | foreach($arrBloc as $bloc_key => $bloc_val){ |
---|
408 | if ($bloc_val['bloc_id'] == $val['bloc_id']) { |
---|
409 | $bloc_name = $bloc_val['bloc_name']; |
---|
410 | break; |
---|
411 | } |
---|
412 | } |
---|
413 | $tpl_arrBloc[$cnt]['name'] = $bloc_name; |
---|
414 | |
---|
415 | return $tpl_arrBloc; |
---|
416 | } |
---|
417 | |
---|
418 | /** |
---|
419 | * ブロックIDが配列に追加されているかのチェックを行う. |
---|
420 | * |
---|
421 | * @param array $arrBloc Bloc情報 |
---|
422 | * @param array $arrChkData チェックを行うデータ配列 |
---|
423 | * @return bool 存在する場合 true |
---|
424 | */ |
---|
425 | function lfChkBloc($arrBloc, $arrChkData) { |
---|
426 | foreach($arrChkData as $key => $val){ |
---|
427 | if ($val['bloc_id'] === $arrBloc['bloc_id'] ) { |
---|
428 | // 配列に存在すればTrueを返す |
---|
429 | return true; |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | // 配列に存在しなければFlaseを返す |
---|
434 | return false; |
---|
435 | } |
---|
436 | |
---|
437 | /** |
---|
438 | * ブロックIDが何番目に配置されているかを調べる. |
---|
439 | * |
---|
440 | * @param array $arrUpdData 更新情報 |
---|
441 | * @param array $arrObj チェックを行うデータ配列 |
---|
442 | * @return integer 順番 |
---|
443 | */ |
---|
444 | function lfGetRowID($arrUpdData, $arrObj){ |
---|
445 | $no = 0; // カウント用(同じデータが必ず1件あるので、初期値は0) |
---|
446 | |
---|
447 | // 対象データが何番目に配置されているのかを取得する。 |
---|
448 | foreach ($arrUpdData as $key => $val) { |
---|
449 | if ($val['target_id'] === $arrObj['target_id'] and $val['top'] <= $arrObj['top']){ |
---|
450 | $no++; |
---|
451 | } |
---|
452 | } |
---|
453 | // 番号を返す |
---|
454 | return $no; |
---|
455 | } |
---|
456 | |
---|
457 | /** |
---|
458 | * プレビューするデータを DB に保存する. |
---|
459 | * |
---|
460 | * @param array $arrPageData ページ情報の配列 |
---|
461 | * @return void |
---|
462 | */ |
---|
463 | function lfSetPreData($arrPageData, &$objLayout){ |
---|
464 | $objQuery = new SC_Query(); // DB操作オブジェクト |
---|
465 | $sql = ""; // データ更新SQL生成用 |
---|
466 | $ret = ""; // データ更新結果格納用 |
---|
467 | $arrUpdData = array(); // 更新データ生成用 |
---|
468 | $filename = $arrPageData[0]['filename']; |
---|
469 | |
---|
470 | $arrPreData = $objLayout->lfgetPageData(" page_id = ? " , array("0")); |
---|
471 | |
---|
472 | // XXX tplファイルの削除 |
---|
473 | $del_tpl = USER_PATH . "templates/" . $filename . '.tpl'; |
---|
474 | |
---|
475 | if (file_exists($del_tpl)){ |
---|
476 | unlink($del_tpl); |
---|
477 | } |
---|
478 | |
---|
479 | // filename が空の場合にはMYページと判断 |
---|
480 | if($filename == ""){ |
---|
481 | $tplfile = TEMPLATE_DIR . "mypage/index"; |
---|
482 | $filename = 'mypage'; |
---|
483 | } else { |
---|
484 | if (file_exists(TEMPLATE_FTP_DIR . $filename . ".tpl")) { |
---|
485 | $tplfile = TEMPLATE_FTP_DIR . $filename; |
---|
486 | } else { |
---|
487 | $tplfile = TEMPLATE_DIR . $filename; |
---|
488 | } |
---|
489 | } |
---|
490 | |
---|
491 | // プレビュー用tplファイルのコピー |
---|
492 | $copyTo = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $filename . ".tpl"; |
---|
493 | |
---|
494 | if (!is_dir(dirname($copyTo))) { |
---|
495 | mkdir(dirname($copyTo)); |
---|
496 | } |
---|
497 | |
---|
498 | copy($tplfile . ".tpl", $copyTo); |
---|
499 | |
---|
500 | // 更新データの取得 |
---|
501 | $sql = "select page_id,page_name, header_chk, footer_chk from dtb_pagelayout where page_id = ? OR page_id = (SELECT page_id FROM dtb_blocposition WHERE anywhere = 1)" ; |
---|
502 | |
---|
503 | $ret = $objQuery->getAll($sql, array($arrPageData[0]['page_id'])); |
---|
504 | |
---|
505 | // dbデータのコピー |
---|
506 | $sql = " update dtb_pagelayout set "; |
---|
507 | $sql .= " page_name = ?"; |
---|
508 | $sql .= " ,header_chk = ?"; |
---|
509 | $sql .= " ,footer_chk = ?"; |
---|
510 | $sql .= " ,url = ?"; |
---|
511 | $sql .= " ,tpl_dir = ?"; |
---|
512 | $sql .= " ,filename = ?"; |
---|
513 | // $sql .= " ,anywhere = ?"; |
---|
514 | $sql .= " where page_id = 0"; |
---|
515 | var_dump($ret); |
---|
516 | echo("####<br/>\n\n".__LINE__ ." in file:".__FILE__."<br/>\n\n ####"); |
---|
517 | |
---|
518 | $arrUpdData = array($ret[0]['page_id'] |
---|
519 | ,$ret[0]['page_id'] |
---|
520 | ,$ret[0]['page_id'] |
---|
521 | ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" |
---|
522 | ,USER_DIR . "templates/" . TEMPLATE_NAME . "/" |
---|
523 | ,$filename |
---|
524 | // ,$ret[0]['anywhere'] |
---|
525 | |
---|
526 | ); |
---|
527 | |
---|
528 | $objQuery->query($sql,$arrUpdData); |
---|
529 | } |
---|
530 | } |
---|
531 | ?> |
---|