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

Revision 20116, 7.8 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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        $this->arrDeviceTypeName[DEVICE_TYPE_PC] = 'PCサイト';
60        $this->arrDeviceTypeName[DEVICE_TYPE_MOBILE] = 'モバイルサイト';
61        $this->arrDeviceTypeName[DEVICE_TYPE_SMARTPHONE] = 'スマートフォン';
62    }
63
64    /**
65     * Page のプロセス.
66     *
67     * @return void
68     */
69    function process() {
70        $this->action();
71        $this->sendResponse();
72    }
73
74    /**
75     * Page のアクション.
76     *
77     * @return void
78     */
79    function action() {
80        $objSess = new SC_Session();
81
82        // 認証可否の判定
83        SC_Utils_Ex::sfIsSuccess($objSess);
84
85        // データの取得
86        $this->arrPageData = $this->lfGetSeoPageData();
87
88        $device_type_id = (isset($_POST['device_type_id'])) ? $_POST['device_type_id'] : '';
89        $page_id = (isset($_POST['page_id'])) ? $_POST['page_id'] : '';
90
91        switch ($this->getMode()) {
92        case 'confirm':
93            // エラーチェック
94            $this->arrErr[$device_type_id][$page_id] = $this->lfErrorCheck($_POST['meta'][$device_type_id][$page_id]);
95
96            // エラーがなければデータを更新
97            if(count($this->arrErr[$device_type_id][$page_id]) == 0) {
98
99                // 更新データの変換
100                $arrMETA = $this->lfConvertParam($_POST['meta'][$device_type_id][$page_id]);
101
102                // 更新データ配列生成
103                $arrUpdData = array($arrMETA['author'], $arrMETA['description'], $arrMETA['keyword'], $device_type_id, $page_id);
104                // データ更新
105                $this->lfUpdPageData($arrUpdData);
106            }else{
107                // POSTのデータを再表示
108                $arrPageData = $this->lfSetData($this->arrPageData, $_POST['meta']);
109                $this->arrPageData = $arrPageData;
110            }
111            break;
112        default:
113            break;
114        }
115
116        // エラーがなければデータの取得
117        if(count($this->arrErr[$device_type_id][$page_id]) == 0) {
118            // データの取得
119            $this->arrPageData = $this->lfGetSeoPageData();
120        }
121    }
122
123    /**
124     * デストラクタ.
125     *
126     * @return void
127     */
128    function destroy() {
129        parent::destroy();
130    }
131
132    /**
133     * ページレイアウトテーブルにデータ更新を行う.
134     *
135     * @param array $arrUpdData 更新データ
136     * @return integer 更新結果
137     */
138    function lfUpdPageData($arrUpdData = array()){
139        $objQuery = new SC_Query();
140        $sql = "";
141
142        // SQL生成
143        $sql .= " UPDATE ";
144        $sql .= "     dtb_pagelayout ";
145        $sql .= " SET ";
146        $sql .= "     author = ? , ";
147        $sql .= "     description = ? , ";
148        $sql .= "     keyword = ? ";
149        $sql .= " WHERE ";
150        $sql .= "     device_type_id = ? ";
151        $sql .= "     AND page_id = ? ";
152        $sql .= " ";
153
154        // SQL実行
155        $ret = $objQuery->query($sql, $arrUpdData);
156
157        return $ret;
158    }
159
160    /**
161     * 入力項目のエラーチェックを行う.
162     *
163     * @param array $array エラーチェック対象データ
164     * @return array エラー内容
165     */
166    function lfErrorCheck($array) {
167        $objErr = new SC_CheckError($array);
168
169        $objErr->doFunc(array("メタタグ:Author", "author", STEXT_LEN), array("MAX_LENGTH_CHECK"));
170        $objErr->doFunc(array("メタタグ:Description", "description", STEXT_LEN), array("MAX_LENGTH_CHECK"));
171        $objErr->doFunc(array("メタタグ:Keywords", "keyword", STEXT_LEN), array("MAX_LENGTH_CHECK"));
172
173        return $objErr->arrErr;
174    }
175
176    /**
177     * テンプレート表示データに値をセットする.
178     *
179     * @param array 表示元データ
180     * @param array 表示データ
181     * @return array 表示データ
182     */
183    function lfSetData($arrPageData, $arrDispData){
184
185        foreach($arrPageData as $device_key => $arrVal){
186            foreach($arrVal as $key => $val) {
187                $device_type_id = $val['device_type_id'];
188                $page_id = $val['page_id'];
189                $arrPageData[$device_key][$key]['author'] = $arrDispData[$device_type_id][$page_id]['author'];
190                $arrPageData[$device_key][$key]['description'] = $arrDispData[$device_type_id][$page_id]['description'];
191                $arrPageData[$device_key][$key]['keyword'] = $arrDispData[$device_type_id][$page_id]['keyword'];
192            }
193        }
194
195        return $arrPageData;
196    }
197
198    /* 取得文字列の変換 */
199    function lfConvertParam($array) {
200        /*
201         *  文字列の変換
202         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
203         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
204         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
205         *  n :  「全角」数字を「半角(ハンカク)」に変換
206         *  a :  全角英数字を半角英数字に変換する
207         */
208        // 人物基本情報
209
210        // スポット商品
211        $arrConvList['author'] = "KVa";
212        $arrConvList['description'] = "KVa";
213        $arrConvList['keyword'] = "KVa";
214
215        // 文字変換
216        foreach ($arrConvList as $key => $val) {
217            // POSTされてきた値のみ変換する。
218            if(isset($array[$key])) {
219                $array[$key] = mb_convert_kana($array[$key] ,$val);
220            }
221        }
222        return $array;
223    }
224
225    /**
226     * SEO管理で設定するページのデータを取得する
227     *
228     * @param void
229     * @return array $arrRet ページデータ($arrRet[デバイスタイプID])
230     */
231    function lfGetSeoPageData() {
232        $objLayout = new SC_Helper_PageLayout_Ex();
233        $arrRet = array();
234
235        $arrRet[DEVICE_TYPE_PC] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_PC));
236        $arrRet[DEVICE_TYPE_MOBILE] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_MOBILE));
237        $arrRet[DEVICE_TYPE_SMARTPHONE] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_SMARTPHONE));
238
239        return $arrRet;
240    }
241}
242?>
Note: See TracBrowser for help on using the repository browser.