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 
00210     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00211     {
00212         if ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00213             if ( $iPage ) { // only if page number > 0
00214                 $sUrl = oxSeoEncoderVendor::getInstance()->getVendorPageUrl( $oVendor, $iPage, $iLang, $this->_isFixedUrl( $oVendor ) );
00215             }
00216         } else {
00217             $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
00218         }
00219 
00220         return $sUrl;
00221     }
00222 
00228     public function generatePageNavigationUrl( )
00229     {
00230         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00231             return $oVendor->getLink();
00232         } else {
00233             return parent::generatePageNavigationUrl( );
00234         }
00235     }
00236 
00242     public function hasVisibleSubCats()
00243     {
00244          if ( $this->_blVisibleSubCats === null ) {
00245              $this->_blVisibleSubCats = false;
00246              if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00247                 if ( ( $oVendor = $this->getActVendor() ) ) {
00248                     if ( $oVendor->getId() == 'root' ) {
00249                         $this->_blVisibleSubCats = $oVendorTree->count();
00250                         $this->_oSubCatList = $oVendorTree;
00251                     }
00252                 }
00253             }
00254         }
00255         return $this->_blVisibleSubCats;
00256     }
00257 
00263     public function getSubCatList()
00264     {
00265         if ( $this->_oSubCatList === null ) {
00266             $this->_oSubCatList = array();
00267             if ( $this->hasVisibleSubCats() ) {
00268                 return $this->_oSubCatList;
00269             }
00270         }
00271         return $this->_oSubCatList;
00272     }
00273 
00279     public function getArticleList()
00280     {
00281          if ( $this->_aArticleList === null ) {
00282              $this->_aArticleList = array();
00283              if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00284                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00285                     list( $aArticleList, $this->_iAllArtCnt ) = $this->_loadArticles( $oVendor );
00286                     if ( $this->_iAllArtCnt ) {
00287                         $this->_aArticleList = $aArticleList;
00288                     }
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 Tue Apr 21 15:45:45 2009 for OXID eShop CE by  doxygen 1.5.5