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_NOINDEXFOLLOW;
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 
00128     protected function _processListArticles()
00129     {
00130         if ( $aArtList = $this->getArticleList() ) {
00131             foreach ( $aArtList as $oArticle ) {
00132                 // forcing to generate vendor URLs by getLink
00133                 $oArticle->setLinkType( OXARTICLE_LINKTYPE_VENDOR );
00134             }
00135         }
00136     }
00137 
00147     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00148     {
00149         parent::setItemSorting( str_replace( 'v_', '', $sCnid ).':vendor', $sSortBy, $sSortDir );
00150     }
00151 
00159     public function getSorting( $sCnid )
00160     {
00161         return parent::getSorting( str_replace( 'v_', '', $sCnid ).':vendor' );
00162     }
00163 
00171     protected function _loadArticles( $oVendor )
00172     {
00173         $sVendorId = $oVendor->getId();
00174 
00175         // load only articles which we show on screen
00176         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00177         $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00178 
00179         $oArtList = oxNew( 'oxarticlelist' );
00180         $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00181         $oArtList->setCustomSorting( $this->getSortingSql( $sVendorId ) );
00182 
00183         // load the articles
00184         $iArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00185 
00186         return array( $oArtList, $iArtCnt );
00187     }
00188 
00194     protected function _getSeoObjectId()
00195     {
00196         if ( ( $oVendor = $this->getActVendor() ) ) {
00197             return $oVendor->getId();
00198         }
00199     }
00200 
00211     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00212     {
00213         if ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00214             if ( $iPage ) { // only if page number > 0
00215                 $sUrl = oxSeoEncoderVendor::getInstance()->getVendorPageUrl( $oVendor, $iPage, $iLang, $this->_isFixedUrl( $oVendor ) );
00216             }
00217         } else {
00218             $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
00219         }
00220 
00221         return $sUrl;
00222     }
00223 
00229     public function generatePageNavigationUrl( )
00230     {
00231         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00232             return $oVendor->getLink();
00233         } else {
00234             return parent::generatePageNavigationUrl( );
00235         }
00236     }
00237 
00243     public function hasVisibleSubCats()
00244     {
00245         if ( $this->_blVisibleSubCats === null ) {
00246             $this->_blVisibleSubCats = false;
00247             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00248                 if ( ( $oVendor = $this->getActVendor() ) ) {
00249                     if ( $oVendor->getId() == 'root' ) {
00250                         $this->_blVisibleSubCats = $oVendorTree->count();
00251                         $this->_oSubCatList = $oVendorTree;
00252                     }
00253                 }
00254             }
00255         }
00256         return $this->_blVisibleSubCats;
00257     }
00258 
00264     public function getSubCatList()
00265     {
00266         if ( $this->_oSubCatList === null ) {
00267             $this->_oSubCatList = array();
00268             if ( $this->hasVisibleSubCats() ) {
00269                 return $this->_oSubCatList;
00270             }
00271         }
00272         return $this->_oSubCatList;
00273     }
00274 
00280     public function getArticleList()
00281     {
00282         if ( $this->_aArticleList === null ) {
00283             $this->_aArticleList = array();
00284             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00285                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00286                     list( $aArticleList, $this->_iAllArtCnt ) = $this->_loadArticles( $oVendor );
00287                     if ( $this->_iAllArtCnt ) {
00288                         $this->_aArticleList = $aArticleList;
00289                     }
00290                 }
00291             }
00292         }
00293         return $this->_aArticleList;
00294     }
00295 
00301     public function getTitle()
00302     {
00303         if ( $this->_sCatTitle === null ) {
00304             $this->_sCatTitle = '';
00305             if ( $oVendorTree = $this->getVendorTree() ) {
00306                 if ( $oVendor = $this->getActVendor() ) {
00307                     $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00308                 }
00309             }
00310         }
00311         return $this->_sCatTitle;
00312     }
00313 
00319     public function getTemplateLocation()
00320     {
00321         if ( $this->_sTplLocation === null ) {
00322             $this->_sTplLocation = false;
00323             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00324                 $this->_sTplLocation = $oVendorTree->getHtmlPath();
00325             }
00326         }
00327         return $this->_sTplLocation;
00328     }
00329 
00335     public function getActiveCategory()
00336     {
00337         if ( $this->_oActCategory === null ) {
00338             $this->_oActCategory = false;
00339             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00340                 if ( $oVendor = $this->getActVendor() ) {
00341                     $this->_oActCategory = $oVendor;
00342                 }
00343             }
00344         }
00345         return $this->_oActCategory;
00346     }
00347 
00353     public function getCatTreePath()
00354     {
00355         if ( $this->_sCatTreePath === null ) {
00356             $this->_sCatTreePath = false;
00357             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00358                 $this->_sCatTreePath  = $oVendorTree->getPath();
00359             }
00360         }
00361         return $this->_sCatTreePath;
00362     }
00363 
00369     public function getTitleSuffix()
00370     {
00371         if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00372             return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00373         }
00374     }
00375 
00384     protected function _prepareMetaKeyword( $sKeywords )
00385     {
00386         return parent::_collectMetaKeyword( $sKeywords );
00387     }
00388 
00399     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00400     {
00401         return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00402     }
00403 }

Generated on Wed Apr 22 12:26:32 2009 for OXID eShop CE by  doxygen 1.5.5