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 = oxVendor::getRootVendor();
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         if (!oxUtils::getInstance()->seoIsActive()) {
00211             return;
00212         }
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 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5