oxvendor.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxVendor extends oxI18n implements oxIUrl
00008 {
00009 
00010     protected static $_aRootVendor = array();
00011 
00015     protected $_sClassName = 'oxvendor';
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( 'oxvendor');
00067     }
00068 
00076     public function setShowArticleCnt( $blShowArticleCount = false )
00077     {
00078         $this->_blShowArticleCnt = $blShowArticleCount;
00079     }
00080 
00088     public function assign( $dbRecord )
00089     {
00090         parent::assign( $dbRecord );
00091 
00092         // vendor article count is stored in cache
00093         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00094             $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getVendorArticleCount( $this->getId() );
00095         }
00096 
00097         $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00098     }
00099 
00108     public function load( $sOxid )
00109     {
00110         if ( $sOxid == 'root' ) {
00111             return $this->_setRootObjectData();
00112         }
00113         return parent::load( $sOxid );
00114     }
00115 
00121     protected function _setRootObjectData()
00122     {
00123         $this->setId( 'root' );
00124         $this->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
00125         $this->oxvendor__oxtitle = new oxField( oxRegistry::getLang()->translateString( 'BY_VENDOR', $this->getLanguage(), false ), oxField::T_RAW );
00126         $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
00127 
00128         return true;
00129     }
00130 
00139     public function getBaseSeoLink( $iLang, $iPage = 0 )
00140     {
00141         $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
00142         if ( !$iPage ) {
00143             return $oEncoder->getVendorUrl( $this, $iLang );
00144         }
00145         return $oEncoder->getVendorPageUrl( $this, $iPage, $iLang );
00146     }
00147 
00155     public function getLink( $iLang = null )
00156     {
00157         if ( !oxRegistry::getUtils()->seoIsActive() ) {
00158             return $this->getStdLink( $iLang );
00159         }
00160 
00161         if ( $iLang === null ) {
00162             $iLang = $this->getLanguage();
00163         }
00164 
00165         if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00166             $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00167         }
00168 
00169         return $this->_aSeoUrls[$iLang];
00170     }
00171 
00181     public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00182     {
00183         $sUrl = '';
00184         if ( $blFull ) {
00185             //always returns shop url, not admin
00186             $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00187         }
00188 
00189         return $sUrl . "index.php?cl=vendorlist" . ( $blAddId ? "&amp;cnid=v_".$this->getId() : "" );
00190     }
00191 
00200     public function getStdLink( $iLang = null, $aParams = array() )
00201     {
00202         if ( $iLang === null ) {
00203             $iLang = $this->getLanguage();
00204         }
00205 
00206         return oxRegistry::get("oxUtilsUrl")->processUrl( $this->getBaseStdLink( $iLang ), true, $aParams, $iLang);
00207     }
00208 
00214     public function getNrOfArticles()
00215     {
00216         if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00217             return -1;
00218         }
00219 
00220         return $this->_iNrOfArticles;
00221     }
00222 
00228     public function getSubCats()
00229     {
00230     }
00231 
00237     public function getIsVisible()
00238     {
00239         return $this->_blIsVisible;
00240     }
00241 
00249     public function setIsVisible( $blVisible )
00250     {
00251         $this->_blIsVisible = $blVisible;
00252     }
00253 
00259     public function getHasVisibleSubCats()
00260     {
00261         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00262             $this->_blHasVisibleSubCats = false;
00263         }
00264 
00265         return $this->_blHasVisibleSubCats;
00266     }
00267 
00275     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00276     {
00277         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00278     }
00279 
00285     public function getContentCats()
00286     {
00287     }
00288 
00296     public function delete( $sOXID = null)
00297     {
00298         if ( parent::delete( $sOXID ) ) {
00299             oxRegistry::get("oxSeoEncoderVendor")->onDeleteVendor( $this );
00300             return true;
00301         }
00302         return false;
00303     }
00304 
00305 
00311     public function getIconUrl()
00312     {
00313         if ( ( $sIcon = $this->oxvendor__oxicon->value ) ) {
00314             $oConfig = $this->getConfig();
00315             $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
00316             if ( !isset( $sSize ) ) {
00317                 $sSize = $oConfig->getConfigParam( 'sIconsize' );
00318             }
00319 
00320             return oxRegistry::get("oxPictureHandler")->getPicUrl( "vendor/icon/", $sIcon, $sSize );
00321         }
00322     }
00323 
00329     public function getThumbUrl()
00330     {
00331         return false;
00332     }
00333 
00339     public function getTitle()
00340     {
00341         return $this->oxvendor__oxtitle->value;
00342     }
00343 
00349     public function getShortDescription()
00350     {
00351         return $this->oxvendor__oxshortdesc->value;
00352     }
00353 
00354 
00355 }