oxvendor.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxVendor extends oxI18n implements oxIUrl
00008 {
00009 
00010     protected static $_aRootVendor = array();
00011 
00015     protected $_sClassName = 'oxvendor';
00016 
00022     protected $_blShowArticleCnt = false;
00023 
00029     protected $_iNrOfArticles = -1;
00030 
00036     protected $_blIsSeoObject = true;
00037 
00043     protected $_blIsVisible;
00044 
00050     protected $_blHasVisibleSubCats;
00051 
00057     protected $_aSeoUrls = array();
00058 
00062     public function __construct()
00063     {
00064         $this->setShowArticleCnt($this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt'));
00065         parent::__construct();
00066         $this->init('oxvendor');
00067     }
00068 
00074     public function setShowArticleCnt($blShowArticleCount = false)
00075     {
00076         $this->_blShowArticleCnt = $blShowArticleCount;
00077     }
00078 
00084     public function assign($dbRecord)
00085     {
00086         parent::assign($dbRecord);
00087 
00088         // vendor article count is stored in cache
00089         if ($this->_blShowArticleCnt && !$this->isAdmin()) {
00090             $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getVendorArticleCount($this->getId());
00091         }
00092 
00093         $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00094     }
00095 
00104     public function load($sOxid)
00105     {
00106         if ($sOxid == 'root') {
00107             return $this->_setRootObjectData();
00108         }
00109 
00110         return parent::load($sOxid);
00111     }
00112 
00118     protected function _setRootObjectData()
00119     {
00120         $this->setId('root');
00121         $this->oxvendor__oxicon = new oxField('', oxField::T_RAW);
00122         $this->oxvendor__oxtitle = new oxField(oxRegistry::getLang()->translateString('BY_VENDOR', $this->getLanguage(), false), oxField::T_RAW);
00123         $this->oxvendor__oxshortdesc = new oxField('', oxField::T_RAW);
00124 
00125         return true;
00126     }
00127 
00136     public function getBaseSeoLink($iLang, $iPage = 0)
00137     {
00138         $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
00139         if (!$iPage) {
00140             return $oEncoder->getVendorUrl($this, $iLang);
00141         }
00142 
00143         return $oEncoder->getVendorPageUrl($this, $iPage, $iLang);
00144     }
00145 
00153     public function getLink($iLang = null)
00154     {
00155         if (!oxRegistry::getUtils()->seoIsActive()) {
00156             return $this->getStdLink($iLang);
00157         }
00158 
00159         if ($iLang === null) {
00160             $iLang = $this->getLanguage();
00161         }
00162 
00163         if (!isset($this->_aSeoUrls[$iLang])) {
00164             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang);
00165         }
00166 
00167         return $this->_aSeoUrls[$iLang];
00168     }
00169 
00179     public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
00180     {
00181         $sUrl = '';
00182         if ($blFull) {
00183             //always returns shop url, not admin
00184             $sUrl = $this->getConfig()->getShopUrl($iLang, false);
00185         }
00186 
00187         return $sUrl . "index.php?cl=vendorlist" . ($blAddId ? "&amp;cnid=v_" . $this->getId() : "");
00188     }
00189 
00198     public function getStdLink($iLang = null, $aParams = array())
00199     {
00200         if ($iLang === null) {
00201             $iLang = $this->getLanguage();
00202         }
00203 
00204         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getBaseStdLink($iLang), true, $aParams, $iLang);
00205     }
00206 
00212     public function getNrOfArticles()
00213     {
00214         if (!$this->_blShowArticleCnt || $this->isAdmin()) {
00215             return -1;
00216         }
00217 
00218         return $this->_iNrOfArticles;
00219     }
00220 
00224     public function getSubCats()
00225     {
00226     }
00227 
00233     public function getIsVisible()
00234     {
00235         return $this->_blIsVisible;
00236     }
00237 
00243     public function setIsVisible($blVisible)
00244     {
00245         $this->_blIsVisible = $blVisible;
00246     }
00247 
00253     public function getHasVisibleSubCats()
00254     {
00255         if (!isset($this->_blHasVisibleSubCats)) {
00256             $this->_blHasVisibleSubCats = false;
00257         }
00258 
00259         return $this->_blHasVisibleSubCats;
00260     }
00261 
00267     public function setHasVisibleSubCats($blHasVisibleSubcats)
00268     {
00269         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00270     }
00271 
00275     public function getContentCats()
00276     {
00277     }
00278 
00286     public function delete($sOXID = null)
00287     {
00288         if (parent::delete($sOXID)) {
00289             oxRegistry::get("oxSeoEncoderVendor")->onDeleteVendor($this);
00290 
00291             return true;
00292         }
00293 
00294         return false;
00295     }
00296 
00297 
00303     public function getIconUrl()
00304     {
00305         if (($sIcon = $this->oxvendor__oxicon->value)) {
00306             $oConfig = $this->getConfig();
00307             $sSize = $oConfig->getConfigParam('sManufacturerIconsize');
00308             if (!isset($sSize)) {
00309                 $sSize = $oConfig->getConfigParam('sIconsize');
00310             }
00311 
00312             return oxRegistry::get("oxPictureHandler")->getPicUrl("vendor/icon/", $sIcon, $sSize);
00313         }
00314     }
00315 
00321     public function getThumbUrl()
00322     {
00323         return false;
00324     }
00325 
00331     public function getTitle()
00332     {
00333         return $this->oxvendor__oxtitle->value;
00334     }
00335 
00341     public function getShortDescription()
00342     {
00343         return $this->oxvendor__oxshortdesc->value;
00344     }
00345 
00346 }