OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxmanufacturer.php
Go to the documentation of this file.
1 <?php
2 
7 class oxManufacturer extends oxI18n implements oxIUrl
8 {
9 
10  protected static $_aRootManufacturer = array();
11 
15  protected $_sClassName = 'oxmanufacturer';
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( 'oxmanufacturers');
67  }
68 
76  public function __get( $sName )
77  {
78  switch ( $sName ) {
79  case 'oxurl':
80  case 'openlink':
81  case 'closelink':
82  case 'link':
83  $sValue = $this->getLink();
84  break;
85  case 'iArtCnt':
86  $sValue = $this->getNrOfArticles();
87  break;
88  case 'isVisible':
89  $sValue = $this->getIsVisible();
90  break;
91  case 'hasVisibleSubCats':
92  $sValue = $this->getHasVisibleSubCats();
93  break;
94  default:
95  $sValue = parent::__get( $sName );
96  break;
97  }
98  return $sValue;
99  }
100 
108  public function setShowArticleCnt( $blShowArticleCount = false )
109  {
110  $this->_blShowArticleCnt = $blShowArticleCount;
111  }
112 
120  public function assign( $dbRecord )
121  {
122  parent::assign( $dbRecord );
123 
124  // manufacturer article count is stored in cache
125  if ( $this->_blShowArticleCnt && !$this->isAdmin() ) {
126  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getManufacturerArticleCount( $this->getId() );
127  }
128 
129  $this->oxmanufacturers__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
130  }
131 
140  public function load( $sOxid )
141  {
142  if ( $sOxid == 'root' ) {
143  return $this->_setRootObjectData();
144  }
145  return parent::load( $sOxid );
146  }
147 
153  protected function _setRootObjectData()
154  {
155  $this->setId( 'root' );
156  $this->oxmanufacturers__oxicon = new oxField( '', oxField::T_RAW );
157  $this->oxmanufacturers__oxtitle = new oxField( oxRegistry::getLang()->translateString( 'BY_MANUFACTURER', $this->getLanguage(), false ), oxField::T_RAW );
158  $this->oxmanufacturers__oxshortdesc = new oxField( '', oxField::T_RAW );
159 
160  return true;
161  }
162 
171  public function getBaseSeoLink( $iLang, $iPage = 0 )
172  {
173  $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
174  if ( !$iPage ) {
175  return $oEncoder->getManufacturerUrl( $this, $iLang );
176  }
177  return $oEncoder->getManufacturerPageUrl( $this, $iPage, $iLang );
178  }
179 
187  public function getLink( $iLang = null )
188  {
189  if ( !oxRegistry::getUtils()->seoIsActive() ) {
190  return $this->getStdLink( $iLang );
191  }
192 
193  if ( $iLang === null ) {
194  $iLang = $this->getLanguage();
195  }
196 
197  if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
198  $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
199  }
200 
201  return $this->_aSeoUrls[$iLang];
202  }
203 
213  public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
214  {
215  $sUrl = '';
216  if ( $blFull ) {
217  //always returns shop url, not admin
218  $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
219  }
220 
221  return $sUrl . "index.php?cl=manufacturerlist" . ( $blAddId ? "&amp;mnid=".$this->getId() : "" );
222  }
223 
232  public function getStdLink( $iLang = null, $aParams = array() )
233  {
234  if ( $iLang === null ) {
235  $iLang = $this->getLanguage();
236  }
237 
238  return oxRegistry::get("oxUtilsUrl")->processUrl( $this->getBaseStdLink( $iLang ), true, $aParams, $iLang);
239  }
240 
246  public function getNrOfArticles()
247  {
248  if ( !$this->_blShowArticleCnt || $this->isAdmin() ) {
249  return -1;
250  }
251 
252  return $this->_iNrOfArticles;
253  }
254 
260  public function getSubCats()
261  {
262  }
263 
269  public function getIsVisible()
270  {
271  return $this->_blIsVisible;
272  }
273 
281  public function setIsVisible( $blVisible )
282  {
283  $this->_blIsVisible = $blVisible;
284  }
285 
291  public function getHasVisibleSubCats()
292  {
293  if ( !isset( $this->_blHasVisibleSubCats ) ) {
294  $this->_blHasVisibleSubCats = false;
295  }
296 
298  }
299 
307  public function setHasVisibleSubCats( $blHasVisibleSubcats )
308  {
309  $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
310  }
311 
317  public function getContentCats()
318  {
319  }
320 
328  public function delete( $sOXID = null)
329  {
330  if ( parent::delete( $sOXID ) ) {
331  oxRegistry::get("oxSeoEncoderManufacturer")->onDeleteManufacturer( $this );
332  return true;
333  }
334  return false;
335  }
336 
342  public function getIconUrl()
343  {
344  if ( ( $sIcon = $this->oxmanufacturers__oxicon->value ) ) {
345  $oConfig = $this->getConfig();
346  $sSize = $oConfig->getConfigParam( 'sManufacturerIconsize' );
347  if ( !$sSize ) {
348  $sSize = $oConfig->getConfigParam( 'sIconsize' );
349  }
350 
351  return oxRegistry::get("oxPictureHandler")->getPicUrl( "manufacturer/icon/", $sIcon, $sSize );
352  }
353  }
354 
360  public function getThumbUrl()
361  {
362  return false;
363  }
364 
370  public function getTitle()
371  {
372  return $this->oxmanufacturers__oxtitle->value;
373  }
374 
380  public function getShortDescription()
381  {
382  return $this->oxmanufacturers__oxshortdesc->value;
383  }
384 
385 
386 }