OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
rss.php
Go to the documentation of this file.
1 <?php
2 
6 class Rss extends oxUBase
7 {
8 
14  protected $_oRss = null;
15 
21  protected $_oChannel = null;
22 
28  protected $_aXmlDef = null;
29 
30 
36  protected $_sThisTemplate = 'widget/rss.tpl';
37 
43  protected function _getRssFeed()
44  {
45  if (!$this->_oRss) {
46  $this->_oRss = oxNew('oxRssFeed');
47  }
48 
49  return $this->_oRss;
50  }
51 
58  public function render()
59  {
61 
62  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
63 
64  // #2873: In demoshop for RSS we set php_handling to SMARTY_PHP_PASSTHRU
65  // as SMARTY_PHP_REMOVE removes not only php tags, but also xml
66  if ($this->getConfig()->isDemoShop()) {
67  $oSmarty->php_handling = SMARTY_PHP_PASSTHRU;
68  }
69 
70  foreach (array_keys($this->_aViewData) as $sViewName) {
71  $oSmarty->assign_by_ref($sViewName, $this->_aViewData[$sViewName]);
72  }
73 
74  // return rss xml, no further processing
75  $sCharset = oxRegistry::getLang()->translateString("charset");
76  oxRegistry::getUtils()->setHeader("Content-Type: text/xml; charset=" . $sCharset);
77  oxRegistry::getUtils()->showMessageAndExit(
78  $this->_processOutput(
79  $oSmarty->fetch($this->_sThisTemplate, $this->getViewId())
80  )
81  );
82  }
83 
91  protected function _processOutput($sInput)
92  {
93  return getStr()->recodeEntities($sInput);
94  }
95 
101  public function topshop()
102  {
103  if ($this->getConfig()->getConfigParam('bl_rssTopShop')) {
104  $this->_getRssFeed()->loadTopInShop();
105  } else {
106  error_404_handler();
107  }
108  }
109 
115  public function newarts()
116  {
117  if ($this->getConfig()->getConfigParam('bl_rssNewest')) {
118  $this->_getRssFeed()->loadNewestArticles();
119  } else {
120  error_404_handler();
121  }
122  }
123 
129  public function catarts()
130  {
131  if ($this->getConfig()->getConfigParam('bl_rssCategories')) {
132  $oCat = oxNew('oxCategory');
133  if ($oCat->load(oxRegistry::getConfig()->getRequestParameter('cat'))) {
134  $this->_getRssFeed()->loadCategoryArticles($oCat);
135  }
136  } else {
137  error_404_handler();
138  }
139  }
140 
146  public function searcharts()
147  {
148  if ($this->getConfig()->getConfigParam('bl_rssSearch')) {
149  $sSearchParameter = oxRegistry::getConfig()->getRequestParameter('searchparam', true);
150  $sCatId = oxRegistry::getConfig()->getRequestParameter('searchcnid');
151  $sVendorId = oxRegistry::getConfig()->getRequestParameter('searchvendor');
152  $sManufacturerId = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer');
153 
154  $this->_getRssFeed()->loadSearchArticles($sSearchParameter, $sCatId, $sVendorId, $sManufacturerId);
155  } else {
156  error_404_handler();
157  }
158  }
159 
169  public function recommlists()
170  {
171  if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam('bl_rssRecommLists')) {
172  $oArticle = oxNew('oxarticle');
173  if ($oArticle->load(oxRegistry::getConfig()->getRequestParameter('anid'))) {
174  $this->_getRssFeed()->loadRecommLists($oArticle);
175 
176  return;
177  }
178  }
179  error_404_handler();
180  }
181 
191  public function recommlistarts()
192  {
193  if ($this->getConfig()->getConfigParam('bl_rssRecommListArts')) {
194  $oRecommList = oxNew('oxrecommlist');
195  if ($oRecommList->load(oxRegistry::getConfig()->getRequestParameter('recommid'))) {
196  $this->_getRssFeed()->loadRecommListArticles($oRecommList);
197 
198  return;
199  }
200  }
201  error_404_handler();
202  }
203 
209  public function bargain()
210  {
211  if ($this->getConfig()->getConfigParam('bl_rssBargain')) {
212  $this->_getRssFeed()->loadBargain();
213  } else {
214  error_404_handler();
215  }
216  }
217 
223  public function getChannel()
224  {
225  if ($this->_oChannel === null) {
226  $this->_oChannel = $this->_getRssFeed()->getChannel();
227  }
228 
229  return $this->_oChannel;
230  }
231 
237  public function getCacheLifeTime()
238  {
239  return $this->_getRssFeed()->getCacheTtl();
240  }
241 }