00001 <?php 00002 00007 class oxSeoEncoderVendor extends oxSeoEncoder 00008 { 00009 00015 protected $_aRootVendorUri = null; 00016 00022 protected function _getUrlExtension() 00023 { 00024 return '/'; 00025 } 00026 00036 public function getVendorUri($oVendor, $iLang = null, $blRegenerate = false) 00037 { 00038 if (!isset($iLang)) { 00039 $iLang = $oVendor->getLanguage(); 00040 } 00041 // load from db 00042 if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxvendor', $oVendor->getId(), $iLang))) { 00043 00044 if ($iLang != $oVendor->getLanguage()) { 00045 $sId = $oVendor->getId(); 00046 $oVendor = oxNew('oxvendor'); 00047 $oVendor->loadInLang($iLang, $sId); 00048 } 00049 00050 $sSeoUrl = ''; 00051 if ($oVendor->getId() != 'root') { 00052 if (!isset($this->_aRootVendorUri[$iLang])) { 00053 $oRootVendor = oxNew('oxvendor'); 00054 $oRootVendor->loadInLang($iLang, 'root'); 00055 $this->_aRootVendorUri[$iLang] = $this->getVendorUri($oRootVendor, $iLang); 00056 } 00057 $sSeoUrl .= $this->_aRootVendorUri[$iLang]; 00058 } 00059 00060 $sSeoUrl .= $this->_prepareTitle($oVendor->oxvendor__oxtitle->value, false, $oVendor->getLanguage()) . '/'; 00061 $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oVendor->getId(), $iLang); 00062 00063 // save to db 00064 $this->_saveToDb('oxvendor', $oVendor->getId(), $oVendor->getBaseStdLink($iLang), $sSeoUrl, $iLang); 00065 } 00066 00067 return $sSeoUrl; 00068 } 00069 00080 public function getVendorPageUrl($oVendor, $iPage, $iLang = null, $blFixed = null) 00081 { 00082 if (!isset($iLang)) { 00083 $iLang = $oVendor->getLanguage(); 00084 } 00085 $sStdUrl = $oVendor->getBaseStdLink($iLang) . '&pgNr=' . $iPage; 00086 $sParams = (int) ($iPage + 1); 00087 00088 $sStdUrl = $this->_trimUrl($sStdUrl, $iLang); 00089 $sSeoUrl = $this->getVendorUri($oVendor, $iLang) . $sParams . "/"; 00090 00091 if ($blFixed === null) { 00092 $blFixed = $this->_isFixed('oxvendor', $oVendor->getId(), $iLang); 00093 } 00094 00095 return $this->_getFullUrl($this->_getPageUri($oVendor, 'oxvendor', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed), $iLang); 00096 } 00097 00106 public function getVendorUrl($oVendor, $iLang = null) 00107 { 00108 if (!isset($iLang)) { 00109 $iLang = $oVendor->getLanguage(); 00110 } 00111 00112 return $this->_getFullUrl($this->getVendorUri($oVendor, $iLang), $iLang); 00113 } 00114 00120 public function onDeleteVendor($oVendor) 00121 { 00122 $oDb = oxDb::getDb(); 00123 $sIdQuoted = $oDb->quote($oVendor->getId()); 00124 $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxvendor'"); 00125 $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted"); 00126 } 00127 00136 protected function _getAltUri($sObjectId, $iLang) 00137 { 00138 $sSeoUrl = null; 00139 $oVendor = oxNew("oxvendor"); 00140 if ($oVendor->loadInLang($iLang, $sObjectId)) { 00141 $sSeoUrl = $this->getVendorUri($oVendor, $iLang, true); 00142 } 00143 00144 return $sSeoUrl; 00145 } 00146 }
1.7.1