OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxwarticlebox.php
Go to the documentation of this file.
1 <?php
2 
6 class oxwArticleBox extends oxWidget
7 {
14  protected $_aComponentNames = array( 'oxcmp_user' => 1, 'oxcmp_basket' => 1, 'oxcmp_cur' => 1 );
15 
20  protected $_sTemplate = 'widget/product/boxproduct.tpl';
21 
22 
27  protected $_oArticle = null;
28 
29 
35  public function getActiveCategory()
36  {
37  $oCategory = $this->getConfig()->getTopActiveView()->getActiveCategory();
38  if ( $oCategory ) {
39  $this->setActiveCategory( $oCategory );
40  }
41  return $this->_oActCategory;
42  }
43 
49  public function render()
50  {
52 
53  $sWidgetType = $this->getViewParameter('sWidgetType');
54  $sListType = $this->getViewParameter('sListType');
55 
56  if ($sWidgetType && $sListType) {
57  $this->_sTemplate = "widget/" . $sWidgetType . "/" . $sListType . ".tpl";
58  }
59 
60  $sForceTemplate = $this->getViewParameter('oxwtemplate');
61  if ($sForceTemplate) {
62  $this->_sTemplate = $sForceTemplate;
63  }
64 
65  return $this->_sTemplate;
66  }
67 
75  public function setProduct( $oArticle )
76  {
77  $this->_oArticle = $oArticle;
78  }
79 
85  public function getProduct()
86  {
87  if ( is_null( $this->_oArticle ) ) {
88 
89  if ( $this->getViewParameter( '_object' ) ) {
90  $oArticle = $this->getViewParameter( '_object' );
91  } else {
92  $sAddDynParams = $this->getConfig()->getTopActiveView()->getAddUrlParams();
93 
94 
95  $oArticle = $this->_getArticleById( $this->getViewParameter( 'anid' ) );
96  $this->_addDynParamsToLink( $sAddDynParams, $oArticle );
97  }
98 
99  $this->setProduct( $oArticle );
100  }
101 
102  return $this->_oArticle;
103  }
104 
112  public function getLink( $iLang = null )
113  {
114  return $this->getConfig()->getTopActiveView()->getLink( $iLang );
115  }
116 
122  public function isVatIncluded()
123  {
124  return (bool) $this->getViewParameter( "isVatIncluded" );
125  }
126 
132  public function getWishId()
133  {
134  return $this->getViewParameter('owishid');
135  }
136 
142  public function getRemoveFunction()
143  {
144  return $this->getViewParameter('removeFunction');
145  }
146 
152  public function getToBasketFunction()
153  {
154  return $this->getViewParameter('toBasketFunction');
155  }
156 
162  public function getDisableToCart()
163  {
164  return (bool) $this->getViewParameter('blDisableToCart');
165  }
166 
172  public function getIndex()
173  {
174  return $this->getViewParameter('iIndex');
175  }
176 
182  public function getRecommId()
183  {
184  return $this->getViewParameter('recommid');
185  }
186 
192  public function getIteration()
193  {
194  return $this->getViewParameter('iIteration');
195  }
196 
202  public function getRSSLinks()
203  {
204  $aRSS = $this->getViewParameter('rsslinks');
205  if ( !is_array($aRSS) ) {
206  $aRSS = null;
207  }
208  return $aRSS;
209  }
210 
216  public function getShowMainLink()
217  {
218  return (bool) $this->getViewParameter('showMainLink');
219  }
220 
226  public function getAltProduct()
227  {
228  return (bool) $this->getViewParameter('altproduct');
229  }
230 
239  protected function _addDynParamsToLink( $sAddDynParams, $oArticle )
240  {
241  $blAddedParams = false;
242  if ( $sAddDynParams ) {
243  $blSeo = oxRegistry::getUtils()->seoIsActive();
244  if ( !$blSeo ) {
245  // only if seo is off..
246  $oArticle->appendStdLink( $sAddDynParams );
247  }
248  $oArticle->appendLink( $sAddDynParams );
249  $blAddedParams = true;
250  }
251 
252  return $blAddedParams;
253  }
254 
262  protected function _getArticleById( $sArticleId )
263  {
265  $oArticle = oxNew( 'oxArticle' );
266  $oArticle->load( $sArticleId );
267  $iLinkType = $this->getViewParameter( 'iLinkType' );
268 
269  if ( $this->getViewParameter( 'inlist' ) ) {
270  $oArticle->setInList();
271  }
272  if ( $iLinkType ) {
273  $oArticle->setLinkType( $iLinkType );
274  }
275  if ( $oRecommList = $this->getActiveRecommList() ) {
276  $oArticle->text = $oRecommList->getArtDescription( $oArticle->getId() );
277  }
278 
279  return $oArticle;
280  }
281 
282 }