[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] | 25 | require_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 | */ |
---|
[20344] | 34 | class LC_Page_RSS extends LC_Page_Ex { |
---|
[16192] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
[21514] | 46 | $this->tpl_mainpage = 'rss/index.tpl'; |
---|
| 47 | $this->encode = 'UTF-8'; |
---|
| 48 | $this->description = '新着情報'; |
---|
[16192] | 49 | } |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * Page のプロセス. |
---|
| 53 | * |
---|
| 54 | * @return void |
---|
| 55 | */ |
---|
| 56 | function process() { |
---|
[21596] | 57 | |
---|
[20507] | 58 | $objQuery = SC_Query_Ex::getSingletonInstance(); |
---|
[20306] | 59 | $objView = new SC_SiteView_Ex(false); |
---|
[16192] | 60 | |
---|
| 61 | //新着情報を取得 |
---|
| 62 | $arrNews = $this->lfGetNews($objQuery); |
---|
[20540] | 63 | |
---|
[16192] | 64 | //キャッシュしない(念のため) |
---|
[21514] | 65 | header('pragma: no-cache'); |
---|
[16192] | 66 | |
---|
| 67 | //XMLテキスト(これがないと正常にRSSとして認識してくれないツールがあるため) |
---|
[21514] | 68 | header('Content-type: application/xml'); |
---|
[16192] | 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 | |
---|
[21596] | 82 | |
---|
[16192] | 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 | */ |
---|
[21479] | 102 | function lfGetNews(&$objQuery) { |
---|
[21514] | 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アドレス |
---|
[21481] | 112 | $from = 'dtb_news'; |
---|
[16192] | 113 | $where = "del_flg = '0'"; |
---|
[21514] | 114 | $order = 'rank DESC'; |
---|
[18675] | 115 | $objQuery->setOrder($order); |
---|
[16192] | 116 | $arrNews = $objQuery->select($col,$from,$where); |
---|
[20540] | 117 | |
---|
[17921] | 118 | // RSS用に変換 |
---|
[21935] | 119 | foreach ($arrNews as $key => $value) { |
---|
[21121] | 120 | $netUrlHttpUrl = new Net_URL(HTTP_URL); |
---|
| 121 | |
---|
[17921] | 122 | $row =& $arrNews[$key]; |
---|
| 123 | // 日付 |
---|
| 124 | $row['news_date'] = date('r', strtotime($row['news_date'])); |
---|
[21121] | 125 | // 新着情報URL |
---|
| 126 | if (SC_Utils_Ex::isBlank($row['news_url'])) { |
---|
| 127 | $row['news_url'] = HTTP_URL; |
---|
[21442] | 128 | } elseif ($row['news_url'][0] == '/') { |
---|
[21121] | 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 | } |
---|
[17921] | 138 | } |
---|
[20540] | 139 | |
---|
[16192] | 140 | return $arrNews; |
---|
| 141 | } |
---|
| 142 | } |
---|