OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxseoencodermanufacturer.php
Go to the documentation of this file.
1 <?php
2 
8 {
14  protected static $_instance = null;
15 
21  protected $_aRootManufacturerUri = null;
22 
30  public static function getInstance()
31  {
32  return oxRegistry::get("oxSeoEncoderManufacturer");
33  }
34 
40  protected function _getUrlExtension()
41  {
42  return '/';
43  }
44 
54  public function getManufacturerUri( $oManufacturer, $iLang = null, $blRegenerate = false )
55  {
56  if (!isset($iLang)) {
57  $iLang = $oManufacturer->getLanguage();
58  }
59  // load from db
60  if ( $blRegenerate || !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
61 
62  if ( $iLang != $oManufacturer->getLanguage() ) {
63  $sId = $oManufacturer->getId();
64  $oManufacturer = oxNew('oxmanufacturer');
65  $oManufacturer->loadInLang( $iLang, $sId );
66  }
67 
68  $sSeoUrl = '';
69  if ( $oManufacturer->getId() != 'root' ) {
70  if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
71  $oRootManufacturer = oxNew('oxmanufacturer');
72  $oRootManufacturer->loadInLang( $iLang, 'root' );
73  $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
74  }
75  $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
76  }
77 
78  $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value, false, $oManufacturer->getLanguage() ) .'/';
79  $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oManufacturer->getId(), $iLang );
80 
81  // save to db
82  $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getBaseStdLink($iLang), $sSeoUrl, $iLang );
83  }
84  return $sSeoUrl;
85  }
86 
97  public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = null )
98  {
99  if (!isset($iLang)) {
100  $iLang = $oManufacturer->getLanguage();
101  }
102  $sStdUrl = $oManufacturer->getBaseStdLink($iLang) . '&amp;pgNr=' . $iPage;
103  $sParams = $sParams = (int) ($iPage + 1);
104 
105  $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
106  $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
107 
108  if ( $blFixed === null ) {
109  $blFixed = $this->_isFixed( 'oxmanufacturers', $oManufacturer->getId(), $iLang );
110  }
111  return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
112  }
113 
122  public function getManufacturerUrl( $oManufacturer, $iLang = null )
123  {
124  if (!isset($iLang)) {
125  $iLang = $oManufacturer->getLanguage();
126  }
127  return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
128  }
129 
137  public function onDeleteManufacturer( $oManufacturer )
138  {
139  $oDb = oxDb::getDb();
140  $sIdQuoted = $oDb->quote( $oManufacturer->getId() );
141  $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxmanufacturer'");
142  $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
143  }
144 
153  protected function _getAltUri( $sObjectId, $iLang )
154  {
155  $sSeoUrl = null;
156  $oManufacturer = oxNew( "oxmanufacturer" );
157  if ( $oManufacturer->loadInLang( $iLang, $sObjectId ) ) {
158  $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang, true );
159  }
160  return $sSeoUrl;
161  }
162 }