source: branches/version-2_12-multilang/data/class/pages/admin/basis/LC_Page_Admin_Basis_Seo.php @ 22496

Revision 22496, 7.1 KB checked in by m_uehara, 11 years ago (diff)

#2084 メッセージIDの振り直し

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