vendorlist.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class VendorList extends aList
00010 {
00015     protected $_sListType = 'vendor';
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 vendor
00085         if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00086             if ( ( $oVendor = $this->getActVendor() ) ) {
00087                 if ( $oVendor->getId() != 'root' ) {
00088                     // load the articles
00089                     $this->getArticleList();
00090 
00091                     // processing list articles
00092                     $this->_processListArticles();
00093                 }
00094             }
00095         }
00096 
00097         return $this->_sThisTemplate;
00098     }
00099 
00105     protected function _getProductLinkType()
00106     {
00107         return OXARTICLE_LINKTYPE_VENDOR;
00108     }
00109 
00119     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00120     {
00121         parent::setItemSorting( str_replace( 'v_', '', $sCnid ).':vendor', $sSortBy, $sSortDir );
00122     }
00123 
00131     public function getSorting( $sCnid )
00132     {
00133         return parent::getSorting( str_replace( 'v_', '', $sCnid ).':vendor' );
00134     }
00135 
00143     protected function _loadArticles( $oVendor )
00144     {
00145         $sVendorId = $oVendor->getId();
00146 
00147         // load only articles which we show on screen
00148         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00149         $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00150 
00151         $oArtList = oxNew( 'oxarticlelist' );
00152         $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00153         $oArtList->setCustomSorting( $this->getSortingSql( $sVendorId ) );
00154 
00155         // load the articles
00156         $this->_iAllArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00157 
00158         // counting pages
00159         $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00160 
00161         return array( $oArtList, $this->_iAllArtCnt );
00162     }
00163 
00169     protected function _getSeoObjectId()
00170     {
00171         if ( ( $oVendor = $this->getActVendor() ) ) {
00172             return $oVendor->getId();
00173         }
00174     }
00175 
00186     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00187     {
00188         if ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00189             if ( $iPage ) {
00190                 // only if page number > 0
00191                 $sUrl = $oVendor->getBaseSeoLink( $iLang, $iPage );
00192             }
00193         } else {
00194             $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00195         }
00196         return $sUrl;
00197     }
00198 
00204     public function generatePageNavigationUrl( )
00205     {
00206         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00207             return $oVendor->getLink();
00208         } else {
00209             return parent::generatePageNavigationUrl( );
00210         }
00211     }
00212 
00218     public function hasVisibleSubCats()
00219     {
00220         if ( $this->_blVisibleSubCats === null ) {
00221             $this->_blVisibleSubCats = false;
00222             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00223                 if ( ( $oVendor = $this->getActVendor() ) ) {
00224                     if ( $oVendor->getId() == 'root' ) {
00225                         $this->_blVisibleSubCats = $oVendorTree->count();
00226                         $this->_oSubCatList = $oVendorTree;
00227                     }
00228                 }
00229             }
00230         }
00231         return $this->_blVisibleSubCats;
00232     }
00233 
00239     public function getSubCatList()
00240     {
00241         if ( $this->_oSubCatList === null ) {
00242             $this->_oSubCatList = array();
00243             if ( $this->hasVisibleSubCats() ) {
00244                 return $this->_oSubCatList;
00245             }
00246         }
00247         return $this->_oSubCatList;
00248     }
00249 
00255     public function getArticleList()
00256     {
00257         if ( $this->_aArticleList === null ) {
00258             $this->_aArticleList = array();
00259             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00260                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00261                     list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oVendor );
00262                     if ( $iAllArtCnt ) {
00263                         $this->_aArticleList = $aArticleList;
00264                     }
00265                 }
00266             }
00267         }
00268         return $this->_aArticleList;
00269     }
00270 
00276     public function getTitle()
00277     {
00278         if ( $this->_sCatTitle === null ) {
00279             $this->_sCatTitle = '';
00280             if ( $oVendorTree = $this->getVendorTree() ) {
00281                 if ( $oVendor = $this->getActVendor() ) {
00282                     $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00283                 }
00284             }
00285         }
00286         return $this->_sCatTitle;
00287     }
00288 
00294     public function getTreePath()
00295     {
00296         if ( $oVendorTree = $this->getVendorTree() ) {
00297             return $oVendorTree->getPath();
00298         }
00299     }
00300 
00306     public function getActiveCategory()
00307     {
00308         if ( $this->_oActCategory === null ) {
00309             $this->_oActCategory = false;
00310             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00311                 if ( $oVendor = $this->getActVendor() ) {
00312                     $this->_oActCategory = $oVendor;
00313                 }
00314             }
00315         }
00316         return $this->_oActCategory;
00317     }
00318 
00324     public function getCatTreePath()
00325     {
00326         if ( $this->_sCatTreePath === null ) {
00327             $this->_sCatTreePath = false;
00328             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00329                 $this->_sCatTreePath  = $oVendorTree->getPath();
00330             }
00331         }
00332         return $this->_sCatTreePath;
00333     }
00334 
00340     public function getTitleSuffix()
00341     {
00342         if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00343             return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00344         }
00345     }
00346 
00356     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00357     {
00358         return parent::_collectMetaKeyword( $sKeywords );
00359     }
00360 
00371     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00372     {
00373         return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00374     }
00375 
00384     protected function _getSubject( $iLang )
00385     {
00386         return $this->getActVendor();
00387     }
00388 
00394     public function getAddUrlParams()
00395     {
00396         $sAddParams  = parent::getAddUrlParams();
00397         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00398         if ( $oVendor = $this->getActVendor() ) {
00399             $sAddParams .= "&amp;cnid=v_" . $oVendor->getId();
00400         }
00401         return $sAddParams;
00402     }
00403 
00409     public function getBreadCrumb()
00410     {
00411         $aPaths = array();
00412 
00413         $oCatTree = $this->getVendorTree()->getPath();
00414 
00415         if ( $oCatTree ) {
00416             foreach ( $oCatTree as $oCat ) {
00417                 $aCatPath = array();
00418 
00419                 $aCatPath['link'] = $oCat->getLink();
00420                 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
00421 
00422                 $aPaths[] = $aCatPath;
00423             }
00424         }
00425 
00426         return $aPaths;
00427     }
00428 }