OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
rss.php
Go to the documentation of this file.
1 <?php
2 
6 class Rss extends oxUBase
7 {
12  protected $_oRss = null;
13 
18  protected $_oChannel = null;
19 
24  protected $_aXmlDef = null;
25 
26 
31  protected $_sThisTemplate = 'widget/rss.tpl';
32 
38  protected function _getRssFeed()
39  {
40  if (!$this->_oRss) {
41  $this->_oRss = oxNew('oxRssFeed');
42  }
43  return $this->_oRss;
44  }
45 
54  public function render()
55  {
57 
58  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
59 
60  // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU
61  // as SMARTY_PHP_REMOVE removes not only php tags, but also xml
62  if ($this->getConfig()->isDemoShop()) {
63  $oSmarty->php_handling = SMARTY_PHP_PASSTHRU;
64  }
65 
66  foreach ( array_keys( $this->_aViewData ) as $sViewName ) {
67  $oSmarty->assign_by_ref( $sViewName, $this->_aViewData[$sViewName] );
68  }
69 
70  // return rss xml, no further processing
71  oxRegistry::getUtils()->setHeader( "Content-Type: text/xml; charset=".oxRegistry::getLang()->translateString( "charset" ) );
72  oxRegistry::getUtils()->showMessageAndExit(
73  $this->_processOutput(
74  $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
75  )
76  );
77  }
78 
86  protected function _processOutput( $sInput )
87  {
88  return getStr()->recodeEntities( $sInput );
89  }
90 
97  public function topshop()
98  {
99  if ($this->getConfig()->getConfigParam( 'bl_rssTopShop' )) {
100  $this->_getRssFeed()->loadTopInShop();
101  } else {
102  error_404_handler();
103  }
104  }
105 
112  public function newarts()
113  {
114  if ($this->getConfig()->getConfigParam( 'bl_rssNewest' )) {
115  $this->_getRssFeed()->loadNewestArticles();
116  } else {
117  error_404_handler();
118  }
119  }
120 
127  public function catarts()
128  {
129  if ($this->getConfig()->getConfigParam( 'bl_rssCategories' )) {
130  $oCat = oxNew('oxCategory');
131  if ($oCat->load(oxConfig::getParameter('cat'))) {
132  $this->_getRssFeed()->loadCategoryArticles($oCat);
133  }
134  } else {
135  error_404_handler();
136  }
137  }
138 
145  public function searcharts()
146  {
147  if ($this->getConfig()->getConfigParam( 'bl_rssSearch' )) {
148  $this->_getRssFeed()->loadSearchArticles( oxConfig::getParameter('searchparam', true), oxConfig::getParameter('searchcnid'), oxConfig::getParameter('searchvendor'), oxConfig::getParameter('searchmanufacturer'));
149  } else {
150  error_404_handler();
151  }
152  }
153 
160  public function recommlists()
161  {
162  if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam( 'bl_rssRecommLists' )) {
163  $oArticle = oxNew('oxarticle');
164  if ($oArticle->load(oxConfig::getParameter('anid'))) {
165  $this->_getRssFeed()->loadRecommLists($oArticle);
166  return;
167  }
168  }
169  error_404_handler();
170  }
171 
178  public function recommlistarts()
179  {
180  if ($this->getConfig()->getConfigParam( 'bl_rssRecommListArts' )) {
181  $oRecommList = oxNew('oxrecommlist');
182  if ($oRecommList->load(oxConfig::getParameter('recommid'))) {
183  $this->_getRssFeed()->loadRecommListArticles($oRecommList);
184  return;
185  }
186  }
187  error_404_handler();
188  }
189 
196  public function bargain()
197  {
198  if ($this->getConfig()->getConfigParam( 'bl_rssBargain' )) {
199  $this->_getRssFeed()->loadBargain();
200  } else {
201  error_404_handler();
202  }
203  }
204 
210  public function getChannel()
211  {
212  if ( $this->_oChannel === null ) {
213  $this->_oChannel = $this->_getRssFeed()->getChannel();
214  }
215  return $this->_oChannel;
216  }
217 
223  public function getCacheLifeTime()
224  {
225  return $this->_getRssFeed()->getCacheTtl();
226  }
227 
228 }