00001 <?php
00002
00005 class oxManufacturer extends oxI18n
00006 {
00007
00008 protected static $_aRootManufacturer = array();
00012 protected $_sCoreTbl = 'oxmanufacturers';
00013
00017 protected $_sClassName = 'oxmanufacturer';
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( 'oxmanufacturers');
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 }
00092 return $sValue;
00093 }
00094
00102 public function setShowArticleCnt( $blShowArticleCount = false )
00103 {
00104 $this->_blShowArticleCnt = $blShowArticleCount;
00105 }
00106
00114 public function assign( $dbRecord )
00115 {
00116 parent::assign( $dbRecord );
00117
00118
00119 if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00120 $this->_iNrOfArticles = oxUtilsCount::getInstance()->getManufacturerArticleCount( $this->getId() );
00121 }
00122
00123 $this->oxmanufacturers__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00124 }
00125
00126
00136 public static function getRootManufacturer( $iLang = null)
00137 {
00138 if (!isset($iLang)) {
00139 $iLang = oxLang::getInstance()->getBaseLanguage();
00140 }
00141 if (!self::$_aRootManufacturer[$iLang]) {
00142 $oRootManufacturer = oxNew( 'oxmanufacturer' );
00143 $oRootManufacturer->setId( 'root' );
00144 $oRootManufacturer->setLanguage( $iLang );
00145 $oRootManufacturer->oxmanufacturers__oxicon = new oxField('');
00146 $oRootManufacturer->oxmanufacturers__oxtitle = new oxField(oxLang::getInstance()->translateString( 'byManufacturer', $iLang, false ) );
00147 $oRootManufacturer->oxmanufacturers__oxshortdesc = new oxField('');
00148 self::$_aRootManufacturer[$iLang] = $oRootManufacturer;
00149 }
00150 return self::$_aRootManufacturer[$iLang];
00151 }
00152
00160 public function getLink( $iLang = null )
00161 {
00162 if ( isset( $iLang ) ) {
00163 $iLang = (int) $iLang;
00164 if ( $iLang == (int) $this->getLanguage() ) {
00165 $iLang = null;
00166 }
00167 }
00168
00169 if ( $this->link === null || isset( $iLang ) ) {
00170
00171 if ( oxUtils::getInstance()->seoIsActive() ) {
00172 $sLink = oxSeoEncoderManufacturer::getInstance()->getManufacturerUrl( $this, $iLang );
00173 } else {
00174 $sLink = $this->getStdLink( $iLang );
00175 }
00176
00177 if ( isset( $iLang ) ) {
00178 return $sLink;
00179 }
00180
00181 $this->link = $sLink;
00182 }
00183
00184 return $this->link;
00185 }
00186
00194 public function getStdLink($iLang = null)
00195 {
00196 $sLangUrl = '';
00197
00198 if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00199 $iLang = (int) $iLang;
00200 if ($iLang != (int) $this->getLanguage()) {
00201 $sLangUrl = "&lang={$iLang}";
00202 }
00203 }
00204 return $this->getConfig()->getShopHomeURL().'cl=manufacturerlist&mnid='.$this->getId().$sLangUrl;
00205 }
00206
00212 public function getNrOfArticles()
00213 {
00214 if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00215 return -1;
00216 }
00217
00218 return $this->_iNrOfArticles;
00219 }
00220
00226 public function getSubCats()
00227 {
00228 }
00229
00235 public function getIsVisible()
00236 {
00237 return $this->_blIsVisible;
00238 }
00239
00247 public function setIsVisible( $blVisible )
00248 {
00249 $this->_blIsVisible = $blVisible;
00250 }
00251
00257 public function getHasVisibleSubCats()
00258 {
00259 if ( !isset( $this->_blHasVisibleSubCats ) ) {
00260 $this->_blHasVisibleSubCats = false;
00261 }
00262
00263 return $this->_blHasVisibleSubCats;
00264 }
00265
00273 public function setHasVisibleSubCats( $blHasVisibleSubcats )
00274 {
00275 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00276 }
00277
00283 public function getIconUrl()
00284 {
00285 return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxmanufacturers__oxicon->value );
00286 }
00287
00293 public function getContentCats()
00294 {
00295 }
00296
00304 public function delete( $sOXID = null)
00305 {
00306 if (parent::delete($sOXID)) {
00307 oxSeoEncoderManufacturer::getInstance()->onDeleteManufacturer($this);
00308 return true;
00309 }
00310 return false;
00311 }
00312 }