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();
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 
00059     protected $_aSeoUrls = array();
00060 
00064     public function __construct()
00065     {
00066         $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00067         parent::__construct();
00068         $this->init( 'oxvendor');
00069     }
00070 
00080     public function __get( $sName )
00081     {
00082         switch ( $sName ) {
00083             case 'oxurl':
00084             case 'openlink':
00085             case 'closelink':
00086             case 'link':
00087                 $sValue = $this->getLink();
00088                 break;
00089             case 'iArtCnt':
00090                 $sValue = $this->getNrOfArticles();
00091                 break;
00092             case 'isVisible':
00093                 $sValue = $this->getIsVisible();
00094                 break;
00095             case 'hasVisibleSubCats':
00096                 $sValue = $this->getHasVisibleSubCats();
00097                 break;
00098             default:
00099                 $sValue = parent::__get( $sName );
00100                 break;
00101         }
00102         return $sValue;
00103     }
00104 
00112     public function setShowArticleCnt( $blShowArticleCount = false )
00113     {
00114         $this->_blShowArticleCnt = $blShowArticleCount;
00115     }
00116 
00124     public function assign( $dbRecord )
00125     {
00126         parent::assign( $dbRecord );
00127 
00128         // vendor article count is stored in cache
00129         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00130             $this->_iNrOfArticles = oxUtilsCount::getInstance()->getVendorArticleCount( $this->getId() );
00131         }
00132 
00133         $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00134     }
00135 
00144     public function load( $sOxid )
00145     {
00146         if ( $sOxid == 'root' ) {
00147             return $this->_setRootObjectData();
00148         }
00149         return parent::load( $sOxid );
00150     }
00151 
00157     protected function _setRootObjectData()
00158     {
00159         $this->setId( 'root' );
00160         $this->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
00161         $this->oxvendor__oxtitle = new oxField( oxLang::getInstance()->translateString( 'byVendor', $this->getLanguage(), false ), oxField::T_RAW );
00162         $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
00163 
00164         return true;
00165     }
00166 
00175     public function getBaseSeoLink( $iLang, $iPage = 0 )
00176     {
00177         $oEncoder = oxSeoEncoderVendor::getInstance();
00178         if ( !$iPage ) {
00179             return $oEncoder->getVendorUrl( $this, $iLang );
00180         }
00181         return $oEncoder->getVendorPageUrl( $this, $iPage, $iLang );
00182     }
00183 
00191     public function getLink( $iLang = null )
00192     {
00193         if ( !oxUtils::getInstance()->seoIsActive() ) {
00194             return $this->getStdLink( $iLang );
00195         }
00196 
00197         if ( $iLang === null ) {
00198             $iLang = $this->getLanguage();
00199         }
00200 
00201         if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00202             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00203         }
00204 
00205         return $this->_aSeoUrls[$iLang];
00206     }
00207 
00217     public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00218     {
00219         $sUrl = '';
00220         if ( $blFull ) {
00221             //always returns shop url, not admin
00222             $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00223         }
00224 
00225         return $sUrl . "index.php?cl=vendorlist" . ( $blAddId ? "&amp;cnid=v_".$this->getId() : "" );
00226     }
00227 
00236     public function getStdLink( $iLang = null, $aParams = array() )
00237     {
00238         if ( $iLang === null ) {
00239             $iLang = $this->getLanguage();
00240         }
00241 
00242         return oxUtilsUrl::getInstance()->processUrl( $this->getBaseStdLink( $iLang ), true, $aParams, $iLang);
00243     }
00244 
00250     public function getNrOfArticles()
00251     {
00252         if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00253             return -1;
00254         }
00255 
00256         return $this->_iNrOfArticles;
00257     }
00258 
00264     public function getSubCats()
00265     {
00266     }
00267 
00273     public function getIsVisible()
00274     {
00275         return $this->_blIsVisible;
00276     }
00277 
00285     public function setIsVisible( $blVisible )
00286     {
00287         $this->_blIsVisible = $blVisible;
00288     }
00289 
00295     public function getHasVisibleSubCats()
00296     {
00297         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00298             $this->_blHasVisibleSubCats = false;
00299         }
00300 
00301         return $this->_blHasVisibleSubCats;
00302     }
00303 
00311     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00312     {
00313         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00314     }
00315 
00321     public function getContentCats()
00322     {
00323     }
00324 
00332     public function delete( $sOXID = null)
00333     {
00334         if ( parent::delete( $sOXID ) ) {
00335             oxSeoEncoderVendor::getInstance()->onDeleteVendor( $this );
00336             return true;
00337         }
00338         return false;
00339     }
00340 
00341 
00347     public function getIconUrl()
00348     {
00349         if ( ( $sIcon = $this->oxvendor__oxicon->value ) ) {
00350             $oConfig = $this->getConfig();
00351             $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
00352             if ( !isset( $sSize ) ) {
00353                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00354             }
00355 
00356             return oxPictureHandler::getInstance()->getPicUrl( "vendor/icon/", $sIcon, $sSize );
00357         }
00358     }
00359 
00365     public function getThumbUrl()
00366     {
00367         return false;
00368     }
00369 
00375     public function getTitle()
00376     {
00377         return $this->oxvendor__oxtitle->value;
00378     }
00379 }