Go to the documentation of this file.00001 <?php
00002
00005 class oxManufacturer extends oxI18n implements oxIUrl
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
00059 protected $_aSeoUrls = array();
00060
00064 public function __construct()
00065 {
00066 $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00067 parent::__construct();
00068 $this->init( 'oxmanufacturers');
00069 }
00070
00078 public function __get( $sName )
00079 {
00080 switch ( $sName ) {
00081 case 'oxurl':
00082 case 'openlink':
00083 case 'closelink':
00084 case 'link':
00085 $sValue = $this->getLink();
00086 break;
00087 case 'iArtCnt':
00088 $sValue = $this->getNrOfArticles();
00089 break;
00090 case 'isVisible':
00091 $sValue = $this->getIsVisible();
00092 break;
00093 case 'hasVisibleSubCats':
00094 $sValue = $this->getHasVisibleSubCats();
00095 break;
00096 default:
00097 $sValue = parent::__get( $sName );
00098 break;
00099 }
00100 return $sValue;
00101 }
00102
00110 public function setShowArticleCnt( $blShowArticleCount = false )
00111 {
00112 $this->_blShowArticleCnt = $blShowArticleCount;
00113 }
00114
00122 public function assign( $dbRecord )
00123 {
00124 parent::assign( $dbRecord );
00125
00126
00127 if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00128 $this->_iNrOfArticles = oxUtilsCount::getInstance()->getManufacturerArticleCount( $this->getId() );
00129 }
00130
00131 $this->oxmanufacturers__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00132 }
00133
00142 public function load( $sOxid )
00143 {
00144 if ( $sOxid == 'root' ) {
00145 return $this->_setRootObjectData();
00146 }
00147 return parent::load( $sOxid );
00148 }
00149
00155 protected function _setRootObjectData()
00156 {
00157 $this->setId( 'root' );
00158 $this->oxmanufacturers__oxicon = new oxField( '', oxField::T_RAW );
00159 $this->oxmanufacturers__oxtitle = new oxField( oxLang::getInstance()->translateString( 'byManufacturer', $this->getLanguage(), false ), oxField::T_RAW );
00160 $this->oxmanufacturers__oxshortdesc = new oxField( '', oxField::T_RAW );
00161
00162 return true;
00163 }
00164
00175 public static function getRootManufacturer( $iLang = null)
00176 {
00177 $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00178 if ( !isset( self::$_aRootManufacturer[$iLang] ) ) {
00179 self::$_aRootManufacturer[$iLang] = false;
00180
00181 $oObject = oxNew( 'oxmanufacturer' );
00182 if ( $oObject->loadInLang( $iLang, 'root' ) ) {
00183 self::$_aRootManufacturer[$iLang] = $oObject;
00184 }
00185 }
00186 return self::$_aRootManufacturer[$iLang];
00187 }
00188
00197 public function getBaseSeoLink( $iLang, $iPage = 0 )
00198 {
00199 $oEncoder = oxSeoEncoderManufacturer::getInstance();
00200 if ( !$iPage ) {
00201 return $oEncoder->getManufacturerUrl( $this, $iLang );
00202 }
00203 return $oEncoder->getManufacturerPageUrl( $this, $iPage, $iLang );
00204 }
00205
00213 public function getLink( $iLang = null )
00214 {
00215 if ( !oxUtils::getInstance()->seoIsActive() ) {
00216 return $this->getStdLink( $iLang );
00217 }
00218
00219 if ( $iLang === null ) {
00220 $iLang = $this->getLanguage();
00221 }
00222
00223 if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00224 $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00225 }
00226
00227 return $this->_aSeoUrls[$iLang];
00228 }
00229
00239 public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00240 {
00241 $sUrl = '';
00242 if ( $blFull ) {
00243
00244 $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00245 }
00246
00247 return $sUrl . "index.php?cl=manufacturerlist" . ( $blAddId ? "&mnid=".$this->getId() : "" );
00248 }
00249
00258 public function getStdLink( $iLang = null, $aParams = array() )
00259 {
00260 if ( $iLang === null ) {
00261 $iLang = $this->getLanguage();
00262 }
00263
00264 return oxUtilsUrl::getInstance()->processStdUrl( $this->getBaseStdLink( $iLang ), $aParams, $iLang, $iLang != $this->getLanguage() );
00265 }
00266
00272 public function getNrOfArticles()
00273 {
00274 if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00275 return -1;
00276 }
00277
00278 return $this->_iNrOfArticles;
00279 }
00280
00286 public function getSubCats()
00287 {
00288 }
00289
00295 public function getIsVisible()
00296 {
00297 return $this->_blIsVisible;
00298 }
00299
00307 public function setIsVisible( $blVisible )
00308 {
00309 $this->_blIsVisible = $blVisible;
00310 }
00311
00317 public function getHasVisibleSubCats()
00318 {
00319 if ( !isset( $this->_blHasVisibleSubCats ) ) {
00320 $this->_blHasVisibleSubCats = false;
00321 }
00322
00323 return $this->_blHasVisibleSubCats;
00324 }
00325
00333 public function setHasVisibleSubCats( $blHasVisibleSubcats )
00334 {
00335 $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00336 }
00337
00343 public function getIconUrl()
00344 {
00345 return $this->getConfig()->getIconUrl( 'icon/'.$this->oxmanufacturers__oxicon->value );
00346 }
00347
00353 public function getContentCats()
00354 {
00355 }
00356
00364 public function delete( $sOXID = null)
00365 {
00366 if (parent::delete($sOXID)) {
00367 oxSeoEncoderManufacturer::getInstance()->onDeleteManufacturer($this);
00368 return true;
00369 }
00370 return false;
00371 }
00372 }