oxmanufacturerlist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxManufacturerList extends oxList
00008 {
00014     protected $_oRoot = null;
00015 
00021     protected $_aPath = array();
00022 
00028     protected $_blShowManufacturerArticleCnt = false;
00029 
00035     protected $_oClickedManufacturer = null;
00036 
00045     public function __construct( $sObjectsInListName = 'oxmanufacturer')
00046     {
00047         $this->setShowManufacturerArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00048         parent::__construct( 'oxmanufacturer');
00049     }
00050 
00058     public function setShowManufacturerArticleCnt( $blShowManufacturerArticleCnt = false )
00059     {
00060         $this->_blShowManufacturerArticleCnt = $blShowManufacturerArticleCnt;
00061     }
00062 
00068     public function loadManufacturerList()
00069     {
00070         $oBaseObject = $this->getBaseObject();
00071 
00072         $sFieldList = $oBaseObject->getSelectFields();
00073         $sViewName  = $oBaseObject->getViewName();
00074         $this->getBaseObject()->setShowArticleCnt( $this->_blShowManufacturerArticleCnt );
00075 
00076         $sWhere = '';
00077         if ( !$this->isAdmin() ) {
00078             $sWhere  = $oBaseObject->getSqlActiveSnippet();
00079             $sWhere  = $sWhere?" where $sWhere and ":' where ';
00080             $sWhere .= "{$sViewName}.oxtitle != '' ";
00081         }
00082 
00083         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
00084         $this->selectString( $sSelect );
00085     }
00086 
00096     public function buildManufacturerTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
00097     {
00098         //Load manufacturer list
00099         $this->loadManufacturerList();
00100 
00101 
00102         //Create fake manufacturer root category
00103         $this->_oRoot = oxNew( "oxManufacturer" );
00104         $this->_oRoot->load( "root" );
00105 
00106         //category fields
00107         $this->_addCategoryFields( $this->_oRoot );
00108         $this->_aPath[] = $this->_oRoot;
00109 
00110         foreach ( $this as $sVndId => $oManufacturer ) {
00111 
00112             // storing active manufacturer object
00113             if ( $sVndId == $sActCat ) {
00114                 $this->setClickManufacturer( $oManufacturer );
00115             }
00116 
00117             $this->_addCategoryFields( $oManufacturer );
00118             if ( $sActCat == $oManufacturer->oxmanufacturers__oxid->value ) {
00119                 $this->_aPath[] = $oManufacturer;
00120             }
00121         }
00122 
00123         $this->_seoSetManufacturerData();
00124     }
00125 
00131     public function getRootCat()
00132     {
00133         return $this->_oRoot;
00134     }
00135 
00141     public function getPath()
00142     {
00143         return $this->_aPath;
00144     }
00145 
00151     public function getHtmlPath()
00152     {
00153         $sHtmlVendTree = '';
00154         $sSep         = '';
00155         foreach ($this->_aPath as $oManufacturer) {
00156             $sHtmlVendTree .= " $sSep<a href='".$oManufacturer->getLink()."'>".$oManufacturer->oxmanufacturers__oxtitle->value."</a>";
00157             $sSep = '/ ';
00158         }
00159         return $sHtmlVendTree;
00160     }
00161 
00169     protected function _addCategoryFields( $oManufacturer )
00170     {
00171         $oManufacturer->oxcategories__oxid    = new oxField( $oManufacturer->oxmanufacturers__oxid->value );
00172         $oManufacturer->oxcategories__oxicon  = $oManufacturer->oxmanufacturers__oxicon;
00173         $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
00174         $oManufacturer->oxcategories__oxdesc  = $oManufacturer->oxmanufacturers__oxshortdesc;
00175 
00176         $oManufacturer->setIsVisible( true );
00177         $oManufacturer->setHasVisibleSubCats( false );
00178     }
00179 
00187     public function setClickManufacturer( $oManufacturer )
00188     {
00189         $this->_oClickedManufacturer = $oManufacturer;
00190     }
00191 
00197     public function getClickManufacturer()
00198     {
00199         return $this->_oClickedManufacturer;
00200     }
00201 
00207     protected function _seoSetManufacturerData()
00208     {
00209         // only when SEO id on and in front end
00210         if ( oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) {
00211 
00212             $oEncoder = oxSeoEncoderManufacturer::getInstance();
00213 
00214             // preparing root manufacturer category
00215             if ($this->_oRoot) {
00216                 $oEncoder->getManufacturerUrl($this->_oRoot);
00217             }
00218 
00219             // encoding manufacturer category
00220             foreach ($this as $sVndId => $value) {
00221                 $oEncoder->getManufacturerUrl( $this->_aArray[$sVndId] );
00222             }
00223         }
00224     }
00225 }