source: branches/feature-module-update/data/class/pages/rss/LC_Page_Rss.php @ 16582

Revision 16582, 4.6 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Date Revision
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.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 {
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 = new SC_Query();
58        $objView = new SC_SiteView(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        $this->timestamp = SC_Utils_Ex::sf_mktime("r", $arrNews[0]['HOUR'], $arrNews[0]['MINUTE'], $arrNews[0]['SECOND'], $arrNews[0]['MONTH'], $arrNews[0]['DAY'], $arrNews[0]['YEAR']);
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        $objView->display($this->tpl_mainpage, true);
84    }
85
86    /**
87     * デストラクタ.
88     *
89     * @return void
90     */
91    function destroy() {
92        parent::destroy();
93    }
94
95    /**
96     * 新着情報を取得する
97     *
98     * @param SC_Query $objQuery DB操作クラス
99     * @return array $arrNews 取得結果を配列で返す
100     */
101    function lfGetNews(&$objQuery){
102        $col = "";
103        $col .= "     news_id ";                                //新着情報ID
104        $col .= "     ,news_title ";                            //新着情報タイトル
105        $col .= "     ,news_comment ";                          //新着情報本文
106
107        if (DB_TYPE == "pgsql") {
108            $col .= "     ,to_char(news_date, 'YYYY') AS YEAR ";    //日付(年)
109            $col .= "     ,to_char(news_date, 'MM') AS MONTH ";     //日付(月)
110            $col .= "     ,to_char(news_date, 'DD') AS DAY ";       //日付(日)
111            $col .= "     ,to_char(news_date, 'HH24') AS HOUR ";    //日付(時間)
112            $col .= "     ,to_char(news_date, 'MI') AS MINUTE ";    //日付(分)
113            $col .= "     ,to_char(news_date, 'SS') AS SECOND ";    //日付(秒)
114        }else if (DB_TYPE == "mysql") {
115            $col .= "     ,DATE_FORMAT(news_date, '%Y') AS YEAR ";      //日付(年)
116            $col .= "     ,DATE_FORMAT(news_date, '%m') AS MONTH ";     //日付(月)
117            $col .= "     ,DATE_FORMAT(news_date, '%d') AS DAY ";       //日付(日)
118            $col .= "     ,DATE_FORMAT(news_date, '%H') AS HOUR ";      //日付(時間)
119            $col .= "     ,DATE_FORMAT(news_date, '%i') AS MINUTE ";    //日付(分)
120            $col .= "     ,DATE_FORMAT(news_date, '%s') AS SECOND ";    //日付(秒)
121        }
122        $col .= "     ,news_url ";                              //新着情報URL
123        $col .= "     ,news_select ";                           //新着情報の区分(1:URL、2:本文)
124        $col .= "     ,(SELECT shop_name FROM dtb_baseinfo limit 1) AS shop_name  ";    //店名
125        $col .= "     ,(SELECT email04 FROM dtb_baseinfo limit 1) AS email ";           //代表Emailアドレス
126        $from = "dtb_news";
127        $where = "del_flg = '0'";
128        $order = "rank DESC";
129        $objQuery->setorder($order);
130        $arrNews = $objQuery->select($col,$from,$where);
131        return $arrNews;
132    }
133}
134?>
Note: See TracBrowser for help on using the repository browser.