oxvendor.php

Go to the documentation of this file.
00001 <?php
00002 
00005 class oxVendor extends oxI18n
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 
00057     public function __construct()
00058     {
00059         $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00060         parent::__construct();
00061         $this->init( 'oxvendor');
00062     }
00063 
00071     public function __get( $sName )
00072     {
00073         switch ( $sName ) {
00074             case 'oxurl':
00075             case 'openlink':
00076             case 'closelink':
00077             case 'link':
00078                 $sValue = $this->getLink();
00079                 break;
00080             case 'iArtCnt':
00081                 $sValue = $this->getNrOfArticles();
00082                 break;
00083             case 'isVisible':
00084                 $sValue = $this->getIsVisible();
00085                 break;
00086             case 'hasVisibleSubCats':
00087                 $sValue = $this->getHasVisibleSubCats();
00088                 break;
00089             default:
00090                 $sValue = parent::__get( $sName );
00091                 break;
00092         }
00093         return $sValue;
00094     }
00095 
00103     public function setShowArticleCnt( $blShowArticleCount = false )
00104     {
00105         $this->_blShowArticleCnt = $blShowArticleCount;
00106     }
00107 
00115     public function assign( $dbRecord )
00116     {
00117         parent::assign( $dbRecord );
00118 
00119         // vendor article count is stored in cache
00120         if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
00121             $this->_iNrOfArticles = oxUtilsCount::getInstance()->getVendorArticleCount( $this->getId() );
00122         }
00123 
00124         $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
00125     }
00126 
00135     public function load( $sOxid )
00136     {
00137         if ( $sOxid == 'root' ) {
00138             return $this->_setRootObjectData();
00139         }
00140         return parent::load( $sOxid );
00141     }
00142 
00148     protected function _setRootObjectData()
00149     {
00150         $this->setId( 'root' );
00151         $this->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
00152         $this->oxvendor__oxtitle = new oxField( oxLang::getInstance()->translateString( 'byVendor', $this->getLanguage(), false ), oxField::T_RAW );
00153         $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
00154 
00155         return true;
00156     }
00157 
00168     public static function getRootVendor( $iLang = null)
00169     {
00170         $iLang = isset( $iLang ) ? $iLang : oxLang::getInstance()->getBaseLanguage();
00171         if ( !isset( self::$_aRootVendor[$iLang] ) ) {
00172             self::$_aRootVendor[$iLang] = false;
00173 
00174             $oObject = oxNew( 'oxvendor' );
00175             if ( $oObject->loadInLang( $iLang, 'root' ) ) {
00176                 self::$_aRootVendor[$iLang] = $oObject;
00177             }
00178         }
00179         return self::$_aRootVendor[$iLang];
00180     }
00181 
00189     public function getLink( $iLang = null )
00190     {
00191         if ( isset( $iLang ) ) {
00192             $iLang = (int) $iLang;
00193             if ( $iLang == (int) $this->getLanguage() ) {
00194                 $iLang = null;
00195             }
00196         }
00197 
00198         if ( $this->link === null || isset( $iLang ) ) {
00199 
00200             if ( oxUtils::getInstance()->seoIsActive() ) {
00201                 $sLink = oxSeoEncoderVendor::getInstance()->getVendorUrl( $this, $iLang );
00202             } else {
00203                 $sLink = $this->getStdLink( $iLang );
00204             }
00205 
00206             if ( isset( $iLang ) ) {
00207                 return $sLink;
00208             }
00209 
00210             $this->link = $sLink;
00211         }
00212 
00213         return $this->link;
00214     }
00215 
00223     public function getStdLink($iLang = null)
00224     {
00225         $sLangUrl = '';
00226 
00227         if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00228             $iLang = (int) $iLang;
00229             if ($iLang != (int) $this->getLanguage()) {
00230                 $sLangUrl = "&amp;lang={$iLang}";
00231             }
00232         }
00233         return $this->getConfig()->getShopHomeURL().'cl=vendorlist&amp;cnid=v_'.$this->getId().$sLangUrl;
00234     }
00235 
00241     public function getNrOfArticles()
00242     {
00243         if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
00244             return -1;
00245         }
00246 
00247         return $this->_iNrOfArticles;
00248     }
00249 
00255     public function getSubCats()
00256     {
00257     }
00258 
00264     public function getIsVisible()
00265     {
00266         return $this->_blIsVisible;
00267     }
00268 
00276     public function setIsVisible( $blVisible )
00277     {
00278         $this->_blIsVisible = $blVisible;
00279     }
00280 
00286     public function getHasVisibleSubCats()
00287     {
00288         if ( !isset( $this->_blHasVisibleSubCats ) ) {
00289             $this->_blHasVisibleSubCats = false;
00290         }
00291 
00292         return $this->_blHasVisibleSubCats;
00293     }
00294 
00302     public function setHasVisibleSubCats( $blHasVisibleSubcats )
00303     {
00304         $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
00305     }
00306 
00312     public function getIconUrl()
00313     {
00314         return $this->getConfig()->getPictureUrl( 'icon/'.$this->oxvendor__oxicon->value );
00315     }
00316 
00322     public function getContentCats()
00323     {
00324     }
00325 
00333     public function delete( $sOXID = null)
00334     {
00335         if (parent::delete($sOXID)) {
00336             oxSeoEncoderVendor::getInstance()->onDeleteVendor($this);
00337             return true;
00338         }
00339         return false;
00340     }
00341 }

Generated on Tue Aug 18 09:21:06 2009 for OXID eShop CE by  doxygen 1.5.5