oxvendor.php

Go to the documentation of this file.
00001 <?php
00002 
00005 class oxVendor extends oxI18n
00006 {
00007 
00008     protected static $_aRootVendor = array();
00012     protected $_sCoreTbl   = 'oxvendor';
00013 
00017     protected $_sClassName = 'oxvendor';
00018 
00024     protected $_blShowArticleCnt = false;
00025 
00031     protected $_iNrOfArticles = -1;
00032 
00038     protected $_blIsSeoObject = true;
00039 
00045     protected $_blIsVisible;
00046 
00052     protected $_blHasVisibleSubCats;
00053 
00057     public function __construct()
00058     {
00059         $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00060         parent::__construct();
00061         $this->init( 'oxvendor');
00062     }
00063 
00071     public function __get( $sName )
00072     {
00073         switch ( $sName ) {
00074             case 'oxurl':
00075             case 'openlink':
00076             case 'closelink':
00077             case 'link':
00078                 $sValue = $this->getLink();
00079                 break;
00080             case 'iArtCnt':
00081                 $sValue = $this->getNrOfArticles();
00082                 break;
00083             case 'isVisible':
00084                 $sValue = $this->getIsVisible();
00085                 break;
00086             case 'hasVisibleSubCats':
00087                 $sValue = $this->getHasVisibleSubCats();
00088                 break;
00089             default:
00090                 $sValue = parent::__get( $sName );
00091                 break;
00092         }
00093         return $sValue;
00094     }
00095 
00103     public function setShowArticleCnt( $blShowArticleCount = false )
00104     {
00105         $this->_blShowArticleCnt = $blShowArticleCount;
00106     }
00107 
00115     public function assign( $dbRecord )
00116     {
00117         parent::assign( $dbRecord );
00118 
00119         // vendor article count is stored in cache
00120         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00121             $this->_iNrOfArticles = oxUtilsCount::getInstance()->getVendorArticleCount( $this->getId() );
00122         }
00123 
00124         $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00125     }
00126 
00127 
00137     public static function getRootVendor( $iLang = null)
00138     {
00139         if (!isset($iLang)) {
00140             $iLang = oxLang::getInstance()->getBaseLanguage();
00141         }
00142         if (!self::$_aRootVendor[$iLang]) {
00143             $oRootVendor = oxNew( 'oxvendor' );
00144             $oRootVendor->setId( 'root' );
00145             $oRootVendor->setLanguage( $iLang );
00146             $oRootVendor->oxvendor__oxicon      = new oxField('');
00147             $oRootVendor->oxvendor__oxtitle     = new oxField(oxLang::getInstance()->translateString( 'byVendor', $iLang, false ) );
00148             $oRootVendor->oxvendor__oxshortdesc = new oxField('');
00149             self::$_aRootVendor[$iLang] = $oRootVendor;
00150         }
00151         return self::$_aRootVendor[$iLang];
00152     }
00153 
00161     public function getLink( $iLang = null )
00162     {
00163         if ( isset( $iLang ) ) {
00164             $iLang = (int) $iLang;
00165             if ( $iLang == (int) $this->getLanguage() ) {
00166                 $iLang = null;
00167             }
00168         }
00169 
00170         if ( $this->link === null || isset( $iLang ) ) {
00171 
00172             if ( oxUtils::getInstance()->seoIsActive() ) {
00173                 $sLink = oxSeoEncoderVendor::getInstance()->getVendorUrl( $this, $iLang );
00174             } else {
00175                 $sLink = $this->getStdLink( $iLang );
00176             }
00177 
00178             if ( isset( $iLang ) ) {
00179                 return $sLink;
00180             }
00181 
00182             $this->link = $sLink;
00183         }
00184 
00185         return $this->link;
00186     }
00187 
00195     public function getStdLink($iLang = null)
00196     {
00197         $sLangUrl = '';
00198 
00199         if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00200             $iLang = (int) $iLang;
00201             if ($iLang != (int) $this->getLanguage()) {
00202                 $sLangUrl = "&amp;lang={$iLang}";
00203             }
00204         }
00205         return $this->getConfig()->getShopHomeURL().'cl=vendorlist&amp;cnid=v_'.$this->getId().$sLangUrl;
00206     }
00207 
00213     public function getNrOfArticles()
00214     {
00215         if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00216             return -1;
00217         }
00218 
00219         return $this->_iNrOfArticles;
00220     }
00221 
00227     public function getSubCats()
00228     {
00229     }
00230 
00236     public function getIsVisible()
00237     {
00238         return $this->_blIsVisible;
00239     }
00240 
00248     public function setIsVisible( $blVisible )
00249     {
00250         $this->_blIsVisible = $blVisible;
00251     }
00252 
00258     public function getHasVisibleSubCats()
00259     {
00260         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00261             $this->_blHasVisibleSubCats = false;
00262         }
00263 
00264         return $this->_blHasVisibleSubCats;
00265     }
00266 
00274     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00275     {
00276         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00277     }
00278 
00284     public function getIconUrl()
00285     {
00286         return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxvendor__oxicon->value );
00287     }
00288 
00294     public function getContentCats()
00295     {
00296     }
00297 
00305     public function delete( $sOXID = null)
00306     {
00307         if (parent::delete($sOXID)) {
00308             oxSeoEncoderVendor::getInstance()->onDeleteVendor($this);
00309             return true;
00310         }
00311         return false;
00312     }
00313 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5