OXID eShop CE  4.9.7
 All Classes 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 
185  public function getRecommId()
186  {
187  return $this->getViewParameter('recommid');
188  }
189 
195  public function getIteration()
196  {
197  return $this->getViewParameter('iIteration');
198  }
199 
205  public function getRSSLinks()
206  {
207  $aRSS = $this->getViewParameter('rsslinks');
208  if (!is_array($aRSS)) {
209  $aRSS = null;
210  }
211 
212  return $aRSS;
213  }
214 
220  public function getShowMainLink()
221  {
222  return (bool) $this->getViewParameter('showMainLink');
223  }
224 
230  public function getAltProduct()
231  {
232  return (bool) $this->getViewParameter('altproduct');
233  }
234 
243  protected function _addDynParamsToLink($sAddDynParams, $oArticle)
244  {
245  $blAddedParams = false;
246  if ($sAddDynParams) {
247  $blSeo = oxRegistry::getUtils()->seoIsActive();
248  if (!$blSeo) {
249  // only if seo is off..
250  $oArticle->appendStdLink($sAddDynParams);
251  }
252  $oArticle->appendLink($sAddDynParams);
253  $blAddedParams = true;
254  }
255 
256  return $blAddedParams;
257  }
258 
266  protected function _getArticleById($sArticleId)
267  {
269  $oArticle = oxNew('oxArticle');
270  $oArticle->load($sArticleId);
271  $iLinkType = $this->getViewParameter('iLinkType');
272 
273  if ($this->getViewParameter('inlist')) {
274  $oArticle->setInList();
275  }
276  if ($iLinkType) {
277  $oArticle->setLinkType($iLinkType);
278  }
279  if ($oRecommList = $this->getActiveRecommList()) {
280  $oArticle->text = $oRecommList->getArtDescription($oArticle->getId());
281  }
282 
283  return $oArticle;
284  }
285 }