OXID eShop CE  4.9.9
 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 
74  public function setShowArticleCnt($blShowArticleCount = false)
75  {
76  $this->_blShowArticleCnt = $blShowArticleCount;
77  }
78 
84  public function assign($dbRecord)
85  {
86  parent::assign($dbRecord);
87 
88  // vendor article count is stored in cache
89  if ($this->_blShowArticleCnt && !$this->isAdmin()) {
90  $this->_iNrOfArticles = oxRegistry::get("oxUtilsCount")->getVendorArticleCount($this->getId());
91  }
92 
93  $this->oxvendor__oxnrofarticles = new oxField($this->_iNrOfArticles, oxField::T_RAW);
94  }
95 
104  public function load($sOxid)
105  {
106  if ($sOxid == 'root') {
107  return $this->_setRootObjectData();
108  }
109 
110  return parent::load($sOxid);
111  }
112 
118  protected function _setRootObjectData()
119  {
120  $this->setId('root');
121  $this->oxvendor__oxicon = new oxField('', oxField::T_RAW);
122  $this->oxvendor__oxtitle = new oxField(oxRegistry::getLang()->translateString('BY_VENDOR', $this->getLanguage(), false), oxField::T_RAW);
123  $this->oxvendor__oxshortdesc = new oxField('', oxField::T_RAW);
124 
125  return true;
126  }
127 
136  public function getBaseSeoLink($iLang, $iPage = 0)
137  {
138  $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
139  if (!$iPage) {
140  return $oEncoder->getVendorUrl($this, $iLang);
141  }
142 
143  return $oEncoder->getVendorPageUrl($this, $iPage, $iLang);
144  }
145 
153  public function getLink($iLang = null)
154  {
155  if (!oxRegistry::getUtils()->seoIsActive()) {
156  return $this->getStdLink($iLang);
157  }
158 
159  if ($iLang === null) {
160  $iLang = $this->getLanguage();
161  }
162 
163  if (!isset($this->_aSeoUrls[$iLang])) {
164  $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink($iLang);
165  }
166 
167  return $this->_aSeoUrls[$iLang];
168  }
169 
179  public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
180  {
181  $sUrl = '';
182  if ($blFull) {
183  //always returns shop url, not admin
184  $sUrl = $this->getConfig()->getShopUrl($iLang, false);
185  }
186 
187  return $sUrl . "index.php?cl=vendorlist" . ($blAddId ? "&amp;cnid=v_" . $this->getId() : "");
188  }
189 
198  public function getStdLink($iLang = null, $aParams = array())
199  {
200  if ($iLang === null) {
201  $iLang = $this->getLanguage();
202  }
203 
204  return oxRegistry::get("oxUtilsUrl")->processUrl($this->getBaseStdLink($iLang), true, $aParams, $iLang);
205  }
206 
212  public function getNrOfArticles()
213  {
214  if (!$this->_blShowArticleCnt || $this->isAdmin()) {
215  return -1;
216  }
217 
218  return $this->_iNrOfArticles;
219  }
220 
224  public function getSubCats()
225  {
226  }
227 
233  public function getIsVisible()
234  {
235  return $this->_blIsVisible;
236  }
237 
243  public function setIsVisible($blVisible)
244  {
245  $this->_blIsVisible = $blVisible;
246  }
247 
253  public function getHasVisibleSubCats()
254  {
255  if (!isset($this->_blHasVisibleSubCats)) {
256  $this->_blHasVisibleSubCats = false;
257  }
258 
260  }
261 
267  public function setHasVisibleSubCats($blHasVisibleSubcats)
268  {
269  $this->_blHasVisibleSubCats = $blHasVisibleSubcats;
270  }
271 
275  public function getContentCats()
276  {
277  }
278 
286  public function delete($sOXID = null)
287  {
288  if (parent::delete($sOXID)) {
289  oxRegistry::get("oxSeoEncoderVendor")->onDeleteVendor($this);
290 
291  return true;
292  }
293 
294  return false;
295  }
296 
297 
303  public function getIconUrl()
304  {
305  if (($sIcon = $this->oxvendor__oxicon->value)) {
306  $oConfig = $this->getConfig();
307  $sSize = $oConfig->getConfigParam('sManufacturerIconsize');
308  if (!isset($sSize)) {
309  $sSize = $oConfig->getConfigParam('sIconsize');
310  }
311 
312  return oxRegistry::get("oxPictureHandler")->getPicUrl("vendor/icon/", $sIcon, $sSize);
313  }
314  }
315 
321  public function getThumbUrl()
322  {
323  return false;
324  }
325 
331  public function getTitle()
332  {
333  return $this->oxvendor__oxtitle->value;
334  }
335 
341  public function getShortDescription()
342  {
343  return $this->oxvendor__oxshortdesc->value;
344  }
345 
346 }