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

Revision 20501, 7.0 KB checked in by shutta, 13 years ago (diff)

SC_FormParamクラスのclass_extends対応

  • 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_EX_REALDIR . "page_extends/admin/LC_Page_Admin_Ex.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_Ex {
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        // データの取得
81        $this->arrPageData = $this->lfGetSeoPageData();
82
83        $mode = $this->getMode();
84
85        if (!empty($_POST)) {
86            $objFormParam = new SC_FormParam_Ex();
87            $this->lfInitParam($mode, $objFormParam);
88            $objFormParam->setParam($_POST);
89            $objFormParam->convParam();
90
91            $this->arrErr = $objFormParam->checkError();
92            $post = $objFormParam->getHashArray();
93        }
94        $device_type_id = (isset($post['device_type_id'])) ? $post['device_type_id'] : '';
95        $page_id = (isset($post['page_id'])) ? $post['page_id'] : '';
96
97        switch ($mode) {
98        case 'confirm':
99            $objFormParam->setParam($_POST['meta'][$device_type_id][$page_id]);
100            $this->arrErr[$device_type_id][$page_id] = $objFormParam->checkError();
101
102            // エラーがなければデータを更新
103            if(count($this->arrErr[$device_type_id][$page_id]) == 0) {
104                $arrMETA = $objFormParam->getHashArray();
105
106                // 更新データ配列生成
107                $arrUpdData = array($arrMETA['author'], $arrMETA['description'], $arrMETA['keyword'], $device_type_id, $page_id);
108                // データ更新
109                $this->lfUpdPageData($arrUpdData);
110            }else{
111                // POSTのデータを再表示
112                $arrPageData = $this->lfSetData($this->arrPageData, $_POST['meta']);
113                $this->arrPageData = $arrPageData;
114            }
115            break;
116        default:
117            break;
118        }
119
120        // エラーがなければデータの取得
121        if(count($this->arrErr[$device_type_id][$page_id]) == 0) {
122            // データの取得
123            $this->arrPageData = $this->lfGetSeoPageData();
124        }
125    }
126
127    /**
128     * デストラクタ.
129     *
130     * @return void
131     */
132    function destroy() {
133        parent::destroy();
134    }
135
136    /**
137     * ページレイアウトテーブルにデータ更新を行う.
138     *
139     * @param array $arrUpdData 更新データ
140     * @return integer 更新結果
141     */
142    function lfUpdPageData($arrUpdData = array()){
143        $objQuery =& SC_Query::getSingletonInstance();
144        $sql = "";
145
146        // SQL生成
147        $sql .= " UPDATE ";
148        $sql .= "     dtb_pagelayout ";
149        $sql .= " SET ";
150        $sql .= "     author = ? , ";
151        $sql .= "     description = ? , ";
152        $sql .= "     keyword = ? ";
153        $sql .= " WHERE ";
154        $sql .= "     device_type_id = ? ";
155        $sql .= "     AND page_id = ? ";
156        $sql .= " ";
157
158        // SQL実行
159        $ret = $objQuery->query($sql, $arrUpdData);
160
161        return $ret;
162    }
163
164
165    function lfInitParam($mode, &$objFormParam) {
166        $objFormParam->addParam('デバイスID', 'device_type_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
167        $objFormParam->addParam('ページID', 'page_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
168        $objFormParam->addParam('メタタグ:Author', 'author', STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK"));
169        $objFormParam->addParam('メタタグ:Description', 'description', STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK"));
170        $objFormParam->addParam('メタタグ:Keywords', 'keyword', STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK"));
171    }
172
173    /**
174     * テンプレート表示データに値をセットする.
175     *
176     * @param array 表示元データ
177     * @param array 表示データ
178     * @return array 表示データ
179     */
180    function lfSetData($arrPageData, $arrDispData){
181
182        foreach($arrPageData as $device_key => $arrVal){
183            foreach($arrVal as $key => $val) {
184                $device_type_id = $val['device_type_id'];
185                $page_id = $val['page_id'];
186                $arrPageData[$device_key][$key]['author'] = $arrDispData[$device_type_id][$page_id]['author'];
187                $arrPageData[$device_key][$key]['description'] = $arrDispData[$device_type_id][$page_id]['description'];
188                $arrPageData[$device_key][$key]['keyword'] = $arrDispData[$device_type_id][$page_id]['keyword'];
189            }
190        }
191
192        return $arrPageData;
193    }
194
195    /**
196     * SEO管理で設定するページのデータを取得する
197     *
198     * @param void
199     * @return array $arrRet ページデータ($arrRet[デバイスタイプID])
200     */
201    function lfGetSeoPageData() {
202        $objLayout = new SC_Helper_PageLayout_Ex();
203        $arrRet = array();
204
205        $arrRet[DEVICE_TYPE_PC] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_PC));
206        $arrRet[DEVICE_TYPE_MOBILE] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_MOBILE));
207        $arrRet[DEVICE_TYPE_SMARTPHONE] = $objLayout->lfgetPageData('edit_flg = ? AND device_type_id = ?', array('2', DEVICE_TYPE_SMARTPHONE));
208
209        return $arrRet;
210    }
211}
212?>
Note: See TracBrowser for help on using the repository browser.