source: branches/version-2_12-dev/data/class/pages/rss/LC_Page_Rss.php @ 22581

Revision 22581, 3.7 KB checked in by pineray, 11 years ago (diff)

#2160 pageクラスからdtb_newsテーブルを直接指定している箇所をなくす
新着情報管理のページクラス内の処理を他と統一する

  • 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
RevLine 
[16192]1<?php
2/*
[16582]3 * This file is part of EC-CUBE
4 *
[22206]5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
[16192]6 *
7 * http://www.lockon.co.jp/
[16582]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.
[16192]22 */
23
24// {{{ requires
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
[16192]26
27/**
28 * RSS のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
[22567]34class LC_Page_RSS extends LC_Page_Ex
35{
[16192]36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
[22567]45    function init()
46    {
[16192]47        parent::init();
[21514]48        $this->tpl_mainpage = 'rss/index.tpl';
49        $this->encode = 'UTF-8';
50        $this->description = '新着情報';
[16192]51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
[22567]58    function process()
59    {
[21596]60
[20306]61        $objView = new SC_SiteView_Ex(false);
[16192]62
63        //新着情報を取得
[22581]64        $arrNews = $this->lfGetNews();
[20540]65
[16192]66        //キャッシュしない(念のため)
[21514]67        header('pragma: no-cache');
[16192]68
69        //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため)
[21514]70        header('Content-type: application/xml');
[16192]71
72        //新着情報をセット
73        $this->arrNews = $arrNews;
74
75        //店名をセット
76        $this->site_title = $arrNews[0]['shop_name'];
77
78        //代表Emailアドレスをセット
79        $this->email = $arrNews[0]['email'];
80
81        //セットしたデータをテンプレートファイルに出力
82        $objView->assignobj($this);
83
[21596]84
[16192]85        //画面表示
86        $objView->display($this->tpl_mainpage, true);
87    }
88
89    /**
90     * デストラクタ.
91     *
92     * @return void
93     */
[22567]94    function destroy()
95    {
[16192]96        parent::destroy();
97    }
98
99    /**
100     * 新着情報を取得する
101     *
102     * @return array $arrNews 取得結果を配列で返す
103     */
[22581]104    function lfGetNews()
[22567]105    {
[22581]106        $objNews = new SC_Helper_News_Ex();
107        $arrNews = $objNews->getList();
[20540]108
[22581]109        $objDb = new SC_Helper_DB_Ex();
110        $arrInfo = $objDb->sfGetBasisData(FALSE, 'shop_name, email04');
111
[17921]112        // RSS用に変換
[21935]113        foreach ($arrNews as $key => $value) {
[21121]114            $netUrlHttpUrl = new Net_URL(HTTP_URL);
115
[17921]116            $row =& $arrNews[$key];
[22581]117            $row['shop_name'] = $arrInfo['shop_name'];
118            $row['email'] = $arrInfo['email04'];
[17921]119            // 日付
120            $row['news_date'] = date('r', strtotime($row['news_date']));
[21121]121            // 新着情報URL
122            if (SC_Utils_Ex::isBlank($row['news_url'])) {
123                $row['news_url'] = HTTP_URL;
[21442]124            } elseif ($row['news_url'][0] == '/') {
[21121]125                // 変換(絶対パス→URL)
126                $netUrl = new Net_URL($row['news_url']);
127                $netUrl->protocol = $netUrlHttpUrl->protocol;
128                $netUrl->user = $netUrlHttpUrl->user;
129                $netUrl->pass = $netUrlHttpUrl->pass;
130                $netUrl->host = $netUrlHttpUrl->host;
131                $netUrl->port = $netUrlHttpUrl->port;
132                $row['news_url'] = $netUrl->getUrl();
133            }
[17921]134        }
[20540]135
[16192]136        return $arrNews;
137    }
138}
Note: See TracBrowser for help on using the repository browser.