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 $_iArticleCnt = null;
00034 
00039     protected $_oRecommList = null;
00040 
00046     protected $_sTplLocation = null;
00047 
00053     protected $_sCatTitle = null;
00054 
00059     protected $_oPageNavigation = null;
00060 
00065     protected $_blShowSorting = true;
00066 
00073     protected $_iViewIndexState = 2;
00074 
00089     public function render()
00090     {
00091         oxUBase::render();
00092 
00093         $myConfig = $this->getConfig();
00094 
00095         // load vendor
00096         if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00097             if ( ( $oVendor = $this->getActVendor() ) ) {
00098                 if ( $oVendor->getId() != 'root' ) {
00099                     // load only articles which we show on screen
00100                     $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00101                     $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00102 
00103                     // load the articles
00104                     $this->_iAllArtCnt = $this->getArticleCnt();
00105                     $this->_iCntPages  = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00106 
00107                 }
00108             }
00109         }
00110         $this->_aViewData['hasVisibleSubCats'] = $this->hasVisibleSubCats();
00111         $this->_aViewData['subcatlist']        = $this->getSubCatList();
00112         $this->_aViewData['articlelist']       = $this->getArticleList();
00113         $this->_aViewData['similarrecommlist'] = $this->getRecommList();
00114 
00115         $this->_aViewData['title']             = $this->getTitle();
00116         $this->_aViewData['template_location'] = $this->getTemplateLocation();
00117         $this->_aViewData['actCategory']       = $this->getActiveCategory();
00118         $this->_aViewData['actCatpath']        = $this->getCatTreePath();
00119 
00120         $this->_aViewData['pageNavigation'] = $this->getPageNavigation();
00121 
00122         // processing list articles
00123         $this->_processListArticles();
00124 
00125         // generating meta info
00126         $this->setMetaDescription( null );
00127         $this->setMetaKeywords( null );
00128 
00129         return $this->_sThisTemplate;
00130     }
00131 
00139     protected function _processListArticles()
00140     {
00141         if ( $aArtList = $this->getArticleList() ) {
00142             foreach ( $aArtList as $oArticle ) {
00143                 // forcing to generate vendor URLs by getLink
00144                 $oArticle->setLinkType( 1 );
00145             }
00146         }
00147     }
00148 
00158     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00159     {
00160         parent::setItemSorting( str_replace( 'v_', '', $sCnid ).':vendor', $sSortBy, $sSortDir );
00161     }
00162 
00170     public function getSorting( $sCnid )
00171     {
00172         return parent::getSorting( str_replace( 'v_', '', $sCnid ).':vendor' );
00173     }
00174 
00182     protected function _loadArticles( $oVendor )
00183     {
00184         $sVendorId = $oVendor->getId();
00185 
00186         // load only articles which we show on screen
00187         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00188         $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;
00189 
00190         $oArtList = oxNew( 'oxarticlelist' );
00191         $oArtList->setSqlLimit( $iNrofCatArticles * $this->getActPage(), $iNrofCatArticles );
00192         $oArtList->setCustomSorting( $this->getSortingSql( $sVendorId ) );
00193 
00194         // load the articles
00195         $iArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00196 
00197         return array( $oArtList, $iArtCnt );
00198     }
00199 
00205     protected function _getSeoObjectId()
00206     {
00207         if ( ( $oVendor = $this->getActVendor() ) ) {
00208             return $oVendor->getId();
00209         }
00210     }
00211 
00221     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00222     {
00223         if ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00224             if ( $iPage ) { // only if page number > 0
00225                 $sUrl = oxSeoEncoderVendor::getInstance()->getVendorPageUrl( $oVendor, $iPage, $iLang, $this->_isFixedUrl( $oVendor ) );
00226             }
00227         } else {
00228             $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
00229         }
00230 
00231         return $sUrl;
00232     }
00233 
00239     public function generatePageNavigationUrl( )
00240     {
00241         if ( ( oxUtils::getInstance()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00242             return $oVendor->getLink();
00243         } else {
00244             return parent::generatePageNavigationUrl( );
00245         }
00246     }
00247 
00253     public function hasVisibleSubCats()
00254     {
00255          if ( $this->_blVisibleSubCats === null ) {
00256              $this->_blVisibleSubCats = false;
00257              if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00258                 if ( ( $oVendor = $this->getActVendor() ) ) {
00259                     if ( $oVendor->getId() == 'root' ) {
00260                         $this->_blVisibleSubCats = $oVendorTree->count();
00261                         $this->_oSubCatList = $oVendorTree;
00262                     }
00263                 }
00264             }
00265         }
00266         return $this->_blVisibleSubCats;
00267     }
00268 
00274     public function getSubCatList()
00275     {
00276         if ( $this->_oSubCatList === null ) {
00277             $this->_oSubCatList = array();
00278             if ( $this->hasVisibleSubCats() ) {
00279                 return $this->_oSubCatList;
00280             }
00281         }
00282         return $this->_oSubCatList;
00283     }
00284 
00290     public function getArticleList()
00291     {
00292          if ( $this->_aArticleList === null ) {
00293              $this->_aArticleList = array();
00294              if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00295                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00296                     list( $aArticleList, $iArticleCnt ) = $this->_loadArticles( $oVendor );
00297                     if ( $iArticleCnt ) {
00298                         $this->_aArticleList = $aArticleList;
00299                         $this->_iArticleCnt  = $iArticleCnt;
00300                     }
00301                 }
00302 
00303             }
00304         }
00305         return $this->_aArticleList;
00306     }
00307 
00313     public function getArticleCnt()
00314     {
00315          if ( $this->_iArticleCnt === null ) {
00316              $this->_iArticleCnt = 0;
00317              if ( $this->getArticleList() ) {
00318                 return $this->_iArticleCnt;
00319             }
00320         }
00321         return $this->_iArticleCnt;
00322     }
00323 
00329     public function getRecommList()
00330     {
00331         if ( $this->_oRecommList === null ) {
00332             $this->_oRecommList = false;
00333             if ( $this->getArticleCnt() ) {
00334                 // loading recommlists
00335                 $oRecommList = oxNew('oxrecommlist');
00336                 $this->_oRecommList = $oRecommList->getRecommListsByIds( $this->_aArticleList->arrayKeys());
00337             }
00338         }
00339         return $this->_oRecommList;
00340     }
00341 
00347     public function getTitle()
00348     {
00349         if ( $this->_sCatTitle === null ) {
00350             $this->_sCatTitle = '';
00351             if ( $oVendorTree = $this->getVendorTree() ) {
00352                 if ( $oVendor = $this->getActVendor() ) {
00353                     $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00354                 }
00355             }
00356         }
00357         return $this->_sCatTitle;
00358     }
00359 
00365     public function getTemplateLocation()
00366     {
00367         if ( $this->_sTplLocation === null ) {
00368             $this->_sTplLocation = false;
00369             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00370                 $this->_sTplLocation = $oVendorTree->getHtmlPath();
00371             }
00372         }
00373         return $this->_sTplLocation;
00374     }
00375 
00381     public function getActiveCategory()
00382     {
00383         if ( $this->_oActCategory === null ) {
00384             $this->_oActCategory = false;
00385             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00386                 if ( $oVendor = $this->getActVendor() ) {
00387                     $this->_oActCategory = $oVendor;
00388                 }
00389             }
00390         }
00391         return $this->_oActCategory;
00392     }
00393 
00399     public function getCatTreePath()
00400     {
00401         if ( $this->_sCatTreePath === null ) {
00402             $this->_sCatTreePath = false;
00403             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00404                 $this->_sCatTreePath  = $oVendorTree->getPath();
00405             }
00406         }
00407         return $this->_sCatTreePath;
00408     }
00409 
00415     public function getPageNavigation()
00416     {
00417         if ( $this->_oPageNavigation === null ) {
00418             $this->_oPageNavigation = false;
00419             $this->_oPageNavigation = $this->generatePageNavigation();
00420         }
00421         return $this->_oPageNavigation;
00422     }
00423 
00429     public function getTitleSuffix()
00430     {
00431         if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00432            return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00433         }
00434     }
00435 
00443     protected function _prepareMetaKeyword( $aCatPath )
00444     {
00445         return parent::_collectMetaKeyword( $aCatPath );
00446     }
00447 
00460     protected function _prepareMetaDescription( $aCatPath, $iLength = 1024, $blDescTag = false )
00461     {
00462         return parent::_collectMetaDescription( $aCatPath, $iLength, $blDescTag );
00463     }
00464 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5