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