OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxvendor.php
Go to the documentation of this file.
1 <?php
2 
7 class oxVendor extends oxI18n implements oxIUrl
8 {
9 
10  protected static $_aRootVendor = array();
11 
15  protected $_sClassName = 'oxvendor';
16 
22  protected $_blShowArticleCnt = false;
23 
29  protected $_iNrOfArticles = -1;
30 
36  protected $_blIsSeoObject = true;
37 
43  protected $_blIsVisible;
44 
51 
57  protected $_aSeoUrls = array();
58 
62  public function __construct()
63  {
64  $this->setShowArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
66  $this->init( 'oxvendor');
67  }
68 
76  public function setShowArticleCnt( $blShowArticleCount = false )
77  {
78  $this->_blShowArticleCnt = $blShowArticleCount;
79  }
80 
88  public function assign( $dbRecord )
89  {
90  parent::assign( $dbRecord );
91 
92  // vendor article count is stored in cache
93  if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
94  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getVendorArticleCount( $this->getId() );
95  }
96 
97  $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
98  }
99 
108  public function load( $sOxid )
109  {
110  if ( $sOxid == 'root' ) {
111  return $this->_setRootObjectData();
112  }
113  return parent::load( $sOxid );
114  }
115 
121  protected function _setRootObjectData()
122  {
123  $this->setId( 'root' );
124  $this->oxvendor__oxicon = new oxField( '', oxField::T_RAW );
125  $this->oxvendor__oxtitle = new oxField( oxRegistry::getLang()->translateString( 'BY_VENDOR', $this->getLanguage(), false ), oxField::T_RAW );
126  $this->oxvendor__oxshortdesc = new oxField( '', oxField::T_RAW );
127 
128  return true;
129  }
130 
139  public function getBaseSeoLink( $iLang, $iPage = 0 )
140  {
141  $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
142  if ( !$iPage ) {
143  return $oEncoder->getVendorUrl( $this, $iLang );
144  }
145  return $oEncoder->getVendorPageUrl( $this, $iPage, $iLang );
146  }
147 
155  public function getLink( $iLang = null )
156  {
157  if ( !oxRegistry::getUtils()->seoIsActive() ) {
158  return $this->getStdLink( $iLang );
159  }
160 
161  if ( $iLang === null ) {
162  $iLang = $this->getLanguage();
163  }
164 
165  if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
166  $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
167  }
168 
169  return $this->_aSeoUrls[$iLang];
170  }
171 
181  public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
182  {
183  $sUrl = '';
184  if ( $blFull ) {
185  //always returns shop url, not admin
186  $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
187  }
188 
189  return $sUrl . "index.php?cl=vendorlist" . ( $blAddId ? "&amp;cnid=v_".$this->getId() : "" );
190  }
191 
200  public function getStdLink( $iLang = null, $aParams = array() )
201  {
202  if ( $iLang === null ) {
203  $iLang = $this->getLanguage();
204  }
205 
206  return oxRegistry::get("oxUtilsUrl")->processUrl( $this->getBaseStdLink( $iLang ), true, $aParams, $iLang);
207  }
208 
214  public function getNrOfArticles()
215  {
216  if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
217  return -1;
218  }
219 
220  return $this->_iNrOfArticles;
221  }
222 
228  public function getSubCats()
229  {
230  }
231 
237  public function getIsVisible()
238  {
239  return $this->_blIsVisible;
240  }
241 
249  public function setIsVisible( $blVisible )
250  {
251  $this->_blIsVisible = $blVisible;
252  }
253 
259  public function getHasVisibleSubCats()
260  {
261  if ( !isset( $this->_blHasVisibleSubCats ) ) {
262  $this->_blHasVisibleSubCats = false;
263  }
264 
266  }
267 
275  public function setHasVisibleSubCats( $blHasVisibleSubcats )
276  {
277  $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
278  }
279 
285  public function getContentCats()
286  {
287  }
288 
296  public function delete( $sOXID = null)
297  {
298  if ( parent::delete( $sOXID ) ) {
299  oxRegistry::get("oxSeoEncoderVendor")->onDeleteVendor( $this );
300  return true;
301  }
302  return false;
303  }
304 
305 
311  public function getIconUrl()
312  {
313  if ( ( $sIcon = $this->oxvendor__oxicon->value ) ) {
314  $oConfig = $this->getConfig();
315  $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
316  if ( !isset( $sSize ) ) {
317  $sSize = $oConfig->getConfigParam( 'sIconsize' );
318  }
319 
320  return oxRegistry::get("oxPictureHandler")->getPicUrl( "vendor/icon/", $sIcon, $sSize );
321  }
322  }
323 
329  public function getThumbUrl()
330  {
331  return false;
332  }
333 
339  public function getTitle()
340  {
341  return $this->oxvendor__oxtitle->value;
342  }
343 
349  public function getShortDescription()
350  {
351  return $this->oxvendor__oxshortdesc->value;
352  }
353 
354 
355 }