oxmanufacturerlist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxManufacturerList extends oxList
00009 {
00015     protected $_oRoot = null;
00016 
00022     protected $_aPath = array();
00023 
00029     protected $_blShowManufacturerArticleCnt = false;
00030 
00036     protected $_oClickedManufacturer = null;
00037 
00046     public function __construct( $sObjectsInListName = 'oxmanufacturer')
00047     {
00048         $this->setShowManufacturerArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00049         parent::__construct( 'oxmanufacturer');
00050     }
00051 
00059     public function setShowManufacturerArticleCnt( $blShowManufacturerArticleCnt = false )
00060     {
00061         $this->_blShowManufacturerArticleCnt = $blShowManufacturerArticleCnt;
00062     }
00063 
00069     public function loadManufacturerList()
00070     {
00071         $oBaseObject = $this->getBaseObject();
00072 
00073         $sFieldList = $oBaseObject->getSelectFields();
00074         $sViewName  = $oBaseObject->getViewName();
00075         $this->getBaseObject()->setShowArticleCnt( $this->_blShowManufacturerArticleCnt );
00076 
00077         $sWhere = '';
00078         if ( !$this->isAdmin() ) {
00079             $sWhere  = $oBaseObject->getSqlActiveSnippet();
00080             $sWhere  = $sWhere?" where $sWhere and ":' where ';
00081             $sWhere .= "{$sViewName}.oxtitle != '' ";
00082         }
00083 
00084         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
00085         $this->selectString( $sSelect );
00086     }
00087 
00097     public function buildManufacturerTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
00098     {
00099         //Load manufacturer list
00100         $this->loadManufacturerList();
00101 
00102 
00103         //Create fake manufacturer root category
00104         $this->_oRoot = oxNew( "oxManufacturer" );
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 => $oManufacturer ) {
00112 
00113             // storing active manufacturer object
00114             if ( $sVndId == $sActCat ) {
00115                 $this->setClickManufacturer( $oManufacturer );
00116             }
00117 
00118             $this->_addCategoryFields( $oManufacturer );
00119             if ( $sActCat == $oManufacturer->oxmanufacturers__oxid->value ) {
00120                 $this->_aPath[] = $oManufacturer;
00121             }
00122         }
00123 
00124         $this->_seoSetManufacturerData();
00125     }
00126 
00132     public function getRootCat()
00133     {
00134         return $this->_oRoot;
00135     }
00136 
00142     public function getPath()
00143     {
00144         return $this->_aPath;
00145     }
00146 
00154     protected function _addCategoryFields( $oManufacturer )
00155     {
00156         $oManufacturer->oxcategories__oxid    = new oxField( $oManufacturer->oxmanufacturers__oxid->value );
00157         $oManufacturer->oxcategories__oxicon  = $oManufacturer->oxmanufacturers__oxicon;
00158         $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
00159         $oManufacturer->oxcategories__oxdesc  = $oManufacturer->oxmanufacturers__oxshortdesc;
00160 
00161         $oManufacturer->setIsVisible( true );
00162         $oManufacturer->setHasVisibleSubCats( false );
00163     }
00164 
00172     public function setClickManufacturer( $oManufacturer )
00173     {
00174         $this->_oClickedManufacturer = $oManufacturer;
00175     }
00176 
00182     public function getClickManufacturer()
00183     {
00184         return $this->_oClickedManufacturer;
00185     }
00186 
00192     protected function _seoSetManufacturerData()
00193     {
00194         // only when SEO id on and in front end
00195         if ( oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
00196 
00197             $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
00198 
00199             // preparing root manufacturer category
00200             if ($this->_oRoot) {
00201                 $oEncoder->getManufacturerUrl($this->_oRoot);
00202             }
00203 
00204             // encoding manufacturer category
00205             foreach ($this as $sVndId => $value) {
00206                 $oEncoder->getManufacturerUrl( $this->_aArray[$sVndId] );
00207             }
00208         }
00209     }
00210 }