OXID eShop CE  4.10.7
 All Classes Namespaces 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 
106  public function setShowArticleCnt($blShowArticleCount = false)
107  {
108  $this->_blShowArticleCnt = $blShowArticleCount;
109  }
110 
116  public function assign($dbRecord)
117  {
118  parent::assign($dbRecord);
119 
120  // manufacturer article count is stored in cache
121  if ($this->_blShowArticleCnt && !$this->isAdmin()) {
122  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getManufacturerArticleCount($this->getId());
123  }
124 
125  $this->oxmanufacturers__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
126  }
127 
136  public function load($sOxid)
137  {
138  if ($sOxid == 'root') {
139  return $this->_setRootObjectData();
140  }
141 
142  return parent::load($sOxid);
143  }
144 
150  protected function _setRootObjectData()
151  {
152  $this->setId('root');
153  $this->oxmanufacturers__oxicon = new oxField('', oxField::T_RAW);
154  $this->oxmanufacturers__oxtitle = new oxField(oxRegistry::getLang()->translateString('BY_MANUFACTURER', $this->getLanguage(), false), oxField::T_RAW);
155  $this->oxmanufacturers__oxshortdesc = new oxField('', oxField::T_RAW);
156 
157  return true;
158  }
159 
168  public function getBaseSeoLink($iLang, $iPage = 0)
169  {
170  $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
171  if (!$iPage) {
172  return $oEncoder->getManufacturerUrl($this, $iLang);
173  }
174 
175  return $oEncoder->getManufacturerPageUrl($this, $iPage, $iLang);
176  }
177 
185  public function getLink($iLang = null)
186  {
187  if (!oxRegistry::getUtils()->seoIsActive()) {
188  return $this->getStdLink($iLang);
189  }
190 
191  if ($iLang === null) {
192  $iLang = $this->getLanguage();
193  }
194 
195  if (!isset($this->_aSeoUrls[$iLang])) {
196  $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang);
197  }
198 
199  return $this->_aSeoUrls[$iLang];
200  }
201 
211  public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
212  {
213  $sUrl = '';
214  if ($blFull) {
215  //always returns shop url, not admin
216  $sUrl = $this->getConfig()->getShopUrl($iLang, false);
217  }
218 
219  return $sUrl . "index.php?cl=manufacturerlist" . ($blAddId ? "&amp;mnid=" . $this->getId() : "");
220  }
221 
230  public function getStdLink($iLang = null, $aParams = array())
231  {
232  if ($iLang === null) {
233  $iLang = $this->getLanguage();
234  }
235 
236  return oxRegistry::get("oxUtilsUrl")->processUrl($this->getBaseStdLink($iLang), true, $aParams, $iLang);
237  }
238 
244  public function getNrOfArticles()
245  {
246  if (!$this->_blShowArticleCnt || $this->isAdmin()) {
247  return -1;
248  }
249 
250  return $this->_iNrOfArticles;
251  }
252 
256  public function getSubCats()
257  {
258  }
259 
265  public function getIsVisible()
266  {
267  return $this->_blIsVisible;
268  }
269 
275  public function setIsVisible($blVisible)
276  {
277  $this->_blIsVisible = $blVisible;
278  }
279 
285  public function getHasVisibleSubCats()
286  {
287  if (!isset($this->_blHasVisibleSubCats)) {
288  $this->_blHasVisibleSubCats = false;
289  }
290 
292  }
293 
299  public function setHasVisibleSubCats($blHasVisibleSubcats)
300  {
301  $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
302  }
303 
307  public function getContentCats()
308  {
309  }
310 
318  public function delete($sOXID = null)
319  {
320  if (parent::delete($sOXID)) {
321  oxRegistry::get("oxSeoEncoderManufacturer")->onDeleteManufacturer($this);
322 
323  return true;
324  }
325 
326  return false;
327  }
328 
334  public function getIconUrl()
335  {
336  if (($sIcon = $this->oxmanufacturers__oxicon->value)) {
337  $oConfig = $this->getConfig();
338  $sSize = $oConfig->getConfigParam('sManufacturerIconsize');
339  if (!$sSize) {
340  $sSize = $oConfig->getConfigParam('sIconsize');
341  }
342 
343  return oxRegistry::get("oxPictureHandler")->getPicUrl("manufacturer/icon/", $sIcon, $sSize);
344  }
345  }
346 
352  public function getThumbUrl()
353  {
354  return false;
355  }
356 
362  public function getTitle()
363  {
364  return $this->oxmanufacturers__oxtitle->value;
365  }
366 
372  public function getShortDescription()
373  {
374  return $this->oxmanufacturers__oxshortdesc->value;
375  }
376 
377 }