00001 <?php
00002
00006 class oxVendor extends oxI18n
00007 {
00008
00009 protected static $_aRootVendor = array();
00013 protected $_sCoreTbl = 'oxvendor';
00014
00018 protected $_sClassName = 'oxvendor';
00019
00025 protected $_blShowArticleCnt = false;
00026
00032 protected $_iNrOfArticles = -1;
00033
00039 protected $_blIsSeoObject = true;
00040
00046 protected $_blIsVisible;
00047
00053 protected $_blHasVisibleSubCats;
00054
00058 public function __construct()
00059 {
00060 $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00061 parent::__construct();
00062 $this->init( 'oxvendor');
00063 }
00064
00072 public function __get( $sName )
00073 {
00074 switch ( $sName ) {
00075 case 'oxurl':
00076 case 'openlink':
00077 case 'closelink':
00078 case 'link':
00079 $sValue = $this->getLink();
00080 break;
00081 case 'iArtCnt':
00082 $sValue = $this->getNrOfArticles();
00083 break;
00084 case 'isVisible':
00085 $sValue = $this->getIsVisible();
00086 break;
00087 case 'hasVisibleSubCats':
00088 $sValue = $this->getHasVisibleSubCats();
00089 break;
00090 default:
00091 $sValue = parent::__get( $sName );
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
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( 'byBrand', $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 = "&lang={$iLang}";
00203 }
00204 }
00205 return $this->getConfig()->getShopHomeURL().'cl=vendorlist&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 }