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         $sLangAdd = oxLang::getInstance()->getLanguageTag();
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{$sLangAdd} != '' ";
00082         }
00083 
00084         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle{$sLangAdd}";
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 
00152     public function getHtmlPath()
00153     {
00154         $sHtmlVendTree = '';
00155         $sSep         = '';
00156         foreach ($this->_aPath as $oManufacturer) {
00157             $sHtmlVendTree .= " $sSep<a href='".$oManufacturer->getLink()."'>".$oManufacturer->oxmanufacturers__oxtitle->value."</a>";
00158             $sSep = '/ ';
00159         }
00160         return $sHtmlVendTree;
00161     }
00162 
00170     protected function _addCategoryFields( $oManufacturer )
00171     {
00172         $oManufacturer->oxcategories__oxid    = new oxField( $oManufacturer->oxmanufacturers__oxid->value );
00173         $oManufacturer->oxcategories__oxicon  = $oManufacturer->oxmanufacturers__oxicon;
00174         $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
00175         $oManufacturer->oxcategories__oxdesc  = $oManufacturer->oxmanufacturers__oxshortdesc;
00176 
00177         $oManufacturer->setIsVisible( true );
00178         $oManufacturer->setHasVisibleSubCats( false );
00179     }
00180 
00188     public function setClickManufacturer( $oManufacturer )
00189     {
00190         $this->_oClickedManufacturer = $oManufacturer;
00191     }
00192 
00198     public function getClickManufacturer()
00199     {
00200         return $this->_oClickedManufacturer;
00201     }
00202 
00208     protected function _seoSetManufacturerData()
00209     {
00210         // only when SEO id on and in front end
00211         if ( oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) {
00212 
00213             $oEncoder = oxSeoEncoderManufacturer::getInstance();
00214 
00215             // preparing root manufacturer category
00216             if ($this->_oRoot) {
00217                 $oEncoder->getManufacturerUrl($this->_oRoot);
00218             }
00219 
00220             // encoding manufacturer category
00221             foreach ($this as $sVndId => $value) {
00222                 $oEncoder->getManufacturerUrl( $this->_aArray[$sVndId] );
00223             }
00224         }
00225     }
00226 }

Generated by  doxygen 1.6.2