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 return $this->getLink();
00080 break;
00081 case 'iArtCnt':
00082 return $this->getNrOfArticles();
00083 break;
00084 case 'isVisible':
00085 return $this->getIsVisible();
00086 break;
00087 case 'hasVisibleSubCats':
00088 return $this->getHasVisibleSubCats();
00089 break;
00090 }
00091 return parent::__get( $sName );
00092 }
00093
00101 public function setShowArticleCnt( $blShowArticleCount = false )
00102 {
00103 $this->_blShowArticleCnt = $blShowArticleCount;
00104 }
00105
00113 public function assign( $dbRecord )
00114 {
00115 parent::assign( $dbRecord );
00116
00117
00118 if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00119 $this->_iNrOfArticles = oxUtilsCount::getInstance()->getVendorArticleCount( $this->getId() );
00120 }
00121
00122 $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00123 }
00124
00125
00135 public static function getRootVendor( $iLang = null)
00136 {
00137 if (!isset($iLang)) {
00138 $iLang = oxLang::getInstance()->getBaseLanguage();
00139 }
00140 if (!self::$_aRootVendor[$iLang]) {
00141 $oRootVendor = oxNew( 'oxvendor' );
00142 $oRootVendor->setId( 'root' );
00143 $oRootVendor->setLanguage( $iLang );
00144 $oRootVendor->oxvendor__oxicon = new oxField('');
00145 $oRootVendor->oxvendor__oxtitle = new oxField(oxLang::getInstance()->translateString( 'byBrand', $iLang, false ) );
00146 $oRootVendor->oxvendor__oxshortdesc = new oxField('');
00147 self::$_aRootVendor[$iLang] = $oRootVendor;
00148 }
00149 return self::$_aRootVendor[$iLang];
00150 }
00151
00159 public function getLink($iLang = null)
00160 {
00161 if (isset($iLang)) {
00162 $iLang = (int) $iLang;
00163 if ($iLang == (int) $this->getLanguage()) {
00164 $iLang = null;
00165 }
00166 }
00167 if ( $this->link === null || isset($iLang) ) {
00168
00169 if ( oxUtils::getInstance()->seoIsActive() ) {
00170 $link = oxSeoEncoderVendor::getInstance()->getVendorUrl( $this, $iLang );
00171 } else {
00172 $link = $this->getStdLink($iLang);
00173 }
00174
00175 if (isset($iLang)) {
00176 return $link;
00177 } else {
00178 $this->link = $link;
00179 }
00180 }
00181
00182 return $this->link;
00183 }
00184
00192 public function getStdLink($iLang = null)
00193 {
00194 $sLangUrl = '';
00195
00196 if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00197 $iLang = (int) $iLang;
00198 if ($iLang != (int) $this->getLanguage()) {
00199 $sLangUrl = "&lang={$iLang}";
00200 }
00201 }
00202 return $this->getConfig()->getShopHomeURL().'cl=vendorlist&cnid=v_'.$this->getId().$sLangUrl;
00203 }
00204
00210 public function getNrOfArticles()
00211 {
00212 if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00213 return -1;
00214 }
00215
00216 return $this->_iNrOfArticles;
00217 }
00218
00224 public function getSubCats()
00225 {
00226 }
00227
00233 public function getIsVisible()
00234 {
00235 return $this->_blIsVisible;
00236 }
00237
00245 public function setIsVisible( $blVisible )
00246 {
00247 $this->_blIsVisible = $blVisible;
00248 }
00249
00255 public function getHasVisibleSubCats()
00256 {
00257 if ( !isset( $this->_blHasVisibleSubCats ) ) {
00258 $this->_blHasVisibleSubCats = false;
00259 }
00260
00261 return $this->_blHasVisibleSubCats;
00262 }
00263
00271 public function setHasVisibleSubCats( $blHasVisibleSubcats )
00272 {
00273 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00274 }
00275
00281 public function getIconUrl()
00282 {
00283 return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxvendor__oxicon->value );
00284 }
00285
00286 }
00287