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

Revision 23057, 3.6 KB checked in by Seasoft, 11 years ago (diff)

#2327 (SC_Helper_PageLayout#sfGetPageLayout ページ情報が取得できない場合の動作が不定)

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