rss.php

Go to the documentation of this file.
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 = 'widget/rss.tpl';
00031 
00037     protected function _getRssFeed()
00038     {
00039         if (!$this->_oRss) {
00040             $this->_oRss = oxNew('oxRssFeed');
00041         }
00042         return $this->_oRss;
00043     }
00044 
00053     public function render()
00054     {
00055         parent::render();
00056 
00057         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00058 
00059         // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU
00060         // as SMARTY_PHP_REMOVE removes not only php tags, but also xml
00061         if ($this->getConfig()->isDemoShop()) {
00062             $oSmarty->php_handling = SMARTY_PHP_PASSTHRU;
00063         }
00064 
00065         foreach ( array_keys( $this->_aViewData ) as $sViewName ) {
00066             $oSmarty->assign_by_ref( $sViewName, $this->_aViewData[$sViewName] );
00067         }
00068 
00069         // variables are set as deprecated, use getters
00070        // $oSmarty->assign('xmldef', $this->getXmlDef());
00071 
00072         // return rss xml, no further processing
00073         oxUtils::getInstance()->setHeader( "Content-Type: text/xml; charset=".oxLang::getInstance()->translateString( "charset" ) );
00074         oxUtils::getInstance()->showMessageAndExit(
00075                     $this->_processOutput(
00076                             $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
00077                     )
00078                 );
00079     }
00080 
00088     protected function _processOutput( $sInput )
00089     {
00090         return getStr()->recodeEntities( $sInput );
00091     }
00092 
00099     public function topshop()
00100     {
00101         if ($this->getConfig()->getConfigParam( 'bl_rssTopShop' )) {
00102             $this->_getRssFeed()->loadTopInShop();
00103         } else {
00104             error_404_handler();
00105         }
00106     }
00107 
00114     public function newarts()
00115     {
00116         if ($this->getConfig()->getConfigParam( 'bl_rssNewest' )) {
00117             $this->_getRssFeed()->loadNewestArticles();
00118         } else {
00119             error_404_handler();
00120         }
00121     }
00122 
00129     public function catarts()
00130     {
00131         if ($this->getConfig()->getConfigParam( 'bl_rssCategories' )) {
00132             $oCat = oxNew('oxCategory');
00133             if ($oCat->load(oxConfig::getParameter('cat'))) {
00134                 $this->_getRssFeed()->loadCategoryArticles($oCat);
00135             }
00136         } else {
00137             error_404_handler();
00138         }
00139     }
00140 
00147     public function searcharts()
00148     {
00149         if ($this->getConfig()->getConfigParam( 'bl_rssSearch' )) {
00150             $this->_getRssFeed()->loadSearchArticles( oxConfig::getParameter('searchparam', true), oxConfig::getParameter('searchcnid'), oxConfig::getParameter('searchvendor'), oxConfig::getParameter('searchmanufacturer'));
00151         } else {
00152             error_404_handler();
00153         }
00154     }
00155 
00162     public function recommlists()
00163     {
00164         if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam( 'bl_rssRecommLists' )) {
00165             $oArticle = oxNew('oxarticle');
00166             if ($oArticle->load(oxConfig::getParameter('anid'))) {
00167                 $this->_getRssFeed()->loadRecommLists($oArticle);
00168                 return;
00169             }
00170         }
00171         error_404_handler();
00172     }
00173 
00180     public function recommlistarts()
00181     {
00182         if ($this->getConfig()->getConfigParam( 'bl_rssRecommListArts' )) {
00183             $oRecommList = oxNew('oxrecommlist');
00184             if ($oRecommList->load(oxConfig::getParameter('recommid'))) {
00185                 $this->_getRssFeed()->loadRecommListArticles($oRecommList);
00186                 return;
00187             }
00188         }
00189         error_404_handler();
00190     }
00191 
00198     public function bargain()
00199     {
00200         if ($this->getConfig()->getConfigParam( 'bl_rssBargain' )) {
00201             $this->_getRssFeed()->loadBargain();
00202         } else {
00203             error_404_handler();
00204         }
00205     }
00206 
00212     public function getChannel()
00213     {
00214         if ( $this->_oChannel === null ) {
00215             $this->_oChannel = $this->_getRssFeed()->getChannel();
00216         }
00217         return $this->_oChannel;
00218     }
00219 
00227     public function getXmlDef()
00228     {
00229         if ( $this->_aXmlDef === null ) {
00230             $this->_aXmlDef = false;
00231             $this->_aXmlDef = array('start'=>'<?xml', 'end'=>'?>');
00232         }
00233         return $this->_aXmlDef;
00234     }
00235 
00236 }