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 
00082     public function render()
00083     {
00084         oxUBase::render();
00085 
00086         $myConfig = $this->getConfig();
00087 
00088         // load vendor
00089         if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00090             if ( ( $oVendor = $this->getActVendor() ) ) {
00091                 if ( $oVendor->getId() != 'root' ) {
00092                     // load only articles which we show on screen
00093                     $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00094                     $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00095 
00096                     // load the articles
00097                     $this->getArticleList();
00098                     $this->_iCntPages  = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00099 
00100                 }
00101             }
00102         }
00103         $this->_aViewData['hasVisibleSubCats'] = $this->hasVisibleSubCats();
00104         $this->_aViewData['subcatlist']        = $this->getSubCatList();
00105         $this->_aViewData['articlelist']       = $this->getArticleList();
00106         $this->_aViewData['similarrecommlist'] = $this->getSimilarRecommLists();
00107 
00108         $this->_aViewData['title']             = $this->getTitle();
00109         $this->_aViewData['template_location'] = $this->getTemplateLocation();
00110         $this->_aViewData['actCategory']       = $this->getActiveCategory();
00111         $this->_aViewData['actCatpath']        = $this->getCatTreePath();
00112 
00113         $this->_aViewData['pageNavigation'] = $this->getPageNavigation();
00114 
00115         // processing list articles
00116         $this->_processListArticles();
00117 
00118         return $this->_sThisTemplate;
00119     }
00120 
00126     protected function _getProductLinkType()
00127     {
00128         return OXARTICLE_LINKTYPE_VENDOR;
00129     }
00130 
00140     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00141     {
00142         parent::setItemSorting( str_replace( 'v_', '', $sCnid ).':vendor', $sSortBy, $sSortDir );
00143     }
00144 
00152     public function getSorting( $sCnid )
00153     {
00154         return parent::getSorting( str_replace( 'v_', '', $sCnid ).':vendor' );
00155     }
00156 
00164     protected function _loadArticles( $oVendor )
00165     {
00166         $sVendorId = $oVendor->getId();
00167 
00168         // load only articles which we show on screen
00169         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00170         $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00171 
00172         $oArtList = oxNew( 'oxarticlelist' );
00173         $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00174         $oArtList->setCustomSorting( $this->getSortingSql( $sVendorId ) );
00175 
00176         // load the articles
00177         $iArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00178 
00179         return array( $oArtList, $iArtCnt );
00180     }
00181 
00187     protected function _getSeoObjectId()
00188     {
00189         if ( ( $oVendor = $this->getActVendor() ) ) {
00190             return $oVendor->getId();
00191         }
00192     }
00193 
00204     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00205     {
00206         if ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00207             if ( $iPage ) {
00208                 // only if page number > 0
00209                 $sUrl = $oVendor->getBaseSeoLink( $iLang, $iPage );
00210             }
00211         } else {
00212             $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00213         }
00214         return $sUrl;
00215     }
00216 
00222     public function generatePageNavigationUrl( )
00223     {
00224         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00225             return $oVendor->getLink();
00226         } else {
00227             return parent::generatePageNavigationUrl( );
00228         }
00229     }
00230 
00236     public function hasVisibleSubCats()
00237     {
00238         if ( $this->_blVisibleSubCats === null ) {
00239             $this->_blVisibleSubCats = false;
00240             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00241                 if ( ( $oVendor = $this->getActVendor() ) ) {
00242                     if ( $oVendor->getId() == 'root' ) {
00243                         $this->_blVisibleSubCats = $oVendorTree->count();
00244                         $this->_oSubCatList = $oVendorTree;
00245                     }
00246                 }
00247             }
00248         }
00249         return $this->_blVisibleSubCats;
00250     }
00251 
00257     public function getSubCatList()
00258     {
00259         if ( $this->_oSubCatList === null ) {
00260             $this->_oSubCatList = array();
00261             if ( $this->hasVisibleSubCats() ) {
00262                 return $this->_oSubCatList;
00263             }
00264         }
00265         return $this->_oSubCatList;
00266     }
00267 
00273     public function getArticleList()
00274     {
00275         if ( $this->_aArticleList === null ) {
00276             $this->_aArticleList = array();
00277             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00278                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00279                     list( $aArticleList, $this->_iAllArtCnt ) = $this->_loadArticles( $oVendor );
00280                     if ( $this->_iAllArtCnt ) {
00281                         $this->_aArticleList = $aArticleList;
00282                     }
00283                 }
00284             }
00285         }
00286         return $this->_aArticleList;
00287     }
00288 
00294     public function getTitle()
00295     {
00296         if ( $this->_sCatTitle === null ) {
00297             $this->_sCatTitle = '';
00298             if ( $oVendorTree = $this->getVendorTree() ) {
00299                 if ( $oVendor = $this->getActVendor() ) {
00300                     $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00301                 }
00302             }
00303         }
00304         return $this->_sCatTitle;
00305     }
00306 
00314     public function getTemplateLocation()
00315     {
00316         if ( $this->_sTplLocation === null ) {
00317             $this->_sTplLocation = false;
00318             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00319                 $this->_sTplLocation = $oVendorTree->getHtmlPath();
00320             }
00321         }
00322         return $this->_sTplLocation;
00323     }
00324 
00330     public function getTreePath()
00331     {
00332         if ( $oVendorTree = $this->getVendorTree() ) {
00333             return $oVendorTree->getPath();
00334         }
00335     }
00336 
00342     public function getActiveCategory()
00343     {
00344         if ( $this->_oActCategory === null ) {
00345             $this->_oActCategory = false;
00346             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00347                 if ( $oVendor = $this->getActVendor() ) {
00348                     $this->_oActCategory = $oVendor;
00349                 }
00350             }
00351         }
00352         return $this->_oActCategory;
00353     }
00354 
00360     public function getCatTreePath()
00361     {
00362         if ( $this->_sCatTreePath === null ) {
00363             $this->_sCatTreePath = false;
00364             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00365                 $this->_sCatTreePath  = $oVendorTree->getPath();
00366             }
00367         }
00368         return $this->_sCatTreePath;
00369     }
00370 
00376     public function getTitleSuffix()
00377     {
00378         if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00379             return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00380         }
00381     }
00382 
00392     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00393     {
00394         return parent::_collectMetaKeyword( $sKeywords );
00395     }
00396 
00407     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00408     {
00409         return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00410     }
00411 
00420     protected function _getSubject( $iLang )
00421     {
00422         return $this->getActVendor();
00423     }
00424 
00430     public function getAddUrlParams()
00431     {
00432         $sAddParams  = parent::getAddUrlParams();
00433         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00434         if ( $oVendor = $this->getActVendor() ) {
00435             $sAddParams .= "&amp;cnid=v_" . $oVendor->getId();
00436         }
00437         return $sAddParams;
00438     }
00439 }