00001 <?php
00002
00005 class oxVendor extends oxI18n implements oxIUrl
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
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
00135 public function load( $sOxid )
00136 {
00137 if ( $sOxid == 'root' ) {
00138 return $this->_setRootObjectData();
00139 }
00140 return parent::load( $sOxid );
00141 }
00142
00148 protected function _setRootObjectData()
00149 {
00150 $this->setId( 'root' );
00151 $this->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
00152 $this->oxvendor__oxtitle = new oxField( oxLang::getInstance()->translateString( 'byVendor', $this->getLanguage(), false ), oxField::T_RAW );
00153 $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
00154
00155 return true;
00156 }
00157
00168 public static function getRootVendor( $iLang = null)
00169 {
00170 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00171 if ( !isset( self::$_aRootVendor[$iLang] ) ) {
00172 self::$_aRootVendor[$iLang] = false;
00173
00174 $oObject = oxNew( 'oxvendor' );
00175 if ( $oObject->loadInLang( $iLang, 'root' ) ) {
00176 self::$_aRootVendor[$iLang] = $oObject;
00177 }
00178 }
00179 return self::$_aRootVendor[$iLang];
00180 }
00181
00189 public function getLink( $iLang = null )
00190 {
00191 if ( isset( $iLang ) ) {
00192 $iLang = (int) $iLang;
00193 if ( $iLang == (int) $this->getLanguage() ) {
00194 $iLang = null;
00195 }
00196 }
00197
00198 if ( $this->link === null || isset( $iLang ) ) {
00199
00200 if ( oxUtils::getInstance()->seoIsActive() ) {
00201 $sLink = oxSeoEncoderVendor::getInstance()->getVendorUrl( $this, $iLang );
00202 } else {
00203 $sLink = $this->getStdLink( $iLang );
00204 }
00205
00206 if ( isset( $iLang ) ) {
00207 return $sLink;
00208 }
00209
00210 $this->link = $sLink;
00211 }
00212
00213 return $this->link;
00214 }
00215
00224 public function getStdLink($iLang = null, $aParams = array() )
00225 {
00226 $sLangUrl = '';
00227
00228 if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00229 $iLang = (int) $iLang;
00230 if ($iLang != (int) $this->getLanguage()) {
00231 $sLangUrl = "&lang={$iLang}";
00232 }
00233 }
00234
00235 foreach ($aParams as $key => $value) {
00236 if ( $value ) {
00237 $sLangUrl .= "&$key=$value";
00238 }
00239 }
00240
00241 return $this->getConfig()->getShopHomeURL().'cl=vendorlist&cnid=v_'.$this->getId().$sLangUrl;
00242 }
00243
00249 public function getNrOfArticles()
00250 {
00251 if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00252 return -1;
00253 }
00254
00255 return $this->_iNrOfArticles;
00256 }
00257
00263 public function getSubCats()
00264 {
00265 }
00266
00272 public function getIsVisible()
00273 {
00274 return $this->_blIsVisible;
00275 }
00276
00284 public function setIsVisible( $blVisible )
00285 {
00286 $this->_blIsVisible = $blVisible;
00287 }
00288
00294 public function getHasVisibleSubCats()
00295 {
00296 if ( !isset( $this->_blHasVisibleSubCats ) ) {
00297 $this->_blHasVisibleSubCats = false;
00298 }
00299
00300 return $this->_blHasVisibleSubCats;
00301 }
00302
00310 public function setHasVisibleSubCats( $blHasVisibleSubcats )
00311 {
00312 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00313 }
00314
00320 public function getIconUrl()
00321 {
00322 return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxvendor__oxicon->value );
00323 }
00324
00330 public function getContentCats()
00331 {
00332 }
00333
00341 public function delete( $sOXID = null)
00342 {
00343 if (parent::delete($sOXID)) {
00344 oxSeoEncoderVendor::getInstance()->onDeleteVendor($this);
00345 return true;
00346 }
00347 return false;
00348 }
00349 }