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

Revision 22796, 4.3 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

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