oxmanufacturer.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxManufacturer extends oxI18n implements oxIUrl
00008 {
00009 
00010     protected static $_aRootManufacturer = array();
00011 
00015     protected $_sClassName = 'oxmanufacturer';
00016 
00022     protected $_blShowArticleCnt = false;
00023 
00029     protected $_iNrOfArticles = -1;
00030 
00036     protected $_blIsSeoObject = true;
00037 
00043     protected $_blIsVisible;
00044 
00050     protected $_blHasVisibleSubCats;
00051 
00057     protected $_aSeoUrls = array();
00058 
00062     public function __construct()
00063     {
00064         $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00065         parent::__construct();
00066         $this->init( 'oxmanufacturers');
00067     }
00068 
00076     public function __get( $sName )
00077     {
00078         switch ( $sName ) {
00079             case 'oxurl':
00080             case 'openlink':
00081             case 'closelink':
00082             case 'link':
00083                 $sValue = $this->getLink();
00084                 break;
00085             case 'iArtCnt':
00086                 $sValue = $this->getNrOfArticles();
00087                 break;
00088             case 'isVisible':
00089                 $sValue = $this->getIsVisible();
00090                 break;
00091             case 'hasVisibleSubCats':
00092                 $sValue = $this->getHasVisibleSubCats();
00093                 break;
00094             default:
00095                 $sValue = parent::__get( $sName );
00096                 break;
00097         }
00098         return $sValue;
00099     }
00100 
00108     public function setShowArticleCnt( $blShowArticleCount = false )
00109     {
00110         $this->_blShowArticleCnt = $blShowArticleCount;
00111     }
00112 
00120     public function assign( $dbRecord )
00121     {
00122         parent::assign( $dbRecord );
00123 
00124         // manufacturer article count is stored in cache
00125         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00126             $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getManufacturerArticleCount( $this->getId() );
00127         }
00128 
00129         $this->oxmanufacturers__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00130     }
00131 
00140     public function load( $sOxid )
00141     {
00142         if ( $sOxid == 'root' ) {
00143             return $this->_setRootObjectData();
00144         }
00145         return parent::load( $sOxid );
00146     }
00147 
00153     protected function _setRootObjectData()
00154     {
00155         $this->setId( 'root' );
00156         $this->oxmanufacturers__oxicon = new oxField( '', oxField::T_RAW );
00157         $this->oxmanufacturers__oxtitle = new oxField( oxRegistry::getLang()->translateString( 'byManufacturer', $this->getLanguage(), false ), oxField::T_RAW );
00158         $this->oxmanufacturers__oxshortdesc = new oxField( '', oxField::T_RAW );
00159 
00160         return true;
00161     }
00162 
00171     public function getBaseSeoLink( $iLang, $iPage = 0 )
00172     {
00173         $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
00174         if ( !$iPage ) {
00175             return $oEncoder->getManufacturerUrl( $this, $iLang );
00176         }
00177         return $oEncoder->getManufacturerPageUrl( $this, $iPage, $iLang );
00178     }
00179 
00187     public function getLink( $iLang = null )
00188     {
00189         if ( !oxRegistry::getUtils()->seoIsActive() ) {
00190             return $this->getStdLink( $iLang );
00191         }
00192 
00193         if ( $iLang === null ) {
00194             $iLang = $this->getLanguage();
00195         }
00196 
00197         if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00198             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00199         }
00200 
00201         return $this->_aSeoUrls[$iLang];
00202     }
00203 
00213     public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00214     {
00215         $sUrl = '';
00216         if ( $blFull ) {
00217             //always returns shop url, not admin
00218             $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00219         }
00220 
00221         return $sUrl . "index.php?cl=manufacturerlist" . ( $blAddId ? "&amp;mnid=".$this->getId() : "" );
00222     }
00223 
00232     public function getStdLink( $iLang = null, $aParams = array() )
00233     {
00234         if ( $iLang === null ) {
00235             $iLang = $this->getLanguage();
00236         }
00237 
00238         return oxRegistry::get("oxUtilsUrl")->processUrl( $this->getBaseStdLink( $iLang ), true, $aParams, $iLang);
00239     }
00240 
00246     public function getNrOfArticles()
00247     {
00248         if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00249             return -1;
00250         }
00251 
00252         return $this->_iNrOfArticles;
00253     }
00254 
00260     public function getSubCats()
00261     {
00262     }
00263 
00269     public function getIsVisible()
00270     {
00271         return $this->_blIsVisible;
00272     }
00273 
00281     public function setIsVisible( $blVisible )
00282     {
00283         $this->_blIsVisible = $blVisible;
00284     }
00285 
00291     public function getHasVisibleSubCats()
00292     {
00293         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00294             $this->_blHasVisibleSubCats = false;
00295         }
00296 
00297         return $this->_blHasVisibleSubCats;
00298     }
00299 
00307     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00308     {
00309         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00310     }
00311 
00317     public function getContentCats()
00318     {
00319     }
00320 
00328     public function delete( $sOXID = null)
00329     {
00330         if ( parent::delete( $sOXID ) ) {
00331             oxRegistry::get("oxSeoEncoderManufacturer")->onDeleteManufacturer( $this );
00332             return true;
00333         }
00334         return false;
00335     }
00336 
00342     public function getIconUrl()
00343     {
00344         if ( ( $sIcon = $this->oxmanufacturers__oxicon->value ) ) {
00345             $oConfig = $this->getConfig();
00346             $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
00347             if ( !$sSize ) {
00348                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00349             }
00350 
00351             return oxRegistry::get("oxPictureHandler")->getPicUrl( "manufacturer/icon/", $sIcon, $sSize );
00352         }
00353     }
00354 
00360     public function getThumbUrl()
00361     {
00362         return false;
00363     }
00364 
00370     public function getTitle()
00371     {
00372         return $this->oxmanufacturers__oxtitle->value;
00373     }
00374 
00380     public function getShortDescription()
00381     {
00382         return $this->oxmanufacturers__oxshortdesc->value;
00383     }
00384 
00385 
00386 }