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