oxmanufacturerlist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxManufacturerList extends oxList
00009 {
00010 
00016     protected $_oRoot = null;
00017 
00023     protected $_aPath = array();
00024 
00030     protected $_blShowManufacturerArticleCnt = false;
00031 
00037     protected $_oClickedManufacturer = null;
00038 
00044     public function __construct()
00045     {
00046         $this->setShowManufacturerArticleCnt($this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt'));
00047         parent::__construct('oxmanufacturer');
00048     }
00049 
00055     public function setShowManufacturerArticleCnt($blShowManufacturerArticleCnt = false)
00056     {
00057         $this->_blShowManufacturerArticleCnt = $blShowManufacturerArticleCnt;
00058     }
00059 
00063     public function loadManufacturerList()
00064     {
00065         $oBaseObject = $this->getBaseObject();
00066 
00067         $sFieldList = $oBaseObject->getSelectFields();
00068         $sViewName = $oBaseObject->getViewName();
00069         $this->getBaseObject()->setShowArticleCnt($this->_blShowManufacturerArticleCnt);
00070 
00071         $sWhere = '';
00072         if (!$this->isAdmin()) {
00073             $sWhere = $oBaseObject->getSqlActiveSnippet();
00074             $sWhere = $sWhere ? " where $sWhere and " : ' where ';
00075             $sWhere .= "{$sViewName}.oxtitle != '' ";
00076         }
00077 
00078         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
00079         $this->selectString($sSelect);
00080     }
00081 
00089     public function buildManufacturerTree($sLinkTarget, $sActCat, $sShopHomeUrl)
00090     {
00091         //Load manufacturer list
00092         $this->loadManufacturerList();
00093 
00094 
00095         //Create fake manufacturer root category
00096         $this->_oRoot = oxNew("oxManufacturer");
00097         $this->_oRoot->load("root");
00098 
00099         //category fields
00100         $this->_addCategoryFields($this->_oRoot);
00101         $this->_aPath[] = $this->_oRoot;
00102 
00103         foreach ($this as $sVndId => $oManufacturer) {
00104 
00105             // storing active manufacturer object
00106             if ($sVndId == $sActCat) {
00107                 $this->setClickManufacturer($oManufacturer);
00108             }
00109 
00110             $this->_addCategoryFields($oManufacturer);
00111             if ($sActCat == $oManufacturer->oxmanufacturers__oxid->value) {
00112                 $this->_aPath[] = $oManufacturer;
00113             }
00114         }
00115 
00116         $this->_seoSetManufacturerData();
00117     }
00118 
00124     public function getRootCat()
00125     {
00126         return $this->_oRoot;
00127     }
00128 
00134     public function getPath()
00135     {
00136         return $this->_aPath;
00137     }
00138 
00144     protected function _addCategoryFields($oManufacturer)
00145     {
00146         $oManufacturer->oxcategories__oxid = new oxField($oManufacturer->oxmanufacturers__oxid->value);
00147         $oManufacturer->oxcategories__oxicon = $oManufacturer->oxmanufacturers__oxicon;
00148         $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
00149         $oManufacturer->oxcategories__oxdesc = $oManufacturer->oxmanufacturers__oxshortdesc;
00150 
00151         $oManufacturer->setIsVisible(true);
00152         $oManufacturer->setHasVisibleSubCats(false);
00153     }
00154 
00160     public function setClickManufacturer($oManufacturer)
00161     {
00162         $this->_oClickedManufacturer = $oManufacturer;
00163     }
00164 
00170     public function getClickManufacturer()
00171     {
00172         return $this->_oClickedManufacturer;
00173     }
00174 
00178     protected function _seoSetManufacturerData()
00179     {
00180         // only when SEO id on and in front end
00181         if (oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
00182 
00183             $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
00184 
00185             // preparing root manufacturer category
00186             if ($this->_oRoot) {
00187                 $oEncoder->getManufacturerUrl($this->_oRoot);
00188             }
00189 
00190             // encoding manufacturer category
00191             foreach ($this as $sVndId => $value) {
00192                 $oEncoder->getManufacturerUrl($this->_aArray[$sVndId]);
00193             }
00194         }
00195     }
00196 }