oxwarticlebox.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxwArticleBox extends oxWidget
00007 {
00008 
00016     protected $_aComponentNames = array('oxcmp_user' => 1, 'oxcmp_basket' => 1, 'oxcmp_cur' => 1);
00017 
00023     protected $_sTemplate = 'widget/product/boxproduct.tpl';
00024 
00025 
00031     protected $_oArticle = null;
00032 
00033 
00039     public function getActiveCategory()
00040     {
00041         $oCategory = $this->getConfig()->getTopActiveView()->getActiveCategory();
00042         if ($oCategory) {
00043             $this->setActiveCategory($oCategory);
00044         }
00045 
00046         return $this->_oActCategory;
00047     }
00048 
00054     public function render()
00055     {
00056         parent::render();
00057 
00058         $sWidgetType = $this->getViewParameter('sWidgetType');
00059         $sListType = $this->getViewParameter('sListType');
00060 
00061         if ($sWidgetType && $sListType) {
00062             $this->_sTemplate = "widget/" . $sWidgetType . "/" . $sListType . ".tpl";
00063         }
00064 
00065         $sForceTemplate = $this->getViewParameter('oxwtemplate');
00066         if ($sForceTemplate) {
00067             $this->_sTemplate = $sForceTemplate;
00068         }
00069 
00070         return $this->_sTemplate;
00071     }
00072 
00078     public function setProduct($oArticle)
00079     {
00080         $this->_oArticle = $oArticle;
00081     }
00082 
00088     public function getProduct()
00089     {
00090         if (is_null($this->_oArticle)) {
00091 
00092             if ($this->getViewParameter('_object')) {
00093                 $oArticle = $this->getViewParameter('_object');
00094             } else {
00095                 $sAddDynParams = $this->getConfig()->getTopActiveView()->getAddUrlParams();
00096 
00097 
00098                 $oArticle = $this->_getArticleById($this->getViewParameter('anid'));
00099                 $this->_addDynParamsToLink($sAddDynParams, $oArticle);
00100             }
00101 
00102             $this->setProduct($oArticle);
00103         }
00104 
00105         return $this->_oArticle;
00106     }
00107 
00115     public function getLink($iLang = null)
00116     {
00117         return $this->getConfig()->getTopActiveView()->getLink($iLang);
00118     }
00119 
00125     public function isVatIncluded()
00126     {
00127         return (bool) $this->getViewParameter("isVatIncluded");
00128     }
00129 
00135     public function getWishId()
00136     {
00137         return $this->getViewParameter('owishid');
00138     }
00139 
00145     public function getRemoveFunction()
00146     {
00147         return $this->getViewParameter('removeFunction');
00148     }
00149 
00155     public function getToBasketFunction()
00156     {
00157         return $this->getViewParameter('toBasketFunction');
00158     }
00159 
00165     public function getDisableToCart()
00166     {
00167         return (bool) $this->getViewParameter('blDisableToCart');
00168     }
00169 
00175     public function getIndex()
00176     {
00177         return $this->getViewParameter('iIndex');
00178     }
00179 
00185     public function getRecommId()
00186     {
00187         return $this->getViewParameter('recommid');
00188     }
00189 
00195     public function getIteration()
00196     {
00197         return $this->getViewParameter('iIteration');
00198     }
00199 
00205     public function getRSSLinks()
00206     {
00207         $aRSS = $this->getViewParameter('rsslinks');
00208         if (!is_array($aRSS)) {
00209             $aRSS = null;
00210         }
00211 
00212         return $aRSS;
00213     }
00214 
00220     public function getShowMainLink()
00221     {
00222         return (bool) $this->getViewParameter('showMainLink');
00223     }
00224 
00230     public function getAltProduct()
00231     {
00232         return (bool) $this->getViewParameter('altproduct');
00233     }
00234 
00243     protected function _addDynParamsToLink($sAddDynParams, $oArticle)
00244     {
00245         $blAddedParams = false;
00246         if ($sAddDynParams) {
00247             $blSeo = oxRegistry::getUtils()->seoIsActive();
00248             if (!$blSeo) {
00249                 // only if seo is off..
00250                 $oArticle->appendStdLink($sAddDynParams);
00251             }
00252             $oArticle->appendLink($sAddDynParams);
00253             $blAddedParams = true;
00254         }
00255 
00256         return $blAddedParams;
00257     }
00258 
00266     protected function _getArticleById($sArticleId)
00267     {
00269         $oArticle = oxNew('oxArticle');
00270         $oArticle->load($sArticleId);
00271         $iLinkType = $this->getViewParameter('iLinkType');
00272 
00273         if ($this->getViewParameter('inlist')) {
00274             $oArticle->setInList();
00275         }
00276         if ($iLinkType) {
00277             $oArticle->setLinkType($iLinkType);
00278         }
00279         if ($oRecommList = $this->getActiveRecommList()) {
00280             $oArticle->text = $oRecommList->getArtDescription($oArticle->getId());
00281         }
00282 
00283         return $oArticle;
00284     }
00285 }