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 
00034     protected $_sTplLocation = null;
00035 
00041     protected $_sCatTitle = null;
00042 
00047     protected $_oPageNavigation = null;
00048 
00053     protected $_blShowSorting = true;
00054 
00060     protected $_iViewIndexState = VIEW_INDEXSTATE_INDEX;
00061 
00067     protected $_oVendorTree  = null;
00068 
00079     public function render()
00080     {
00081         oxUBase::render();
00082 
00083         // load vendor
00084         if ( ( $this->getVendorTree() ) ) {
00085             if ( ( $oVendor = $this->getActVendor() ) ) {
00086                 if ( $oVendor->getId() != 'root' ) {
00087                     // load the articles
00088                     $this->getArticleList();
00089 
00090                     // checking if requested page is correct
00091                     $this->_checkRequestedPage();
00092 
00093                     // processing list articles
00094                     $this->_processListArticles();
00095                 }
00096             }
00097         }
00098 
00099         return $this->_sThisTemplate;
00100     }
00101 
00107     protected function _getProductLinkType()
00108     {
00109         return OXARTICLE_LINKTYPE_VENDOR;
00110     }
00111 
00123     public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00124     {
00125         parent::setItemSorting( $sCnid, $sSortBy, $sSortDir );
00126     }
00127 
00137     public function getSorting( $sCnid )
00138     {
00139         return parent::getSorting( $sCnid );
00140     }
00141 
00149     protected function _loadArticles( $oVendor )
00150     {
00151         $sVendorId = $oVendor->getId();
00152 
00153         // load only articles which we show on screen
00154         $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00155         $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00156 
00157         $oArtList = oxNew( 'oxarticlelist' );
00158         $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00159         $oArtList->setCustomSorting( $this->getSortingSql( $this->getSortIdent() ) );
00160 
00161         // load the articles
00162         $this->_iAllArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00163 
00164         // counting pages
00165         $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00166 
00167         return array( $oArtList, $this->_iAllArtCnt );
00168     }
00169 
00175     protected function _getSeoObjectId()
00176     {
00177         if ( ( $oVendor = $this->getActVendor() ) ) {
00178             return $oVendor->getId();
00179         }
00180     }
00181 
00192     protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00193     {
00194         if ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00195             if ( $iPage ) {
00196                 // only if page number > 0
00197                 $sUrl = $oVendor->getBaseSeoLink( $iLang, $iPage );
00198             }
00199         } else {
00200             $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00201         }
00202         return $sUrl;
00203     }
00204 
00210     public function generatePageNavigationUrl( )
00211     {
00212         if ( ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00213             return $oVendor->getLink();
00214         } else {
00215             return parent::generatePageNavigationUrl( );
00216         }
00217     }
00218 
00224     public function hasVisibleSubCats()
00225     {
00226         if ( $this->_blVisibleSubCats === null ) {
00227             $this->_blVisibleSubCats = false;
00228             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00229                 if ( ( $oVendor = $this->getActVendor() ) ) {
00230                     if ( $oVendor->getId() == 'root' ) {
00231                         $this->_blVisibleSubCats = $oVendorTree->count();
00232                         $this->_oSubCatList = $oVendorTree;
00233                     }
00234                 }
00235             }
00236         }
00237         return $this->_blVisibleSubCats;
00238     }
00239 
00245     public function getSubCatList()
00246     {
00247         if ( $this->_oSubCatList === null ) {
00248             $this->_oSubCatList = array();
00249             if ( $this->hasVisibleSubCats() ) {
00250                 return $this->_oSubCatList;
00251             }
00252         }
00253         return $this->_oSubCatList;
00254     }
00255 
00261     public function getArticleList()
00262     {
00263         if ( $this->_aArticleList === null ) {
00264             $this->_aArticleList = array();
00265                 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00266                     list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oVendor );
00267                     if ( $iAllArtCnt ) {
00268                         $this->_aArticleList = $aArticleList;
00269                     }
00270                 }
00271         }
00272         return $this->_aArticleList;
00273     }
00274 
00280     public function getTitle()
00281     {
00282         if ( $this->_sCatTitle === null ) {
00283             $this->_sCatTitle = '';
00284                 if ( $oVendor = $this->getActVendor() ) {
00285                     $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00286                 }
00287         }
00288         return $this->_sCatTitle;
00289     }
00290 
00296     public function getTreePath()
00297     {
00298         if ( $oVendorTree = $this->getVendorTree() ) {
00299             return $oVendorTree->getPath();
00300         }
00301     }
00302 
00308     public function getActiveCategory()
00309     {
00310         if ( $this->_oActCategory === null ) {
00311             $this->_oActCategory = false;
00312             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00313                 if ( $oVendor = $this->getActVendor() ) {
00314                     $this->_oActCategory = $oVendor;
00315                 }
00316             }
00317         }
00318         return $this->_oActCategory;
00319     }
00320 
00326     public function getCatTreePath()
00327     {
00328         if ( $this->_sCatTreePath === null ) {
00329             $this->_sCatTreePath = false;
00330             if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00331                 $this->_sCatTreePath  = $oVendorTree->getPath();
00332             }
00333         }
00334         return $this->_sCatTreePath;
00335     }
00336 
00342     public function getTitleSuffix()
00343     {
00344         if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00345             return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00346         }
00347     }
00348 
00358     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00359     {
00360         return parent::_collectMetaKeyword( $sKeywords );
00361     }
00362 
00373     protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00374     {
00375         return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00376     }
00377 
00386     protected function _getSubject( $iLang )
00387     {
00388         return $this->getActVendor();
00389     }
00390 
00396     public function getAddUrlParams()
00397     {
00398         $sAddParams  = parent::getAddUrlParams();
00399         $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
00400         if ( $oVendor = $this->getActVendor() ) {
00401             $sAddParams .= "&amp;cnid=v_" . $oVendor->getId();
00402         }
00403         return $sAddParams;
00404     }
00405 
00411     public function getBreadCrumb()
00412     {
00413         $aPaths = array();
00414         $oCatTree = $this->getVendorTree();
00415 
00416         if ( $oCatTree ) {
00417             foreach ( $oCatTree->getPath() 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 
00430 
00436     public function getVendorTree()
00437     {
00438         if ( $this->_oVendorTree === null) {
00439             $oVendorTree = oxNew( 'oxvendorlist' );
00440             $oVendorTree->buildVendorTree( 'vendorlist', $this->getActVendor()->getId(), $this->getConfig()->getShopHomeURL() );
00441             $this->_oVendorTree = $oVendorTree;
00442         }
00443 
00444         return $this->_oVendorTree;
00445     }
00446 
00454     public function setVendorTree( $oVendorTree )
00455     {
00456         $this->_oVendorTree = $oVendorTree;
00457     }
00458 
00465     public function getAttributes()
00466     {
00467         return null;
00468     }
00469 
00470 }