rss.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Rss extends oxUBase
00007 {
00008 
00014     protected $_oRss = null;
00015 
00021     protected $_oChannel = null;
00022 
00028     protected $_aXmlDef = null;
00029 
00030 
00036     protected $_sThisTemplate = 'widget/rss.tpl';
00037 
00043     protected function _getRssFeed()
00044     {
00045         if (!$this->_oRss) {
00046             $this->_oRss = oxNew('oxRssFeed');
00047         }
00048 
00049         return $this->_oRss;
00050     }
00051 
00058     public function render()
00059     {
00060         parent::render();
00061 
00062         $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00063 
00064         // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU
00065         // as SMARTY_PHP_REMOVE removes not only php tags, but also xml
00066         if ($this->getConfig()->isDemoShop()) {
00067             $oSmarty->php_handling = SMARTY_PHP_PASSTHRU;
00068         }
00069 
00070         foreach (array_keys($this->_aViewData) as $sViewName) {
00071             $oSmarty->assign_by_ref($sViewName, $this->_aViewData[$sViewName]);
00072         }
00073 
00074         // return rss xml, no further processing
00075         $sCharset = oxRegistry::getLang()->translateString("charset");
00076         oxRegistry::getUtils()->setHeader("Content-Type: text/xml; charset=" . $sCharset);
00077         oxRegistry::getUtils()->showMessageAndExit(
00078             $this->_processOutput(
00079                 $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
00080             )
00081         );
00082     }
00083 
00091     protected function _processOutput($sInput)
00092     {
00093         return getStr()->recodeEntities($sInput);
00094     }
00095 
00101     public function topshop()
00102     {
00103         if ($this->getConfig()->getConfigParam('bl_rssTopShop')) {
00104             $this->_getRssFeed()->loadTopInShop();
00105         } else {
00106             error_404_handler();
00107         }
00108     }
00109 
00115     public function newarts()
00116     {
00117         if ($this->getConfig()->getConfigParam('bl_rssNewest')) {
00118             $this->_getRssFeed()->loadNewestArticles();
00119         } else {
00120             error_404_handler();
00121         }
00122     }
00123 
00129     public function catarts()
00130     {
00131         if ($this->getConfig()->getConfigParam('bl_rssCategories')) {
00132             $oCat = oxNew('oxCategory');
00133             if ($oCat->load(oxRegistry::getConfig()->getRequestParameter('cat'))) {
00134                 $this->_getRssFeed()->loadCategoryArticles($oCat);
00135             }
00136         } else {
00137             error_404_handler();
00138         }
00139     }
00140 
00146     public function searcharts()
00147     {
00148         if ($this->getConfig()->getConfigParam('bl_rssSearch')) {
00149             $sSearchParameter = oxRegistry::getConfig()->getRequestParameter('searchparam', true);
00150             $sCatId = oxRegistry::getConfig()->getRequestParameter('searchcnid');
00151             $sVendorId = oxRegistry::getConfig()->getRequestParameter('searchvendor');
00152             $sManufacturerId = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer');
00153 
00154             $this->_getRssFeed()->loadSearchArticles($sSearchParameter, $sCatId, $sVendorId, $sManufacturerId);
00155         } else {
00156             error_404_handler();
00157         }
00158     }
00159 
00166     public function recommlists()
00167     {
00168         if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam('bl_rssRecommLists')) {
00169             $oArticle = oxNew('oxarticle');
00170             if ($oArticle->load(oxRegistry::getConfig()->getRequestParameter('anid'))) {
00171                 $this->_getRssFeed()->loadRecommLists($oArticle);
00172 
00173                 return;
00174             }
00175         }
00176         error_404_handler();
00177     }
00178 
00185     public function recommlistarts()
00186     {
00187         if ($this->getConfig()->getConfigParam('bl_rssRecommListArts')) {
00188             $oRecommList = oxNew('oxrecommlist');
00189             if ($oRecommList->load(oxRegistry::getConfig()->getRequestParameter('recommid'))) {
00190                 $this->_getRssFeed()->loadRecommListArticles($oRecommList);
00191 
00192                 return;
00193             }
00194         }
00195         error_404_handler();
00196     }
00197 
00203     public function bargain()
00204     {
00205         if ($this->getConfig()->getConfigParam('bl_rssBargain')) {
00206             $this->_getRssFeed()->loadBargain();
00207         } else {
00208             error_404_handler();
00209         }
00210     }
00211 
00217     public function getChannel()
00218     {
00219         if ($this->_oChannel === null) {
00220             $this->_oChannel = $this->_getRssFeed()->getChannel();
00221         }
00222 
00223         return $this->_oChannel;
00224     }
00225 
00231     public function getCacheLifeTime()
00232     {
00233         return $this->_getRssFeed()->getCacheTtl();
00234     }
00235 }