source: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Seo.php @ 19805

Revision 19805, 6.8 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部実装

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * SEO管理 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Seo extends LC_Page_Admin {
35
36    // {{{ properties
37
38    /** エラー情報 */
39    var $arrErr;
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $this->tpl_mainpage = 'basis/seo.tpl';
52        $this->tpl_subnavi = 'basis/subnavi.tpl';
53        $this->tpl_subno = 'seo';
54        $this->tpl_mainno = 'basis';
55        $this->tpl_subtitle = 'SEO管理';
56        $masterData = new SC_DB_MasterData_Ex();
57        $this->arrPref = $masterData->getMasterData('mtb_pref');
58        $this->arrTAXRULE = $masterData->getMasterData("mtb_taxrule");
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process() {
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のアクション.
73     *
74     * @return void
75     */
76    function action() {
77        $objSess = new SC_Session();
78        $objQuery = new SC_Query();
79
80        // 認証可否の判定
81        SC_Utils_Ex::sfIsSuccess($objSess);
82
83        // データの取得
84        $objLayout = new SC_Helper_PageLayout_Ex();
85        $this->arrPageData = $objLayout->lfgetPageData(" edit_flg = 2 ");
86
87        if (isset($_POST['page_id'])) {
88            $page_id = $_POST['page_id'];
89        } else {
90            $page_id = "";
91        }
92
93        if (!isset($_POST['mode'])) $_POST['mode'] = "";
94
95        if($_POST['mode'] == "confirm") {
96            // エラーチェック
97            $this->arrErr[$page_id] = $this->lfErrorCheck($_POST['meta'][$page_id]);
98
99            // エラーがなければデータを更新
100            if(count($this->arrErr[$page_id]) == 0) {
101
102                // 更新データの変換
103                $arrMETA = $this->lfConvertParam($_POST['meta'][$page_id]);
104
105                // 更新データ配列生成
106                $arrUpdData = array($arrMETA['author'], $arrMETA['description'], $arrMETA['keyword'], $page_id);
107                // データ更新
108                $this->lfUpdPageData($arrUpdData);
109            }else{
110                // POSTのデータを再表示
111                $arrPageData = $this->lfSetData($arrPageData, $_POST['meta']);
112                $this->arrPageData = $arrPageData;
113            }
114        }
115
116        $arrDisp_flg = array();
117        // エラーがなければデータの取得
118        if(count($this->arrErr[$page_id]) == 0) {
119            // データの取得
120            $arrPageData = $objLayout->lfgetPageData(" edit_flg = 2 ");
121            $this->arrPageData = $arrPageData;
122        }
123
124        // 表示・非表示切り替え
125        foreach($arrPageData as $key => $val){
126            $arrDisp_flg[$val['page_id']] = $_POST['disp_flg'.$val['page_id']];
127        }
128
129        $this->disp_flg = $arrDisp_flg;
130    }
131
132    /**
133     * デストラクタ.
134     *
135     * @return void
136     */
137    function destroy() {
138        parent::destroy();
139    }
140
141    /**
142     * ページレイアウトテーブルにデータ更新を行う.
143     *
144     * @param array $arrUpdData 更新データ
145     * @return integer 更新結果
146     */
147    function lfUpdPageData($arrUpdData = array()){
148        $objQuery = new SC_Query();
149        $sql = "";
150
151        // SQL生成
152        $sql .= " UPDATE ";
153        $sql .= "     dtb_pagelayout ";
154        $sql .= " SET ";
155        $sql .= "     author = ? , ";
156        $sql .= "     description = ? , ";
157        $sql .= "     keyword = ? ";
158        $sql .= " WHERE ";
159        $sql .= "     page_id = ? ";
160        $sql .= " ";
161
162        // SQL実行
163        $ret = $objQuery->query($sql, $arrUpdData);
164
165        return $ret;
166    }
167
168    /**
169     * 入力項目のエラーチェックを行う.
170     *
171     * @param array $array エラーチェック対象データ
172     * @return array エラー内容
173     */
174    function lfErrorCheck($array) {
175        $objErr = new SC_CheckError($array);
176
177        $objErr->doFunc(array("メタタグ:Author", "author", STEXT_LEN), array("MAX_LENGTH_CHECK"));
178        $objErr->doFunc(array("メタタグ:Description", "description", STEXT_LEN), array("MAX_LENGTH_CHECK"));
179        $objErr->doFunc(array("メタタグ:Keywords", "keyword", STEXT_LEN), array("MAX_LENGTH_CHECK"));
180
181        return $objErr->arrErr;
182    }
183
184    /**
185     * テンプレート表示データに値をセットする.
186     *
187     * @param array 表示元データ
188     * @param array 表示データ
189     * @return array 表示データ
190     */
191    function lfSetData($arrPageData, $arrDispData){
192
193        foreach($arrPageData as $key => $val){
194            $page_id = $val['page_id'];
195            $arrPageData[$key]['author'] = $arrDispData[$page_id]['author'];
196            $arrPageData[$key]['description'] = $arrDispData[$page_id]['description'];
197            $arrPageData[$key]['keyword'] = $arrDispData[$page_id]['keyword'];
198        }
199
200        return $arrPageData;
201    }
202
203    /* 取得文字列の変換 */
204    function lfConvertParam($array) {
205        /*
206         *  文字列の変換
207         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
208         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
209         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
210         *  n :  「全角」数字を「半角(ハンカク)」に変換
211         *  a :  全角英数字を半角英数字に変換する
212         */
213        // 人物基本情報
214
215        // スポット商品
216        $arrConvList['author'] = "KVa";
217        $arrConvList['description'] = "KVa";
218        $arrConvList['keyword'] = "KVa";
219
220        // 文字変換
221        foreach ($arrConvList as $key => $val) {
222            // POSTされてきた値のみ変換する。
223            if(isset($array[$key])) {
224                $array[$key] = mb_convert_kana($array[$key] ,$val);
225            }
226        }
227        return $array;
228    }
229}
230?>
Note: See TracBrowser for help on using the repository browser.