00001 <?php
00002
00006 class Rss extends oxUBase
00007 {
00012 protected $_oRss = null;
00013
00018 protected $_oChannel = null;
00019
00024 protected $_aXmlDef = null;
00025
00030 protected $_sThisTemplate = 'rss.tpl';
00031
00038 public function init()
00039 {
00040 if (null !== ($iCur = oxConfig::getParameter('cur'))) {
00041 oxSession::setVar('currency', (int) $iCur);
00042 }
00043 parent::init();
00044 $this->_oRss = oxNew('oxRssFeed');
00045 }
00046
00055 public function render()
00056 {
00057 parent::render();
00058
00059 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00060
00061 foreach ( array_keys( $this->_aViewData ) as $sViewName ) {
00062 $oSmarty->assign_by_ref( $sViewName, $this->_aViewData[$sViewName] );
00063 }
00064
00065 $oSmarty->assign('channel', $this->getChannel());
00066 $oSmarty->assign('xmldef', $this->getXmlDef());
00067
00068 header ("content-type: text/xml");
00069
00070
00071 echo $this->_processOutput( $oSmarty->fetch('rss.tpl', $this->getViewId()) );
00072
00073
00074 exit (0);
00075 }
00076
00084 protected function _processOutput( $sInput )
00085 {
00086 return getStr()->recodeEntities( $sInput );
00087 }
00088
00095 public function topshop()
00096 {
00097 if (in_array('oxrss_topshop', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00098 $this->_oRss->loadTopInShop();
00099 } else {
00100 error_404_handler();
00101 }
00102 }
00103
00110 public function newarts()
00111 {
00112 if (in_array('oxrss_newest', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00113 $this->_oRss->loadNewestArticles();
00114 } else {
00115 error_404_handler();
00116 }
00117 }
00118
00125 public function catarts()
00126 {
00127 if (in_array('oxrss_categories', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00128 $oCat = oxNew('oxCategory');
00129 if ($oCat->load(oxConfig::getParameter('cat'))) {
00130 $this->_oRss->loadCategoryArticles($oCat);
00131 }
00132 } else {
00133 error_404_handler();
00134 }
00135 }
00136
00143 public function searcharts()
00144 {
00145 if (in_array('oxrss_search', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00146 $this->_oRss->loadSearchArticles( oxConfig::getParameter('searchparam', true), oxConfig::getParameter('searchcnid'), oxConfig::getParameter('searchvendor'), oxConfig::getParameter('searchmanufacturer'));
00147 } else {
00148 error_404_handler();
00149 }
00150 }
00151
00158 public function recommlists()
00159 {
00160 if (in_array('oxrss_recommlists', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00161 $oArticle = oxNew('oxarticle');
00162 if ($oArticle->load(oxConfig::getParameter('anid'))) {
00163 $this->_oRss->loadRecommLists($oArticle);
00164 return;
00165 }
00166 }
00167 error_404_handler();
00168 }
00169
00176 public function recommlistarts()
00177 {
00178 if (in_array('oxrss_recommlistarts', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00179 $oRecommList = oxNew('oxrecommlist');
00180 if ($oRecommList->load(oxConfig::getParameter('recommid'))) {
00181 $this->_oRss->loadRecommListArticles($oRecommList);
00182 return;
00183 }
00184 }
00185 error_404_handler();
00186 }
00187
00194 public function bargain()
00195 {
00196 if (in_array('oxrss_bargain', $this->getConfig()->getConfigParam( 'aRssSelected' ))) {
00197 $this->_oRss->loadBargain();
00198 } else {
00199 error_404_handler();
00200 }
00201 }
00202
00208 public function getChannel()
00209 {
00210 if ( $this->_oChannel === null ) {
00211 $this->_oChannel = false;
00212 if ( $this->_oRss ) {
00213 $this->_oChannel = $this->_oRss->getChannel();
00214 }
00215 }
00216 return $this->_oChannel;
00217 }
00218
00224 public function getXmlDef()
00225 {
00226 if ( $this->_aXmlDef === null ) {
00227 $this->_aXmlDef = false;
00228 $this->_aXmlDef = array('start'=>'<?xml', 'end'=>'?>');
00229 }
00230 return $this->_aXmlDef;
00231 }
00232
00233 }