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         $oBaseObject = $this->getBaseObject();
00071         $sFieldList = $oBaseObject->getSelectFields();
00072         $sViewName  = $oBaseObject->getViewName();
00073         $this->getBaseObject()->setShowArticleCnt( $this->_blShowVendorArticleCnt );
00074 
00075         $sWhere = '';
00076         if ( !$this->isAdmin() ) {
00077             $sWhere  = $oBaseObject->getSqlActiveSnippet();
00078             $sWhere  = $sWhere?" where $sWhere and ":' where ';
00079             $sWhere .= "{$sViewName}.oxtitle != '' ";
00080         }
00081 
00082         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
00083         $this->selectString( $sSelect );
00084     }
00085 
00095     public function buildVendorTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
00096     {
00097         $sActCat = str_replace( 'v_', '', $sActCat );
00098 
00099         //Load vendor list
00100         $this->loadVendorList();
00101 
00102 
00103         //Create fake vendor root category
00104         $this->_oRoot = oxNew( "oxVendor" );
00105         $this->_oRoot->load( 'root' );
00106 
00107         //category fields
00108         $this->_addCategoryFields( $this->_oRoot );
00109         $this->_aPath[] = $this->_oRoot;
00110 
00111         foreach ( $this as $sVndId => $oVendor ) {
00112 
00113             // storing active vendor object
00114             if ( $sVndId == $sActCat ) {
00115                 $this->setClickVendor( $oVendor );
00116             }
00117 
00118             $this->_addCategoryFields( $oVendor );
00119             if ( $sActCat == $oVendor->oxvendor__oxid->value ) {
00120                 $this->_aPath[] = $oVendor;
00121             }
00122         }
00123 
00124         $this->_seoSetVendorData();
00125     }
00126 
00132     public function getRootCat()
00133     {
00134         return $this->_oRoot;
00135     }
00136 
00142     public function getPath()
00143     {
00144         return $this->_aPath;
00145     }
00146 
00152     public function getHtmlPath()
00153     {
00154         $sHtmlVendTree = '';
00155         $sSep         = '';
00156         foreach ($this->_aPath as $oVendor) {
00157             $sHtmlVendTree .= " $sSep<a href='".$oVendor->getLink()."'>".$oVendor->oxvendor__oxtitle->value."</a>";
00158             $sSep = '/ ';
00159         }
00160         return $sHtmlVendTree;
00161     }
00162 
00170     protected function _addCategoryFields( $oVendor )
00171     {
00172         $oVendor->oxcategories__oxid    = new oxField("v_".$oVendor->oxvendor__oxid->value);
00173         $oVendor->oxcategories__oxicon  = $oVendor->oxvendor__oxicon;
00174         $oVendor->oxcategories__oxtitle = $oVendor->oxvendor__oxtitle;
00175         $oVendor->oxcategories__oxdesc  = $oVendor->oxvendor__oxshortdesc;
00176 
00177         $oVendor->setIsVisible( true );
00178         $oVendor->setHasVisibleSubCats( false );
00179     }
00180 
00188     public function setClickVendor( $oVendor )
00189     {
00190         $this->_oClickedVendor = $oVendor;
00191     }
00192 
00198     public function getClickVendor()
00199     {
00200         return $this->_oClickedVendor;
00201     }
00202 
00208     protected function _seoSetVendorData()
00209     {
00210         // only when SEO id on and in front end
00211         if ( oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) {
00212 
00213             $oEncoder = oxSeoEncoderVendor::getInstance();
00214 
00215             // preparing root vendor category
00216             if ($this->_oRoot) {
00217                 $oEncoder->getVendorUrl($this->_oRoot);
00218             }
00219 
00220             // encoding vendor category
00221             foreach ($this as $sVndId => $value) {
00222                 $oEncoder->getVendorUrl( $this->_aArray[$sVndId] );
00223             }
00224         }
00225     }
00226 }