OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
oxseoencodervendor.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
15  protected $_aRootVendorUri = null;
16 
22  protected function _getUrlExtension()
23  {
24  return '/';
25  }
26 
36  public function getVendorUri($oVendor, $iLang = null, $blRegenerate = false)
37  {
38  if (!isset($iLang)) {
39  $iLang = $oVendor->getLanguage();
40  }
41  // load from db
42  if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxvendor', $oVendor->getId(), $iLang))) {
43 
44  if ($iLang != $oVendor->getLanguage()) {
45  $sId = $oVendor->getId();
46  $oVendor = oxNew('oxvendor');
47  $oVendor->loadInLang($iLang, $sId);
48  }
49 
50  $sSeoUrl = '';
51  if ($oVendor->getId() != 'root') {
52  if (!isset($this->_aRootVendorUri[$iLang])) {
53  $oRootVendor = oxNew('oxvendor');
54  $oRootVendor->loadInLang($iLang, 'root');
55  $this->_aRootVendorUri[$iLang] = $this->getVendorUri($oRootVendor, $iLang);
56  }
57  $sSeoUrl .= $this->_aRootVendorUri[$iLang];
58  }
59 
60  $sSeoUrl .= $this->_prepareTitle($oVendor->oxvendor__oxtitle->value, false, $oVendor->getLanguage()) . '/';
61  $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oVendor->getId(), $iLang);
62 
63  // save to db
64  $this->_saveToDb('oxvendor', $oVendor->getId(), $oVendor->getBaseStdLink($iLang), $sSeoUrl, $iLang);
65  }
66 
67  return $sSeoUrl;
68  }
69 
80  public function getVendorPageUrl($oVendor, $iPage, $iLang = null, $blFixed = null)
81  {
82  if (!isset($iLang)) {
83  $iLang = $oVendor->getLanguage();
84  }
85  $sStdUrl = $oVendor->getBaseStdLink($iLang) . '&amp;pgNr=' . $iPage;
86  $sParams = (int) ($iPage + 1);
87 
88  $sStdUrl = $this->_trimUrl($sStdUrl, $iLang);
89  $sSeoUrl = $this->getVendorUri($oVendor, $iLang) . $sParams . "/";
90 
91  if ($blFixed === null) {
92  $blFixed = $this->_isFixed('oxvendor', $oVendor->getId(), $iLang);
93  }
94 
95  return $this->_getFullUrl($this->_getPageUri($oVendor, 'oxvendor', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed), $iLang);
96  }
97 
106  public function getVendorUrl($oVendor, $iLang = null)
107  {
108  if (!isset($iLang)) {
109  $iLang = $oVendor->getLanguage();
110  }
111 
112  return $this->_getFullUrl($this->getVendorUri($oVendor, $iLang), $iLang);
113  }
114 
120  public function onDeleteVendor($oVendor)
121  {
122  $oDb = oxDb::getDb();
123  $sIdQuoted = $oDb->quote($oVendor->getId());
124  $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxvendor'");
125  $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
126  }
127 
136  protected function _getAltUri($sObjectId, $iLang)
137  {
138  $sSeoUrl = null;
139  $oVendor = oxNew("oxvendor");
140  if ($oVendor->loadInLang($iLang, $sObjectId)) {
141  $sSeoUrl = $this->getVendorUri($oVendor, $iLang, true);
142  }
143 
144  return $sSeoUrl;
145  }
146 }