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->_getVendorId() && $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
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
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
00162 $this->_iAllArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
00163
00164
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
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 ( ($this->_getVendorId() && $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 ( $this->_getVendorId() && $oVendorTree = $this->getVendorTree() ) {
00299 return $oVendorTree->getPath();
00300 }
00301 }
00302
00303 protected function _getVendorId()
00304 {
00305 return oxRegistry::getConfig()->getRequestParameter( 'cnid' );
00306 }
00307
00313 public function getActiveCategory()
00314 {
00315 if ( $this->_oActCategory === null ) {
00316 $this->_oActCategory = false;
00317 if ( ( $this->_getVendorId() && $oVendorTree = $this->getVendorTree() ) ) {
00318 if ( $oVendor = $this->getActVendor() ) {
00319 $this->_oActCategory = $oVendor;
00320 }
00321 }
00322 }
00323 return $this->_oActCategory;
00324 }
00325
00331 public function getCatTreePath()
00332 {
00333 if ( $this->_sCatTreePath === null ) {
00334 $this->_sCatTreePath = false;
00335 if ( ( $oVendorTree = $this->getVendorTree() ) ) {
00336 $this->_sCatTreePath = $oVendorTree->getPath();
00337 }
00338 }
00339 return $this->_sCatTreePath;
00340 }
00341
00347 public function getTitleSuffix()
00348 {
00349 if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
00350 return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
00351 }
00352 }
00353
00363 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00364 {
00365 return parent::_collectMetaKeyword( $sKeywords );
00366 }
00367
00378 protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
00379 {
00380 return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
00381 }
00382
00391 protected function _getSubject( $iLang )
00392 {
00393 return $this->getActVendor();
00394 }
00395
00401 public function getAddUrlParams()
00402 {
00403 $sAddParams = parent::getAddUrlParams();
00404 $sAddParams .= ($sAddParams?'&':'') . "listtype={$this->_sListType}";
00405 if ( $oVendor = $this->getActVendor() ) {
00406 $sAddParams .= "&cnid=v_" . $oVendor->getId();
00407 }
00408 return $sAddParams;
00409 }
00410
00416 public function getBreadCrumb()
00417 {
00418 $aPaths = array();
00419 $oCatTree = $this->getVendorTree();
00420
00421 if ( $oCatTree ) {
00422 foreach ( $oCatTree->getPath() as $oCat ) {
00423 $aCatPath = array();
00424
00425 $aCatPath['link'] = $oCat->getLink();
00426 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
00427
00428 $aPaths[] = $aCatPath;
00429 }
00430 }
00431
00432 return $aPaths;
00433 }
00434
00435
00441 public function getVendorTree()
00442 {
00443 if ( $this->_getVendorId() && $this->_oVendorTree === null) {
00444 $oVendorTree = oxNew( 'oxVendorList' );
00445 $oVendorTree->buildVendorTree( 'vendorlist', $this->getActVendor()->getId(), $this->getConfig()->getShopHomeURL() );
00446 $this->_oVendorTree = $oVendorTree;
00447 }
00448
00449 return $this->_oVendorTree;
00450 }
00451
00459 public function setVendorTree( $oVendorTree )
00460 {
00461 $this->_oVendorTree = $oVendorTree;
00462 }
00463
00470 public function getAttributes()
00471 {
00472 return null;
00473 }
00474
00475 }