manufacturerlist.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class ManufacturerList extends aList
00010 {
00015     protected $_sListType = 'manufacturer';
00016 
00021     protected $_blVisibleSubCats = null;
00022 
00027     protected $_oSubCatList = null;
00028 
00033     protected $_oRecommList = null;
00034 
00040     protected $_sTplLocation = null;
00041 
00047     protected $_sCatTitle = null;
00048 
00053     protected $_oPageNavigation = null;
00054 
00059     protected $_blShowSorting = true;
00060 
00066     protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00067 
00078     public function render()
00079     {
00080         oxUBase::render();
00081 
00082         // load Manufacturer
00083         if ( $this->getManufacturerTree() ) {
00084             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00085                 if ( $oManufacturer->getId() != 'root' ) {
00086                     // load the articles
00087                     $this->getArticleList();
00088 
00089                     // checking if requested page is correct
00090                     $this->_checkRequestedPage();
00091 
00092                     // processing list articles
00093                     $this->_processListArticles();
00094                 }
00095             }
00096         }
00097 
00098         return $this->_sThisTemplate;
00099     }
00100 
00106     protected function _getProductLinkType()
00107     {
00108         return OXARTICLE_LINKTYPE_MANUFACTURER;
00109     }
00110 
00122     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00123     {
00124         parent::setItemSorting( $sCnid, $sSortBy, $sSortDir );
00125     }
00126 
00136     public function getSorting( $sCnid )
00137     {
00138         return parent::getSorting( $sCnid );
00139     }
00140 
00148     protected function _loadArticles( $oManufacturer )
00149     {
00150         $sManufacturerId = $oManufacturer->getId();
00151 
00152         // load only articles which we show on screen
00153         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00154         $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00155 
00156         $oArtList = oxNew( 'oxarticlelist' );
00157         $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00158         $oArtList->setCustomSorting( $this->getSortingSql( $this->getSortIdent() ) );
00159 
00160         // load the articles
00161         $this->_iAllArtCnt = $oArtList->loadManufacturerArticles( $sManufacturerId, $oManufacturer );
00162 
00163         // counting pages
00164         $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00165 
00166         return array( $oArtList, $this->_iAllArtCnt );
00167     }
00168 
00174     protected function _getSeoObjectId()
00175     {
00176         $sId = null;
00177         if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00178             $sId = $oManufacturer->getId();
00179         }
00180         return $sId;
00181     }
00182 
00193     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00194     {
00195         if ( oxRegistry::getUtils()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) {
00196             if ( $iPage ) {
00197                 // only if page number > 0
00198                 $sUrl = $oManufacturer->getBaseSeoLink( $iLang, $iPage );
00199             }
00200         } else {
00201             $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
00202         }
00203         return $sUrl;
00204     }
00205 
00211     public function generatePageNavigationUrl()
00212     {
00213         if ( ( oxRegistry::getUtils()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) ) {
00214             return $oManufacturer->getLink();
00215         } else {
00216             return parent::generatePageNavigationUrl( );
00217         }
00218     }
00219 
00225     public function hasVisibleSubCats()
00226     {
00227         if ( $this->_blVisibleSubCats === null ) {
00228             $this->_blVisibleSubCats = false;
00229             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00230                 if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00231                     if ( $oManufacturer->getId() == 'root' ) {
00232                         $this->_blVisibleSubCats = $oManufacturerTree->count();
00233                         $this->_oSubCatList = $oManufacturerTree;
00234                     }
00235                 }
00236             }
00237         }
00238         return $this->_blVisibleSubCats;
00239     }
00240 
00246     public function getSubCatList()
00247     {
00248         if ( $this->_oSubCatList === null ) {
00249             $this->_oSubCatList = $this->hasVisibleSubCats() ? $this->_oSubCatList : array();
00250         }
00251         return $this->_oSubCatList;
00252     }
00253 
00259     public function getArticleList()
00260     {
00261         if ( $this->_aArticleList === null ) {
00262             $this->_aArticleList = array();
00263             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00264                 if ( ( $oManufacturer = $this->getActManufacturer() ) && ( $oManufacturer->getId() != 'root' ) && $oManufacturer->getIsVisible() ) {
00265                     list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oManufacturer );
00266                     if ( $iAllArtCnt ) {
00267                         $this->_aArticleList = $aArticleList;
00268                     }
00269                 }
00270             }
00271         }
00272         return $this->_aArticleList;
00273     }
00274 
00280     public function getTitle()
00281     {
00282         if ( $this->_sCatTitle === null ) {
00283             $this->_sCatTitle = '';
00284             if ( $oManufacturerTree = $this->getManufacturerTree() ) {
00285                 if ( $oManufacturer = $this->getActManufacturer() ) {
00286                     $this->_sCatTitle = $oManufacturer->oxmanufacturers__oxtitle->value;
00287                 }
00288             }
00289         }
00290         return $this->_sCatTitle;
00291     }
00292 
00298     public function getTreePath()
00299     {
00300         $aPath = null;
00301         if ( $oManufacturerTree = $this->getManufacturerTree() ) {
00302             $aPath = $oManufacturerTree->getPath();
00303         }
00304         return $aPath;
00305     }
00306 
00312     public function getActiveCategory()
00313     {
00314         if ( $this->_oActCategory === null ) {
00315             $this->_oActCategory = false;
00316             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00317                 if ( $oManufacturer = $this->getActManufacturer() ) {
00318                     $this->_oActCategory = $oManufacturer;
00319                 }
00320             }
00321         }
00322         return $this->_oActCategory;
00323     }
00324 
00330     public function getCatTreePath()
00331     {
00332         if ( $this->_sCatTreePath === null ) {
00333             $this->_sCatTreePath = false;
00334             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00335                 $this->_sCatTreePath  = $oManufacturerTree->getPath();
00336             }
00337         }
00338         return $this->_sCatTreePath;
00339     }
00340 
00346     public function getTitleSuffix()
00347     {
00348         $sSuffix = null;
00349         if ( $this->getActManufacturer()->oxmanufacturers__oxshowsuffix->value ) {
00350             $sSuffix = $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00351         }
00352         return $sSuffix;
00353     }
00354 
00363     protected function _prepareMetaKeyword( $aCatPath, $blRemoveDuplicatedWords = true )
00364     {
00365         return parent::_collectMetaKeyword( $aCatPath );
00366     }
00367 
00380     protected function _prepareMetaDescription( $aCatPath, $iLength = 1024, $blDescTag = false )
00381     {
00382         return parent::_collectMetaDescription( $aCatPath, $iLength, $blDescTag );
00383     }
00384 
00393     protected function _getSubject( $iLang )
00394     {
00395         return $this->getActManufacturer();
00396     }
00397 
00403     public function getAddUrlParams()
00404     {
00405         $sAddParams  = parent::getAddUrlParams();
00406         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00407         if ( $oManufacturer = $this->getActManufacturer() ) {
00408             $sAddParams .= "&amp;mnid=" . $oManufacturer->getId();
00409         }
00410         return $sAddParams;
00411     }
00412 
00418     public function getBreadCrumb()
00419     {
00420         $aPaths = array();
00421 
00422         $oCatTree = $this->getManufacturerTree();
00423 
00424         if ( $oCatTree ) {
00425             foreach ( $oCatTree->getPath() as $oCat ) {
00426                 $aCatPath = array();
00427                 $aCatPath['link'] = $oCat->getLink();
00428                 $aCatPath['title'] = $oCat->oxmanufacturers__oxtitle->value;
00429 
00430                 $aPaths[] = $aCatPath;
00431             }
00432         }
00433 
00434         return $aPaths;
00435     }
00436 
00443     public function getAttributes()
00444     {
00445         return null;
00446     }
00447 }