OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
oxwarticlebox.php
Go to the documentation of this file.
1 <?php
2 
6 class oxwArticleBox extends oxWidget
7 {
8 
16  protected $_aComponentNames = array('oxcmp_user' => 1, 'oxcmp_basket' => 1, 'oxcmp_cur' => 1);
17 
23  protected $_sTemplate = 'widget/product/boxproduct.tpl';
24 
25 
31  protected $_oArticle = null;
32 
33 
39  public function getActiveCategory()
40  {
41  $oCategory = $this->getConfig()->getTopActiveView()->getActiveCategory();
42  if ($oCategory) {
43  $this->setActiveCategory($oCategory);
44  }
45 
46  return $this->_oActCategory;
47  }
48 
54  public function render()
55  {
57 
58  $sWidgetType = $this->getViewParameter('sWidgetType');
59  $sListType = $this->getViewParameter('sListType');
60 
61  if ($sWidgetType && $sListType) {
62  $this->_sTemplate = "widget/" . $sWidgetType . "/" . $sListType . ".tpl";
63  }
64 
65  $sForceTemplate = $this->getViewParameter('oxwtemplate');
66  if ($sForceTemplate) {
67  $this->_sTemplate = $sForceTemplate;
68  }
69 
70  return $this->_sTemplate;
71  }
72 
78  public function setProduct($oArticle)
79  {
80  $this->_oArticle = $oArticle;
81  }
82 
88  public function getProduct()
89  {
90  if (is_null($this->_oArticle)) {
91 
92  if ($this->getViewParameter('_object')) {
93  $oArticle = $this->getViewParameter('_object');
94  } else {
95  $sAddDynParams = $this->getConfig()->getTopActiveView()->getAddUrlParams();
96 
97 
98  $oArticle = $this->_getArticleById($this->getViewParameter('anid'));
99  $this->_addDynParamsToLink($sAddDynParams, $oArticle);
100  }
101 
102  $this->setProduct($oArticle);
103  }
104 
105  return $this->_oArticle;
106  }
107 
115  public function getLink($iLang = null)
116  {
117  return $this->getConfig()->getTopActiveView()->getLink($iLang);
118  }
119 
125  public function isVatIncluded()
126  {
127  return (bool) $this->getViewParameter("isVatIncluded");
128  }
129 
135  public function getWishId()
136  {
137  return $this->getViewParameter('owishid');
138  }
139 
145  public function getRemoveFunction()
146  {
147  return $this->getViewParameter('removeFunction');
148  }
149 
155  public function getToBasketFunction()
156  {
157  return $this->getViewParameter('toBasketFunction');
158  }
159 
165  public function getDisableToCart()
166  {
167  return (bool) $this->getViewParameter('blDisableToCart');
168  }
169 
175  public function getIndex()
176  {
177  return $this->getViewParameter('iIndex');
178  }
179 
187  public function getRecommId()
188  {
189  return $this->getViewParameter('recommid');
190  }
191 
197  public function getIteration()
198  {
199  return $this->getViewParameter('iIteration');
200  }
201 
207  public function getRSSLinks()
208  {
209  $aRSS = $this->getViewParameter('rsslinks');
210  if (!is_array($aRSS)) {
211  $aRSS = null;
212  }
213 
214  return $aRSS;
215  }
216 
222  public function getShowMainLink()
223  {
224  return (bool) $this->getViewParameter('showMainLink');
225  }
226 
232  public function getAltProduct()
233  {
234  return (bool) $this->getViewParameter('altproduct');
235  }
236 
245  protected function _addDynParamsToLink($sAddDynParams, $oArticle)
246  {
247  $blAddedParams = false;
248  if ($sAddDynParams) {
249  $blSeo = oxRegistry::getUtils()->seoIsActive();
250  if (!$blSeo) {
251  // only if seo is off..
252  $oArticle->appendStdLink($sAddDynParams);
253  }
254  $oArticle->appendLink($sAddDynParams);
255  $blAddedParams = true;
256  }
257 
258  return $blAddedParams;
259  }
260 
268  protected function _getArticleById($sArticleId)
269  {
271  $oArticle = oxNew('oxArticle');
272  $oArticle->load($sArticleId);
273  $iLinkType = $this->getViewParameter('iLinkType');
274 
275  if ($this->getViewParameter('inlist')) {
276  $oArticle->setInList();
277  }
278  if ($iLinkType) {
279  $oArticle->setLinkType($iLinkType);
280  }
281  // @deprecated since v5.3 (2016-06-17); Listmania will be moved to an own module.
282  if ($oRecommList = $this->getActiveRecommList()) {
283  $oArticle->text = $oRecommList->getArtDescription($oArticle->getId());
284  }
285  // END deprecated
286 
287  return $oArticle;
288  }
289 }