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         $myConfig = $this->getConfig();
00083 
00084         // load Manufacturer
00085         if ( $this->getManufacturerTree() ) {
00086             if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00087                 if ( $oManufacturer->getId() != 'root' ) {
00088                     // load the articles
00089                     $this->getArticleList();
00090 
00091                     // processing list articles
00092                     $this->_processListArticles();
00093                 }
00094             }
00095         }
00096 
00097         // generating meta info
00098         $this->setMetaDescription( null );
00099         $this->setMetaKeywords( null );
00100 
00101         return $this->_sThisTemplate;
00102     }
00103 
00109     protected function _getProductLinkType()
00110     {
00111         return OXARTICLE_LINKTYPE_MANUFACTURER;
00112     }
00113 
00123     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00124     {
00125         parent::setItemSorting( oxConfig::getParameter( 'mnid' ) .':manufacturer', $sSortBy, $sSortDir );
00126     }
00127 
00135     public function getSorting( $sCnid )
00136     {
00137         return parent::getSorting( oxConfig::getParameter( 'mnid' ) .':manufacturer' );
00138     }
00139 
00147     protected function _loadArticles( $oManufacturer )
00148     {
00149         $sManufacturerId = $oManufacturer->getId();
00150 
00151         // load only articles which we show on screen
00152         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00153         $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00154 
00155         $oArtList = oxNew( 'oxarticlelist' );
00156         $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00157         $oArtList->setCustomSorting( $this->getSortingSql( $sManufacturerId ) );
00158 
00159         // load the articles
00160         $this->_iAllArtCnt = $oArtList->loadManufacturerArticles( $sManufacturerId, $oManufacturer );
00161 
00162         // counting pages
00163         $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00164 
00165         return array( $oArtList, $this->_iAllArtCnt );
00166     }
00167 
00173     protected function _getSeoObjectId()
00174     {
00175         $sId = null;
00176         if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00177             $sId = $oManufacturer->getId();
00178         }
00179         return $sId;
00180     }
00181 
00192     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00193     {
00194         if ( oxUtils::getInstance()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) {
00195             if ( $iPage ) {
00196                 // only if page number > 0
00197                 $sUrl = $oManufacturer->getBaseSeoLink( $iLang, $iPage );
00198             }
00199         } else {
00200             $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
00201         }
00202         return $sUrl;
00203     }
00204 
00210     public function generatePageNavigationUrl()
00211     {
00212         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) ) {
00213             return $oManufacturer->getLink();
00214         } else {
00215             return parent::generatePageNavigationUrl( );
00216         }
00217     }
00218 
00224     public function hasVisibleSubCats()
00225     {
00226         if ( $this->_blVisibleSubCats === null ) {
00227             $this->_blVisibleSubCats = false;
00228             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00229                 if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
00230                     if ( $oManufacturer->getId() == 'root' ) {
00231                         $this->_blVisibleSubCats = $oManufacturerTree->count();
00232                         $this->_oSubCatList = $oManufacturerTree;
00233                     }
00234                 }
00235             }
00236         }
00237         return $this->_blVisibleSubCats;
00238     }
00239 
00245     public function getSubCatList()
00246     {
00247         if ( $this->_oSubCatList === null ) {
00248             $this->_oSubCatList = $this->hasVisibleSubCats() ? $this->_oSubCatList : array();
00249         }
00250         return $this->_oSubCatList;
00251     }
00252 
00258     public function getArticleList()
00259     {
00260         if ( $this->_aArticleList === null ) {
00261             $this->_aArticleList = array();
00262             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00263                 if ( ( $oManufacturer = $this->getActManufacturer() ) && ( $oManufacturer->getId() != 'root' ) ) {
00264                     list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oManufacturer );
00265                     if ( $iAllArtCnt ) {
00266                         $this->_aArticleList = $aArticleList;
00267                     }
00268                 }
00269             }
00270         }
00271         return $this->_aArticleList;
00272     }
00273 
00279     public function getTitle()
00280     {
00281         if ( $this->_sCatTitle === null ) {
00282             $this->_sCatTitle = '';
00283             if ( $oManufacturerTree = $this->getManufacturerTree() ) {
00284                 if ( $oManufacturer = $this->getActManufacturer() ) {
00285                     $this->_sCatTitle = $oManufacturer->oxmanufacturers__oxtitle->value;
00286                 }
00287             }
00288         }
00289         return $this->_sCatTitle;
00290     }
00291 
00297     public function getTreePath()
00298     {
00299         $aPath = null;
00300         if ( $oManufacturerTree = $this->getManufacturerTree() ) {
00301             $aPath = $oManufacturerTree->getPath();
00302         }
00303         return $aPath;
00304     }
00305 
00311     public function getActiveCategory()
00312     {
00313         if ( $this->_oActCategory === null ) {
00314             $this->_oActCategory = false;
00315             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00316                 if ( $oManufacturer = $this->getActManufacturer() ) {
00317                     $this->_oActCategory = $oManufacturer;
00318                 }
00319             }
00320         }
00321         return $this->_oActCategory;
00322     }
00323 
00329     public function getCatTreePath()
00330     {
00331         if ( $this->_sCatTreePath === null ) {
00332             $this->_sCatTreePath = false;
00333             if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
00334                 $this->_sCatTreePath  = $oManufacturerTree->getPath();
00335             }
00336         }
00337         return $this->_sCatTreePath;
00338     }
00339 
00345     public function getTitleSuffix()
00346     {
00347         $sSuffix = null;
00348         if ( $this->getActManufacturer()->oxmanufacturers__oxshowsuffix->value ) {
00349             $sSuffix = $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00350         }
00351         return $sSuffix;
00352     }
00353 
00362     protected function _prepareMetaKeyword( $aCatPath, $blRemoveDuplicatedWords = true )
00363     {
00364         return parent::_collectMetaKeyword( $aCatPath );
00365     }
00366 
00379     protected function _prepareMetaDescription( $aCatPath, $iLength = 1024, $blDescTag = false )
00380     {
00381         return parent::_collectMetaDescription( $aCatPath, $iLength, $blDescTag );
00382     }
00383 
00392     protected function _getSubject( $iLang )
00393     {
00394         return $this->getActManufacturer();
00395     }
00396 
00402     public function getAddUrlParams()
00403     {
00404         $sAddParams  = parent::getAddUrlParams();
00405         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00406         if ( $oManufacturer = $this->getActManufacturer() ) {
00407             $sAddParams .= "&amp;mnid=" . $oManufacturer->getId();
00408         }
00409         return $sAddParams;
00410     }
00411 
00417     public function getBreadCrumb()
00418     {
00419         $aPaths = array();
00420 
00421         $oCatTree = $this->getManufacturerTree()->getPath();
00422 
00423         if ( $oCatTree ) {
00424             foreach ( $oCatTree as $oCat ) {
00425                 $aCatPath = array();
00426                 $aCatPath['link'] = $oCat->getLink();
00427                 $aCatPath['title'] = $oCat->oxmanufacturers__oxtitle->value;
00428 
00429                 $aPaths[] = $aCatPath;
00430             }
00431         }
00432 
00433         return $aPaths;
00434     }
00435 }