oxvendorlist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxVendorList extends oxList
00008 {
00014     protected $_oRoot = null;
00015 
00021     protected $_aPath = array();
00022 
00028     protected $_blShowVendorArticleCnt = false;
00029 
00035     protected $_oClickedVendor = null;
00036 
00045     public function __construct( $sObjectsInListName = 'oxvendor')
00046     {
00047         $this->setShowVendorArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00048         parent::__construct( 'oxvendor');
00049     }
00050 
00058     public function setShowVendorArticleCnt( $blShowVendorArticleCnt = false )
00059     {
00060         $this->_blShowVendorArticleCnt = $blShowVendorArticleCnt;
00061     }
00062 
00068     public function loadVendorList()
00069     {
00070         $sLangAdd = oxLang::getInstance()->getLanguageTag();
00071         $oBaseObject = $this->getBaseObject();
00072         $sFieldList = $oBaseObject->getSelectFields();
00073         $sViewName  = $oBaseObject->getViewName();
00074         $this->getBaseObject()->setShowArticleCnt( $this->_blShowVendorArticleCnt );
00075 
00076         $sWhere = '';
00077         if ( !$this->isAdmin() ) {
00078             $sWhere  = $oBaseObject->getSqlActiveSnippet();
00079             $sWhere  = $sWhere?" where $sWhere and ":' where ';
00080             $sWhere .= "{$sViewName}.oxtitle{$sLangAdd} != '' ";
00081         }
00082 
00083         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle{$sLangAdd}";
00084         $this->selectString( $sSelect );
00085     }
00086 
00096     public function buildVendorTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
00097     {
00098         $sActCat = str_replace( 'v_', '', $sActCat );
00099 
00100         //Load vendor list
00101         $this->loadVendorList();
00102 
00103 
00104         //Create fake vendor root category
00105         $this->_oRoot = oxNew( "oxVendor" );
00106         $this->_oRoot->load( 'root' );
00107 
00108         //category fields
00109         $this->_addCategoryFields( $this->_oRoot );
00110         $this->_aPath[] = $this->_oRoot;
00111 
00112         foreach ( $this as $sVndId => $oVendor ) {
00113 
00114             // storing active vendor object
00115             if ( $sVndId == $sActCat ) {
00116                 $this->setClickVendor( $oVendor );
00117             }
00118 
00119             $this->_addCategoryFields( $oVendor );
00120             if ( $sActCat == $oVendor->oxvendor__oxid->value ) {
00121                 $this->_aPath[] = $oVendor;
00122             }
00123         }
00124 
00125         $this->_seoSetVendorData();
00126     }
00127 
00133     public function getRootCat()
00134     {
00135         return $this->_oRoot;
00136     }
00137 
00143     public function getPath()
00144     {
00145         return $this->_aPath;
00146     }
00147 
00153     public function getHtmlPath()
00154     {
00155         $sHtmlVendTree = '';
00156         $sSep         = '';
00157         foreach ($this->_aPath as $oVendor) {
00158             $sHtmlVendTree .= " $sSep<a href='".$oVendor->getLink()."'>".$oVendor->oxvendor__oxtitle->value."</a>";
00159             $sSep = '/ ';
00160         }
00161         return $sHtmlVendTree;
00162     }
00163 
00171     protected function _addCategoryFields( $oVendor )
00172     {
00173         $oVendor->oxcategories__oxid    = new oxField("v_".$oVendor->oxvendor__oxid->value);
00174         $oVendor->oxcategories__oxicon  = $oVendor->oxvendor__oxicon;
00175         $oVendor->oxcategories__oxtitle = $oVendor->oxvendor__oxtitle;
00176         $oVendor->oxcategories__oxdesc  = $oVendor->oxvendor__oxshortdesc;
00177 
00178         $oVendor->setIsVisible( true );
00179         $oVendor->setHasVisibleSubCats( false );
00180     }
00181 
00189     public function setClickVendor( $oVendor )
00190     {
00191         $this->_oClickedVendor = $oVendor;
00192     }
00193 
00199     public function getClickVendor()
00200     {
00201         return $this->_oClickedVendor;
00202     }
00203 
00209     protected function _seoSetVendorData()
00210     {
00211         // only when SEO id on and in front end
00212         if ( oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) {
00213 
00214             $oEncoder = oxSeoEncoderVendor::getInstance();
00215 
00216             // preparing root vendor category
00217             if ($this->_oRoot) {
00218                 $oEncoder->getVendorUrl($this->_oRoot);
00219             }
00220 
00221             // encoding vendor category
00222             foreach ($this as $sVndId => $value) {
00223                 $oEncoder->getVendorUrl( $this->_aArray[$sVndId] );
00224             }
00225         }
00226     }
00227 }