oxvendor.php

Go to the documentation of this file.
00001 <?php
00002 
00005 class oxVendor extends oxI18n implements oxIUrl
00006 {
00007 
00008     protected static $_aRootVendor = array();
00009 
00013     protected $_sClassName = 'oxvendor';
00014 
00020     protected $_blShowArticleCnt = false;
00021 
00027     protected $_iNrOfArticles = -1;
00028 
00034     protected $_blIsSeoObject = true;
00035 
00041     protected $_blIsVisible;
00042 
00048     protected $_blHasVisibleSubCats;
00049 
00055     protected $_aSeoUrls = array();
00056 
00060     public function __construct()
00061     {
00062         $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00063         parent::__construct();
00064         $this->init( 'oxvendor');
00065     }
00066 
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         // vendor article count is stored in cache
00125         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00126             $this->_iNrOfArticles = oxUtilsCount::getInstance()->getVendorArticleCount( $this->getId() );
00127         }
00128 
00129         $this->oxvendor__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->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
00157         $this->oxvendor__oxtitle = new oxField( oxLang::getInstance()->translateString( 'byVendor', $this->getLanguage(), false ), oxField::T_RAW );
00158         $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
00159 
00160         return true;
00161     }
00162 
00171     public function getBaseSeoLink( $iLang, $iPage = 0 )
00172     {
00173         $oEncoder = oxSeoEncoderVendor::getInstance();
00174         if ( !$iPage ) {
00175             return $oEncoder->getVendorUrl( $this, $iLang );
00176         }
00177         return $oEncoder->getVendorPageUrl( $this, $iPage, $iLang );
00178     }
00179 
00187     public function getLink( $iLang = null )
00188     {
00189         if ( !oxUtils::getInstance()->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=vendorlist" . ( $blAddId ? "&amp;cnid=v_".$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 oxUtilsUrl::getInstance()->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             oxSeoEncoderVendor::getInstance()->onDeleteVendor( $this );
00332             return true;
00333         }
00334         return false;
00335     }
00336 
00337 
00343     public function getIconUrl()
00344     {
00345         if ( ( $sIcon = $this->oxvendor__oxicon->value ) ) {
00346             $oConfig = $this->getConfig();
00347             $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
00348             if ( !isset( $sSize ) ) {
00349                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00350             }
00351 
00352             return oxPictureHandler::getInstance()->getPicUrl( "vendor/icon/", $sIcon, $sSize );
00353         }
00354     }
00355 
00361     public function getThumbUrl()
00362     {
00363         return false;
00364     }
00365 
00371     public function getTitle()
00372     {
00373         return $this->oxvendor__oxtitle->value;
00374     }
00375 }