Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Rss.php

Documentation is available at LC_Page_Rss.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2010 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_PATH "pages/LC_Page.php");
  26.  
  27. /**
  28.  * RSS のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id: LC_Page_Rss.php 18735 2010-06-22 08:53:31Z nanasess $
  33.  */
  34. class 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.         // XXX 2.4.3 以下の互換性確保
  72.         $this->timestamp $arrNews[0]['news_date'];
  73.  
  74.         //店名をセット
  75.         $this->site_title $arrNews[0]['shop_name'];
  76.  
  77.         //代表Emailアドレスをセット
  78.         $this->email $arrNews[0]['email'];
  79.  
  80.         //セットしたデータをテンプレートファイルに出力
  81.         $objView->assignobj($this);
  82.  
  83.         //画面表示
  84.         $objView->display($this->tpl_mainpagetrue);
  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 (array_keys($arrNewsas $key{
  120.             $row =$arrNews[$key];
  121.             // 日付
  122.             $row['news_date'date("r"strtotime($row['news_date']));
  123.         }
  124.  
  125.         return $arrNews;
  126.     }
  127. }
  128. ?>

Documentation generated on Fri, 24 Feb 2012 13:59:46 +0900 by Seasoft