OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
vendorlist.php
Go to the documentation of this file.
1 <?php
2 
9 class VendorList extends aList
10 {
15  protected $_sListType = 'vendor';
16 
21  protected $_blVisibleSubCats = null;
22 
27  protected $_oSubCatList = null;
28 
34  protected $_sTplLocation = null;
35 
41  protected $_sCatTitle = null;
42 
47  protected $_oPageNavigation = null;
48 
53  protected $_blShowSorting = true;
54 
61 
67  protected $_oVendorTree = null;
68 
79  public function render()
80  {
82 
83  // load vendor
84  if ( ( $this->_getVendorId() && $this->getVendorTree() ) ) {
85  if ( ( $oVendor = $this->getActVendor() ) ) {
86  if ( $oVendor->getId() != 'root' ) {
87  // load the articles
88  $this->getArticleList();
89 
90  // checking if requested page is correct
91  $this->_checkRequestedPage();
92 
93  // processing list articles
94  $this->_processListArticles();
95  }
96  }
97  }
98 
99  return $this->_sThisTemplate;
100  }
101 
107  protected function _getProductLinkType()
108  {
110  }
111 
123  public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
124  {
125  parent::setItemSorting( $sCnid, $sSortBy, $sSortDir );
126  }
127 
137  public function getSorting( $sCnid )
138  {
139  return parent::getSorting( $sCnid );
140  }
141 
149  protected function _loadArticles( $oVendor )
150  {
151  $sVendorId = $oVendor->getId();
152 
153  // load only articles which we show on screen
154  $iNrOfCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
155  $iNrOfCatArticles = $iNrOfCatArticles ? $iNrOfCatArticles : 1;
156 
157  $oArtList = oxNew( 'oxArticleList' );
158  $oArtList->setSqlLimit( $iNrOfCatArticles * $this->_getRequestPageNr(), $iNrOfCatArticles );
159  $oArtList->setCustomSorting( $this->getSortingSql( $this->getSortIdent() ) );
160 
161  // load the articles
162  $this->_iAllArtCnt = $oArtList->loadVendorArticles( $sVendorId, $oVendor );
163 
164  // counting pages
165  $this->_iCntPages = round( $this->_iAllArtCnt / $iNrOfCatArticles + 0.49 );
166 
167  return array( $oArtList, $this->_iAllArtCnt );
168  }
169 
175  protected function _getSeoObjectId()
176  {
177  if ( ( $oVendor = $this->getActVendor() ) ) {
178  return $oVendor->getId();
179  }
180  }
181 
192  protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
193  {
194  if ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) {
195  if ( $iPage ) {
196  // only if page number > 0
197  $sUrl = $oVendor->getBaseSeoLink( $iLang, $iPage );
198  }
199  } else {
200  $sUrl = oxUBase::_addPageNrParam( $sUrl, $iPage, $iLang );
201  }
202  return $sUrl;
203  }
204 
210  public function generatePageNavigationUrl( )
211  {
212  if ( ( oxRegistry::getUtils()->seoIsActive() && ( $oVendor = $this->getActVendor() ) ) ) {
213  return $oVendor->getLink();
214  } else {
216  }
217  }
218 
224  public function hasVisibleSubCats()
225  {
226  if ( $this->_blVisibleSubCats === null ) {
227  $this->_blVisibleSubCats = false;
228  if ( ($this->_getVendorId() && $oVendorTree = $this->getVendorTree() ) ) {
229  if ( ( $oVendor = $this->getActVendor() ) ) {
230  if ( $oVendor->getId() == 'root' ) {
231  $this->_blVisibleSubCats = $oVendorTree->count();
232  $this->_oSubCatList = $oVendorTree;
233  }
234  }
235  }
236  }
238  }
239 
245  public function getSubCatList()
246  {
247  if ( $this->_oSubCatList === null ) {
248  $this->_oSubCatList = array();
249  if ( $this->hasVisibleSubCats() ) {
250  return $this->_oSubCatList;
251  }
252  }
253  return $this->_oSubCatList;
254  }
255 
261  public function getArticleList()
262  {
263  if ( $this->_aArticleList === null ) {
264  $this->_aArticleList = array();
265  if ( ( $oVendor = $this->getActVendor() ) && ( $oVendor->getId() != 'root' ) ) {
266  list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oVendor );
267  if ( $iAllArtCnt ) {
268  $this->_aArticleList = $aArticleList;
269  }
270  }
271  }
272  return $this->_aArticleList;
273  }
274 
280  public function getTitle()
281  {
282  if ( $this->_sCatTitle === null ) {
283  $this->_sCatTitle = '';
284  if ( $oVendor = $this->getActVendor() ) {
285  $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
286  }
287  }
288  return $this->_sCatTitle;
289  }
290 
296  public function getTreePath()
297  {
298  if ( $this->_getVendorId() && $oVendorTree = $this->getVendorTree() ) {
299  return $oVendorTree->getPath();
300  }
301  }
302 
303  protected function _getVendorId()
304  {
305  return oxRegistry::getConfig()->getRequestParameter( 'cnid' );
306  }
307 
313  public function getActiveCategory()
314  {
315  if ( $this->_oActCategory === null ) {
316  $this->_oActCategory = false;
317  if ( ( $this->_getVendorId() && $oVendorTree = $this->getVendorTree() ) ) {
318  if ( $oVendor = $this->getActVendor() ) {
319  $this->_oActCategory = $oVendor;
320  }
321  }
322  }
323  return $this->_oActCategory;
324  }
325 
331  public function getCatTreePath()
332  {
333  if ( $this->_sCatTreePath === null ) {
334  $this->_sCatTreePath = false;
335  if ( ( $oVendorTree = $this->getVendorTree() ) ) {
336  $this->_sCatTreePath = $oVendorTree->getPath();
337  }
338  }
339  return $this->_sCatTreePath;
340  }
341 
347  public function getTitleSuffix()
348  {
349  if ( $this->getActVendor()->oxvendor__oxshowsuffix->value ) {
350  return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
351  }
352  }
353 
363  protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
364  {
365  return parent::_collectMetaKeyword( $sKeywords );
366  }
367 
378  protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blDescTag = false )
379  {
380  return parent::_collectMetaDescription( $sMeta, $iLength, $blDescTag );
381  }
382 
391  protected function _getSubject( $iLang )
392  {
393  return $this->getActVendor();
394  }
395 
401  public function getAddUrlParams()
402  {
403  $sAddParams = parent::getAddUrlParams();
404  $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
405  if ( $oVendor = $this->getActVendor() ) {
406  $sAddParams .= "&amp;cnid=v_" . $oVendor->getId();
407  }
408  return $sAddParams;
409  }
410 
416  public function getBreadCrumb()
417  {
418  $aPaths = array();
419  $oCatTree = $this->getVendorTree();
420 
421  if ( $oCatTree ) {
422  foreach ( $oCatTree->getPath() as $oCat ) {
423  $aCatPath = array();
424 
425  $aCatPath['link'] = $oCat->getLink();
426  $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
427 
428  $aPaths[] = $aCatPath;
429  }
430  }
431 
432  return $aPaths;
433  }
434 
435 
441  public function getVendorTree()
442  {
443  if ( $this->_getVendorId() && $this->_oVendorTree === null) {
444  $oVendorTree = oxNew( 'oxVendorList' );
445  $oVendorTree->buildVendorTree( 'vendorlist', $this->getActVendor()->getId(), $this->getConfig()->getShopHomeURL() );
446  $this->_oVendorTree = $oVendorTree;
447  }
448 
449  return $this->_oVendorTree;
450  }
451 
459  public function setVendorTree( $oVendorTree )
460  {
461  $this->_oVendorTree = $oVendorTree;
462  }
463 
470  public function getAttributes()
471  {
472  return null;
473  }
474 
475 }