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         foreach ( array_keys( $this->_aViewData ) as $sViewName ) {
00060             $oSmarty->assign_by_ref( $sViewName, $this->_aViewData[$sViewName] );
00061         }
00062 
00063         // variables are set as deprecated, use getters
00064        // $oSmarty->assign('xmldef', $this->getXmlDef());
00065 
00066         // return rss xml, no further processing
00067         oxUtils::getInstance()->setHeader( "Content-Type: text/xml; charset=".oxLang::getInstance()->translateString( "charset" ) );
00068         oxUtils::getInstance()->showMessageAndExit(
00069                     $this->_processOutput(
00070                             $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
00071                     )
00072                 );
00073     }
00074 
00082     protected function _processOutput( $sInput )
00083     {
00084         return getStr()->recodeEntities( $sInput );
00085     }
00086 
00093     public function topshop()
00094     {
00095         if ($this->getConfig()->getConfigParam( 'bl_rssTopShop' )) {
00096             $this->_getRssFeed()->loadTopInShop();
00097         } else {
00098             error_404_handler();
00099         }
00100     }
00101 
00108     public function newarts()
00109     {
00110         if ($this->getConfig()->getConfigParam( 'bl_rssNewest' )) {
00111             $this->_getRssFeed()->loadNewestArticles();
00112         } else {
00113             error_404_handler();
00114         }
00115     }
00116 
00123     public function catarts()
00124     {
00125         if ($this->getConfig()->getConfigParam( 'bl_rssCategories' )) {
00126             $oCat = oxNew('oxCategory');
00127             if ($oCat->load(oxConfig::getParameter('cat'))) {
00128                 $this->_getRssFeed()->loadCategoryArticles($oCat);
00129             }
00130         } else {
00131             error_404_handler();
00132         }
00133     }
00134 
00141     public function searcharts()
00142     {
00143         if ($this->getConfig()->getConfigParam( 'bl_rssSearch' )) {
00144             $this->_getRssFeed()->loadSearchArticles( oxConfig::getParameter('searchparam', true), oxConfig::getParameter('searchcnid'), oxConfig::getParameter('searchvendor'), oxConfig::getParameter('searchmanufacturer'));
00145         } else {
00146             error_404_handler();
00147         }
00148     }
00149 
00156     public function recommlists()
00157     {
00158         if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam( 'bl_rssRecommLists' )) {
00159             $oArticle = oxNew('oxarticle');
00160             if ($oArticle->load(oxConfig::getParameter('anid'))) {
00161                 $this->_getRssFeed()->loadRecommLists($oArticle);
00162                 return;
00163             }
00164         }
00165         error_404_handler();
00166     }
00167 
00174     public function recommlistarts()
00175     {
00176         if ($this->getConfig()->getConfigParam( 'bl_rssRecommListArts' )) {
00177             $oRecommList = oxNew('oxrecommlist');
00178             if ($oRecommList->load(oxConfig::getParameter('recommid'))) {
00179                 $this->_getRssFeed()->loadRecommListArticles($oRecommList);
00180                 return;
00181             }
00182         }
00183         error_404_handler();
00184     }
00185 
00192     public function bargain()
00193     {
00194         if ($this->getConfig()->getConfigParam( 'bl_rssBargain' )) {
00195             $this->_getRssFeed()->loadBargain();
00196         } else {
00197             error_404_handler();
00198         }
00199     }
00200 
00206     public function getChannel()
00207     {
00208         if ( $this->_oChannel === null ) {
00209             $this->_oChannel = $this->_getRssFeed()->getChannel();
00210         }
00211         return $this->_oChannel;
00212     }
00213 
00221     public function getXmlDef()
00222     {
00223         if ( $this->_aXmlDef === null ) {
00224             $this->_aXmlDef = false;
00225             $this->_aXmlDef = array('start'=>'<?xml', 'end'=>'?>');
00226         }
00227         return $this->_aXmlDef;
00228     }
00229 
00230 }