Source for file LC_Page_Admin_Design_MainEdit.php
Documentation is available at LC_Page_Admin_Design_MainEdit.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2007 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");
* @author LOCKON CO.,LTD.
$this->tpl_subnavi =
'design/subnavi.tpl';
$this->user_URL =
USER_URL;
$this->tpl_subno =
"main_edit";
$this->tpl_subtitle =
'ページ詳細設定';
$this->arrPageList =
$this->objLayout->lfgetPageData();
if (isset
($_POST['page_id'])) {
$page_id =
$_POST['page_id'];
}else if (isset
($_GET['page_id'])){
$page_id =
$_GET['page_id'];
$this->page_id =
$page_id;
if (isset
($_GET['msg']) &&
$_GET['msg'] ==
"on"){
// page_id が指定されている場合にはテンプレートデータの取得
$arrPageData =
$this->objLayout->lfgetPageData(" page_id = ? " , array($page_id));
if (strlen($arrPageData[0]['filename']) ==
0) {
$this->arrErr['page_id_err'] =
"※ 指定されたページは編集できません。";
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
// テンプレートファイルが存在していれば読み込む
$tpl_file =
USER_TEMPLATE_PATH .
"/" .
TEMPLATE_NAME .
"/" .
$arrPageData[0]['filename'] .
".tpl";
// 存在してなければ, 指定されたテンプレートのファイルを読み込む
$arrPageData[0]['tpl_data'] =
file_get_contents(TEMPLATE_DIR .
$arrPageData[0]['filename'] .
".tpl");
$arrPageData[0]['header_chk'] =
SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['header_chk'], true);
$arrPageData[0]['footer_chk'] =
SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['footer_chk'], true);
$arrPageData[0]['directory'] =
str_replace(USER_DIR, '', $arrPageData[0]['php_dir']);
$this->arrPageData =
$arrPageData[0];
if (!isset
($_POST['mode'])) $_POST['mode'] =
"";
if ($_POST['mode'] ==
'preview') {
// プレビューの場合ページIDを0にセットする。
$tmpPost['page_id'] =
$page_id;
$tmpPost['tpl_dir'] =
USER_PATH .
"templates/preview/";
$arrPreData =
$this->objLayout->lfgetPageData("page_id = ?" , array($page_id));
// tplファイルの削除 (XXX: 処理の意図が不明。存在していると都合が悪いファイル?)
$del_tpl =
USER_PATH .
"templates/" .
$arrPreData[0]['filename'] .
'.tpl';
$preview_tpl =
USER_PATH .
"templates/preview/" .
TEMPLATE_NAME .
"/" .
$url .
'.tpl';
$sql =
'delete from dtb_blocposition where page_id = 0';
$ret =
$objDBConn->query($sql);
if ($page_id_old !=
"") {
$sql =
"SELECT 0, target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ?";
$ret =
$objDBConn->getAll($sql,array($page_id_old));
$sql =
" insert into dtb_blocposition (";
$sql .=
" )values(?, ?, ?, ?)";
foreach($ret as $key =>
$val){
$ret =
$objDBConn->query($sql,$val);
$_SESSION['preview'] =
"ON";
$this->sendRedirect($this->getLocation(URL_DIR .
"preview/" .
DIR_INDEX_URL, array("filename" =>
$arrPageData[0]["filename"])));
if ($_POST['mode'] ==
'confirm') {
if (count($this->arrErr) ==
0) {
// ベースデータでなければファイルを削除し、PHPファイルを作成する
if (!$this->objLayout->lfCheckBaseData($page_id)) {
$this->objLayout->lfDelFile($arrPageData[0]);
$cre_tpl =
USER_TEMPLATE_PATH .
"/" .
TEMPLATE_NAME .
"/" .
basename($_POST['url']) .
'.tpl';
$arrPageData =
$this->objLayout->lfgetPageData(" url = ? AND page_id <> 0" , array(USER_DIR .
$_POST['url'] .
'.php'));
$page_id =
$arrPageData[0]['page_id'];
array("page_id" =>
$page_id,
$this->arrPageData =
$_POST;
$this->arrPageData['header_chk'] =
SC_Utils_Ex::sfChangeCheckBox(SC_Utils_Ex::sfChangeCheckBox($_POST['header_chk']), true);
$this->arrPageData['footer_chk'] =
SC_Utils_Ex::sfChangeCheckBox(SC_Utils_Ex::sfChangeCheckBox($_POST['footer_chk']), true);
$this->arrPageData['directory'] =
'';
$this->arrPageData['filename'] =
$_POST['url'];
// データ削除処理 ベースデータでなければファイルを削除
if ($_POST['mode'] ==
'delete' and !$this->objLayout->lfCheckBaseData($page_id)) {
$this->objLayout->lfDelPageData($_POST['page_id']);
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
* @param array $arrData 更新データ
$sql =
""; // データ更新SQL生成用
$arrUpdData =
array(); // 更新データ生成用
$arrChk =
array(); // 排他チェック用
if($arrData['page_id'] !==
''){
$arrChk =
$this->objLayout->lfgetPageData("page_id = ?", array($arrData['page_id']));
// page_id が空 若しくは データが存在していない場合にはINSERTを行う
if ($arrData['page_id'] ===
'' or !isset
($arrChk[0])) {
$sql =
" INSERT INTO dtb_pagelayout ";
$sql .=
" ) VALUES ( ?,?,?,?,?,?,?,?,now(),now() )";
// データが存在してる場合にはアップデートを行う
$sql =
" UPDATE dtb_pagelayout ";
$sql .=
" page_name = ? ";
$sql .=
" ,php_dir = ? ";
$sql .=
" ,tpl_dir = ? ";
$sql .=
" ,filename = ? ";
$sql .=
" ,header_chk = ? ";
$sql .=
" ,footer_chk = ? ";
$sql .=
" ,update_url = ? ";
$sql .=
" ,update_date = now() ";
$sql .=
" WHERE page_id = ?";
$ret =
$objDBConn->query($sql,$arrUpdData);
* @param array $arrData 更新データ
if ($this->objLayout->lfCheckBaseData($arrData['page_id'])) {
$arrPageData =
$this->objLayout->lfgetPageData( ' page_id = ? ' , array($arrData['page_id']));
$name =
$arrPageData[0]['page_name'] ;
$url =
$arrPageData[0]['url'];
$php_dir =
$arrPageData[0]['php_dir'];
$filename =
$arrPageData[0]['filename'];
$name =
$arrData['page_name'] ;
$url =
USER_DIR .
$arrData['url'] .
'.php';
$filename =
basename($arrData['url']); // 拡張子を付加しない
,SC_Utils_Ex::sfChangeCheckBox($arrData['header_chk']) // ヘッダー使用
,SC_Utils_Ex::sfChangeCheckBox($arrData['footer_chk']) // フッター使用
,$_SERVER['HTTP_REFERER'] // 更新URL
* @param array $arrData 入力データ
$objErr->doFunc(array("名称", "page_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
$objErr->doFunc(array("URL", "url", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
foreach (explode('/', $array['url']) as $url_part) {
if (!ereg( '^[a-zA-Z0-9:_~\.-]+$', $url_part)) {
if ($url_part ==
'.' ||
$url_part ==
'..') {
$objErr->arrErr['url'] =
"※ URLを正しく入力してください。<br />";
$sqlWhere .=
' (url = ? OR url = ?)';
$params[] =
USER_DIR .
$array['url'] .
'.php';
$params[] =
USER_URL .
$array['url'] .
'.php'; // 従来形式
$sqlWhere .=
' AND page_id <> 0';
if (strlen($array['page_id']) !=
0) {
$sqlWhere .=
' AND page_id <> ?';
$params[] =
$array['page_id'];
$arrChk =
$this->objLayout->lfgetPageData($sqlWhere , $params);
if (count($arrChk) >=
1) {
$objErr->arrErr['url'] =
'※ 同じURLのデータが存在しています。別のURLを付けてください。<br />';
* @param string $path テンプレートファイルのパス
fwrite($fp, $_POST['tpl_data']); // FIXME いきなり POST はちょっと...
* @param string $path PHPファイルのパス
$path =
USER_PATH .
$url .
".php";
// php保存先ディレクトリが存在していなければ作成する
Documentation generated on Tue, 28 Apr 2009 18:11:08 +0900 by phpDocumentor 1.4.2