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
00084 if ( ( $this->getVendorTree() ) ) {
00085 if ( ( $oVendor = $this->getActVendor() ) ) {
00086 if ( $oVendor->getId() != 'root' ) {
00087
00088 $this->getArticleList();
00089
00090
00091 $this->_checkRequestedPage();
00092
00093
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
00121 public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
00122 {
00123 parent::setItemSorting( str_replace( 'v_', '', $sCnid ).':vendor', $sSortBy, $sSortDir );
00124 }
00125
00133 public function getSorting( $sCnid )
00134 {
00135 return parent::getSorting( str_replace( 'v_', '', $sCnid ).':vendor' );
00136 }
00137
00145 protected function _loadArticles( $oVendor )
00146 {
00147 $sVendorId = $oVendor->getId();
00148
00149
00150 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00151 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
00152
00153 $oArtList = oxNew( 'oxarticlelist' );
00154 $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
00155 $oArtList->setCustomSorting( $this->getSortingSql( $sVendorId ) );
00156
00157
00158 $this->_iAllArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00159
00160
00161 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00162
00163 return array( $oArtList, $this->_iAllArtCnt );
00164 }
00165
00171 protected function _getSeoObjectId()
00172 {
00173 if ( ( $oVendor = $this->getActVendor() ) ) {
00174 return $oVendor->getId();
00175 }
00176 }
00177
00188 protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
00189 {
00190 if ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
00191 if ( $iPage ) {
00192
00193 $sUrl = $oVendor->getBaseSeoLink( $iLang, $iPage );
00194 }
00195 } else {
00196 $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
00197 }
00198 return $sUrl;
00199 }
00200
00206 public function generatePageNavigationUrl( )
00207 {
00208 if ( ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
00209 return $oVendor->getLink();
00210 } else {
00211 return parent::generatePageNavigationUrl( );
00212 }
00213 }
00214
00220 public function hasVisibleSubCats()
00221 {
00222 if ( $this->_blVisibleSubCats === null ) {
00223 $this->_blVisibleSubCats = false;
00224 if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00225 if ( ( $oVendor = $this->getActVendor() ) ) {
00226 if ( $oVendor->getId() == 'root' ) {
00227 $this->_blVisibleSubCats = $oVendorTree->count();
00228 $this->_oSubCatList = $oVendorTree;
00229 }
00230 }
00231 }
00232 }
00233 return $this->_blVisibleSubCats;
00234 }
00235
00241 public function getSubCatList()
00242 {
00243 if ( $this->_oSubCatList === null ) {
00244 $this->_oSubCatList = array();
00245 if ( $this->hasVisibleSubCats() ) {
00246 return $this->_oSubCatList;
00247 }
00248 }
00249 return $this->_oSubCatList;
00250 }
00251
00257 public function getArticleList()
00258 {
00259 if ( $this->_aArticleList === null ) {
00260 $this->_aArticleList = array();
00261 if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
00262 list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oVendor );
00263 if ( $iAllArtCnt ) {
00264 $this->_aArticleList = $aArticleList;
00265 }
00266 }
00267 }
00268 return $this->_aArticleList;
00269 }
00270
00276 public function getTitle()
00277 {
00278 if ( $this->_sCatTitle === null ) {
00279 $this->_sCatTitle = '';
00280 if ( $oVendor = $this->getActVendor() ) {
00281 $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
00282 }
00283 }
00284 return $this->_sCatTitle;
00285 }
00286
00292 public function getTreePath()
00293 {
00294 if ( $oVendorTree = $this->getVendorTree() ) {
00295 return $oVendorTree->getPath();
00296 }
00297 }
00298
00304 public function getActiveCategory()
00305 {
00306 if ( $this->_oActCategory === null ) {
00307 $this->_oActCategory = false;
00308 if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00309 if ( $oVendor = $this->getActVendor() ) {
00310 $this->_oActCategory = $oVendor;
00311 }
00312 }
00313 }
00314 return $this->_oActCategory;
00315 }
00316
00322 public function getCatTreePath()
00323 {
00324 if ( $this->_sCatTreePath === null ) {
00325 $this->_sCatTreePath = false;
00326 if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00327 $this->_sCatTreePath = $oVendorTree->getPath();
00328 }
00329 }
00330 return $this->_sCatTreePath;
00331 }
00332
00338 public function getTitleSuffix()
00339 {
00340 if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00341 return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00342 }
00343 }
00344
00354 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00355 {
00356 return parent::_collectMetaKeyword( $sKeywords );
00357 }
00358
00369 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00370 {
00371 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00372 }
00373
00382 protected function _getSubject( $iLang )
00383 {
00384 return $this->getActVendor();
00385 }
00386
00392 public function getAddUrlParams()
00393 {
00394 $sAddParams = parent::getAddUrlParams();
00395 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00396 if ( $oVendor = $this->getActVendor() ) {
00397 $sAddParams .= "&cnid=v_" . $oVendor->getId();
00398 }
00399 return $sAddParams;
00400 }
00401
00407 public function getBreadCrumb()
00408 {
00409 $aPaths = array();
00410 $oCatTree = $this->getVendorTree();
00411
00412 if ( $oCatTree ) {
00413 foreach ( $oCatTree->getPath() as $oCat ) {
00414 $aCatPath = array();
00415
00416 $aCatPath['link'] = $oCat->getLink();
00417 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
00418
00419 $aPaths[] = $aCatPath;
00420 }
00421 }
00422
00423 return $aPaths;
00424 }
00425
00426
00432 public function getVendorTree()
00433 {
00434 if ( $this->_oVendorTree === null) {
00435 $oVendorTree = oxNew( 'oxvendorlist' );
00436 $oVendorTree->buildVendorTree( 'vendorlist', $this->getActVendor()->getId(), $this->getConfig()->getShopHomeURL() );
00437 $this->_oVendorTree = $oVendorTree;
00438 }
00439
00440 return $this->_oVendorTree;
00441 }
00442
00450 public function setVendorTree( $oVendorTree )
00451 {
00452 $this->_oVendorTree = $oVendorTree;
00453 }
00454
00455 }