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 |
---|
25 | require_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 | */ |
---|
34 | class 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 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
58 | $objView = new SC_SiteView_Ex(false); |
---|
59 | |
---|
60 | //新着情報を取得 |
---|
61 | $arrNews = $this->lfGetNews($objQuery); |
---|
62 | |
---|
63 | //キャッシュしない(念のため) |
---|
64 | header('pragma: no-cache'); |
---|
65 | |
---|
66 | //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため) |
---|
67 | header('Content-type: application/xml'); |
---|
68 | |
---|
69 | //新着情報をセット |
---|
70 | $this->arrNews = $arrNews; |
---|
71 | |
---|
72 | //店名をセット |
---|
73 | $this->site_title = $arrNews[0]['shop_name']; |
---|
74 | |
---|
75 | //代表Emailアドレスをセット |
---|
76 | $this->email = $arrNews[0]['email']; |
---|
77 | |
---|
78 | //セットしたデータをテンプレートファイルに出力 |
---|
79 | $objView->assignobj($this); |
---|
80 | |
---|
81 | //画面表示 |
---|
82 | $objView->display($this->tpl_mainpage, true); |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * デストラクタ. |
---|
87 | * |
---|
88 | * @return void |
---|
89 | */ |
---|
90 | function destroy() { |
---|
91 | parent::destroy(); |
---|
92 | } |
---|
93 | |
---|
94 | /** |
---|
95 | * 新着情報を取得する |
---|
96 | * |
---|
97 | * @param SC_Query $objQuery DB操作クラス |
---|
98 | * @return array $arrNews 取得結果を配列で返す |
---|
99 | */ |
---|
100 | function lfGetNews(&$objQuery) { |
---|
101 | $col = ''; |
---|
102 | $col .= 'news_id '; // 新着情報ID |
---|
103 | $col .= ',news_title '; // 新着情報タイトル |
---|
104 | $col .= ',news_comment '; // 新着情報本文 |
---|
105 | $col .= ',news_date '; // 日付 |
---|
106 | $col .= ',news_url '; // 新着情報URL |
---|
107 | $col .= ',news_select '; // 新着情報の区分(1:URL、2:本文) |
---|
108 | $col .= ',(SELECT shop_name FROM dtb_baseinfo limit 1) AS shop_name '; // 店名 |
---|
109 | $col .= ',(SELECT email04 FROM dtb_baseinfo limit 1) AS email '; // 代表Emailアドレス |
---|
110 | $from = 'dtb_news'; |
---|
111 | $where = "del_flg = '0'"; |
---|
112 | $order = 'rank DESC'; |
---|
113 | $objQuery->setOrder($order); |
---|
114 | $arrNews = $objQuery->select($col,$from,$where); |
---|
115 | |
---|
116 | // RSS用に変換 |
---|
117 | foreach (array_keys($arrNews) as $key) { |
---|
118 | $netUrlHttpUrl = new Net_URL(HTTP_URL); |
---|
119 | |
---|
120 | $row =& $arrNews[$key]; |
---|
121 | // 日付 |
---|
122 | $row['news_date'] = date('r', strtotime($row['news_date'])); |
---|
123 | // 新着情報URL |
---|
124 | if (SC_Utils_Ex::isBlank($row['news_url'])) { |
---|
125 | $row['news_url'] = HTTP_URL; |
---|
126 | } elseif ($row['news_url'][0] == '/') { |
---|
127 | // 変換(絶対パス→URL) |
---|
128 | $netUrl = new Net_URL($row['news_url']); |
---|
129 | $netUrl->protocol = $netUrlHttpUrl->protocol; |
---|
130 | $netUrl->user = $netUrlHttpUrl->user; |
---|
131 | $netUrl->pass = $netUrlHttpUrl->pass; |
---|
132 | $netUrl->host = $netUrlHttpUrl->host; |
---|
133 | $netUrl->port = $netUrlHttpUrl->port; |
---|
134 | $row['news_url'] = $netUrl->getUrl(); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | return $arrNews; |
---|
139 | } |
---|
140 | } |
---|