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

Revision 21693, 7.5 KB checked in by h_yoshimoto, 12 years ago (diff)

#1692 フックポイント名を変更

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