OXID eShop CE  4.9.9
 All Classes 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 
166  public function recommlists()
167  {
168  if ($this->getViewConfig()->getShowListmania() && $this->getConfig()->getConfigParam('bl_rssRecommLists')) {
169  $oArticle = oxNew('oxarticle');
170  if ($oArticle->load(oxRegistry::getConfig()->getRequestParameter('anid'))) {
171  $this->_getRssFeed()->loadRecommLists($oArticle);
172 
173  return;
174  }
175  }
176  error_404_handler();
177  }
178 
185  public function recommlistarts()
186  {
187  if ($this->getConfig()->getConfigParam('bl_rssRecommListArts')) {
188  $oRecommList = oxNew('oxrecommlist');
189  if ($oRecommList->load(oxRegistry::getConfig()->getRequestParameter('recommid'))) {
190  $this->_getRssFeed()->loadRecommListArticles($oRecommList);
191 
192  return;
193  }
194  }
195  error_404_handler();
196  }
197 
203  public function bargain()
204  {
205  if ($this->getConfig()->getConfigParam('bl_rssBargain')) {
206  $this->_getRssFeed()->loadBargain();
207  } else {
208  error_404_handler();
209  }
210  }
211 
217  public function getChannel()
218  {
219  if ($this->_oChannel === null) {
220  $this->_oChannel = $this->_getRssFeed()->getChannel();
221  }
222 
223  return $this->_oChannel;
224  }
225 
231  public function getCacheLifeTime()
232  {
233  return $this->_getRssFeed()->getCacheTtl();
234  }
235 }