Go to the documentation of this file.00001 <?php
00002
00007 class oxSeoEncoderVendor extends oxSeoEncoder
00008 {
00014 protected static $_instance = null;
00015
00021 protected $_aRootVendorUri = null;
00022
00030 public static function getInstance()
00031 {
00032 return oxRegistry::get("oxSeoEncoderVendor");
00033 }
00034
00040 protected function _getUrlExtension()
00041 {
00042 return '/';
00043 }
00044
00054 public function getVendorUri( $oVendor, $iLang = null, $blRegenerate = false )
00055 {
00056 if (!isset($iLang)) {
00057 $iLang = $oVendor->getLanguage();
00058 }
00059
00060 if ( $blRegenerate || !( $sSeoUrl = $this->_loadFromDb( 'oxvendor', $oVendor->getId(), $iLang ) ) ) {
00061
00062 if ($iLang != $oVendor->getLanguage()) {
00063 $sId = $oVendor->getId();
00064 $oVendor = oxNew('oxvendor');
00065 $oVendor->loadInLang( $iLang, $sId );
00066 }
00067
00068 $sSeoUrl = '';
00069 if ( $oVendor->getId() != 'root' ) {
00070 if ( !isset( $this->_aRootVendorUri[$iLang] ) ) {
00071 $oRootVendor = oxNew('oxvendor');
00072 $oRootVendor->loadInLang( $iLang, 'root' );
00073 $this->_aRootVendorUri[$iLang] = $this->getVendorUri( $oRootVendor, $iLang );
00074 }
00075 $sSeoUrl .= $this->_aRootVendorUri[$iLang];
00076 }
00077
00078 $sSeoUrl .= $this->_prepareTitle( $oVendor->oxvendor__oxtitle->value, false, $oVendor->getLanguage() ) .'/';
00079 $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oVendor->getId(), $iLang );
00080
00081
00082 $this->_saveToDb( 'oxvendor', $oVendor->getId(), $oVendor->getBaseStdLink($iLang), $sSeoUrl, $iLang );
00083 }
00084 return $sSeoUrl;
00085 }
00086
00097 public function getVendorPageUrl( $oVendor, $iPage, $iLang = null, $blFixed = null )
00098 {
00099 if (!isset($iLang)) {
00100 $iLang = $oVendor->getLanguage();
00101 }
00102 $sStdUrl = $oVendor->getBaseStdLink($iLang) . '&pgNr=' . $iPage;
00103 $sParams = (int) ($iPage + 1);
00104
00105 $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00106 $sSeoUrl = $this->getVendorUri( $oVendor, $iLang ) . $sParams . "/";
00107
00108 if ( $blFixed === null ) {
00109 $blFixed = $this->_isFixed( 'oxvendor', $oVendor->getId(), $iLang );
00110 }
00111 return $this->_getFullUrl( $this->_getPageUri( $oVendor, 'oxvendor', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00112 }
00113
00122 public function getVendorUrl( $oVendor, $iLang = null )
00123 {
00124 if (!isset($iLang)) {
00125 $iLang = $oVendor->getLanguage();
00126 }
00127 return $this->_getFullUrl( $this->getVendorUri( $oVendor, $iLang ), $iLang );
00128 }
00129
00137 public function onDeleteVendor( $oVendor )
00138 {
00139 $oDb = oxDb::getDb();
00140 $sIdQuoted = $oDb->quote($oVendor->getId());
00141 $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxvendor'");
00142 $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
00143 }
00144
00153 protected function _getAltUri( $sObjectId, $iLang )
00154 {
00155 $sSeoUrl = null;
00156 $oVendor = oxNew( "oxvendor" );
00157 if ( $oVendor->loadInLang( $iLang, $sObjectId ) ) {
00158 $sSeoUrl = $this->getVendorUri( $oVendor, $iLang, true );
00159 }
00160 return $sSeoUrl;
00161 }
00162 }