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

Revision 22567, 4.3 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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