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 
00026 
00031     protected $_sThisTemplate = 'widget/rss.tpl';
00032 
00038     protected function _getRssFeed()
00039     {
00040         if (!$this->_oRss) {
00041             $this->_oRss = oxNew('oxRssFeed');
00042         }
00043         return $this->_oRss;
00044     }
00045 
00054     public function render()
00055     {
00056         parent::render();
00057 
00058         $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00059 
00060         // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU
00061         // as SMARTY_PHP_REMOVE removes not only php tags, but also xml
00062         if ($this->getConfig()->isDemoShop()) {
00063             $oSmarty->php_handling = SMARTY_PHP_PASSTHRU;
00064         }
00065 
00066         foreach ( array_keys( $this->_aViewData ) as $sViewName ) {
00067             $oSmarty->assign_by_ref( $sViewName, $this->_aViewData[$sViewName] );
00068         }
00069 
00070         // return rss xml, no further processing
00071         oxRegistry::getUtils()->setHeader( "Content-Type: text/xml; charset=".oxRegistry::getLang()->translateString( "charset" ) );
00072         oxRegistry::getUtils()->showMessageAndExit(
00073                     $this->_processOutput(
00074                             $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
00075                     )
00076                 );
00077     }
00078 
00086     protected function _processOutput( $sInput )
00087     {
00088         return getStr()->recodeEntities( $sInput );
00089     }
00090 
00097     public function topshop()
00098     {
00099         if ($this->getConfig()->getConfigParam( 'bl_rssTopShop' )) {
00100             $this->_getRssFeed()->loadTopInShop();
00101         } else {
00102             error_404_handler();
00103         }
00104     }
00105 
00112     public function newarts()
00113     {
00114         if ($this->getConfig()->getConfigParam( 'bl_rssNewest' )) {
00115             $this->_getRssFeed()->loadNewestArticles();
00116         } else {
00117             error_404_handler();
00118         }
00119     }
00120 
00127     public function catarts()
00128     {
00129         if ($this->getConfig()->getConfigParam( 'bl_rssCategories' )) {
00130             $oCat = oxNew('oxCategory');
00131             if ($oCat->load(oxConfig::getParameter('cat'))) {
00132                 $this->_getRssFeed()->loadCategoryArticles($oCat);
00133             }
00134         } else {
00135             error_404_handler();
00136         }
00137     }
00138 
00145     public function searcharts()
00146     {
00147         if ($this->getConfig()->getConfigParam( 'bl_rssSearch' )) {
00148             $this->_getRssFeed()->loadSearchArticles( oxConfig::getParameter('searchparam', true), oxConfig::getParameter('searchcnid'), oxConfig::getParameter('searchvendor'), oxConfig::getParameter('searchmanufacturer'));
00149         } else {
00150             error_404_handler();
00151         }
00152     }
00153 
00160     public function recommlists()
00161     {
00162         if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam( 'bl_rssRecommLists' )) {
00163             $oArticle = oxNew('oxarticle');
00164             if ($oArticle->load(oxConfig::getParameter('anid'))) {
00165                 $this->_getRssFeed()->loadRecommLists($oArticle);
00166                 return;
00167             }
00168         }
00169         error_404_handler();
00170     }
00171 
00178     public function recommlistarts()
00179     {
00180         if ($this->getConfig()->getConfigParam( 'bl_rssRecommListArts' )) {
00181             $oRecommList = oxNew('oxrecommlist');
00182             if ($oRecommList->load(oxConfig::getParameter('recommid'))) {
00183                 $this->_getRssFeed()->loadRecommListArticles($oRecommList);
00184                 return;
00185             }
00186         }
00187         error_404_handler();
00188     }
00189 
00196     public function bargain()
00197     {
00198         if ($this->getConfig()->getConfigParam( 'bl_rssBargain' )) {
00199             $this->_getRssFeed()->loadBargain();
00200         } else {
00201             error_404_handler();
00202         }
00203     }
00204 
00210     public function getChannel()
00211     {
00212         if ( $this->_oChannel === null ) {
00213             $this->_oChannel = $this->_getRssFeed()->getChannel();
00214         }
00215         return $this->_oChannel;
00216     }
00217 
00223     public function getCacheLifeTime()
00224     {
00225         return $this->_getRssFeed()->getCacheTtl();
00226     }
00227 
00228 }