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