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

Revision 22945, 3.5 KB checked in by kimoto, 11 years ago (diff)

#2043 typo修正・ソース整形・ソースコメントの改善 for 2.13.0
不要な変数を削除

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