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

Revision 21864, 7.1 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新

  • 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 = '基本情報管理';
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        // データの取得
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        $sql = '';
147
148        // SQL生成
149        $sql .= ' UPDATE ';
150        $sql .= '     dtb_pagelayout ';
151        $sql .= ' SET ';
152        $sql .= '     author = ? , ';
153        $sql .= '     description = ? , ';
154        $sql .= '     keyword = ? ';
155        $sql .= ' WHERE ';
156        $sql .= '     device_type_id = ? ';
157        $sql .= '     AND page_id = ? ';
158        $sql .= ' ';
159
160        // SQL実行
161        $ret = $objQuery->query($sql, $arrUpdData);
162
163        return $ret;
164    }
165
166    function lfInitParam($mode, &$objFormParam) {
167        $objFormParam->addParam('デバイスID', 'device_type_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
168        $objFormParam->addParam('ページID', 'page_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
169        $objFormParam->addParam('メタタグ:Author', 'author', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
170        $objFormParam->addParam('メタタグ:Description', 'description', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
171        $objFormParam->addParam('メタタグ:Keywords', 'keyword', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
172    }
173
174    /**
175     * テンプレート表示データに値をセットする.
176     *
177     * @param array 表示元データ
178     * @param array 表示データ
179     * @return array 表示データ
180     */
181    function lfSetData($arrPageData, $arrDispData) {
182
183        foreach ($arrPageData as $device_key => $arrVal) {
184            foreach ($arrVal as $key => $val) {
185                $device_type_id = $val['device_type_id'];
186                $page_id = $val['page_id'];
187                $arrPageData[$device_key][$key]['author'] = $arrDispData[$device_type_id][$page_id]['author'];
188                $arrPageData[$device_key][$key]['description'] = $arrDispData[$device_type_id][$page_id]['description'];
189                $arrPageData[$device_key][$key]['keyword'] = $arrDispData[$device_type_id][$page_id]['keyword'];
190            }
191        }
192
193        return $arrPageData;
194    }
195
196    /**
197     * SEO管理で設定するページのデータを取得する
198     *
199     * @param void
200     * @return array $arrRet ページデータ($arrRet[デバイスタイプID])
201     */
202    function lfGetSeoPageData() {
203        $objLayout = new SC_Helper_PageLayout_Ex();
204
205        return array(
206            DEVICE_TYPE_PC          => $objLayout->getPageProperties(DEVICE_TYPE_PC, null, 'edit_flg = ?', array('2')),
207            DEVICE_TYPE_MOBILE      => $objLayout->getPageProperties(DEVICE_TYPE_MOBILE, null, 'edit_flg = ?', array('2')),
208            DEVICE_TYPE_SMARTPHONE  => $objLayout->getPageProperties(DEVICE_TYPE_SMARTPHONE, null, 'edit_flg = ?', array('2')),
209        );
210    }
211}
Note: See TracBrowser for help on using the repository browser.