00001 <?php
00002
00007 class oxSeoEncoderManufacturer extends oxSeoEncoder
00008 {
00014 protected static $_instance = null;
00015
00021 protected $_aRootManufacturerUri = null;
00022
00028 public static function getInstance()
00029 {
00030 if (!self::$_instance) {
00031 self::$_instance = oxNew("oxSeoEncoderManufacturer");
00032 }
00033
00034 if ( defined( 'OXID_PHP_UNIT' ) ) {
00035
00036 self::$_instance->_aSeoCache = array();
00037 }
00038
00039 return self::$_instance;
00040 }
00041
00050 public function getManufacturerUri( $oManufacturer, $iLang = null )
00051 {
00052 if (!isset($iLang)) {
00053 $iLang = $oManufacturer->getLanguage();
00054 }
00055
00056 if ( !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
00057
00058 if ( $iLang != $oManufacturer->getLanguage() ) {
00059 $sId = $oManufacturer->getId();
00060 $oManufacturer = oxNew('oxmanufacturer');
00061 $oManufacturer->loadInLang( $iLang, $sId );
00062 }
00063
00064 $sSeoUrl = '';
00065 if ( $oManufacturer->getId() != 'root' ) {
00066 if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
00067 $oRootManufacturer = oxNew('oxmanufacturer');
00068 $oRootManufacturer->loadInLang( $iLang, 'root' );
00069 $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
00070 }
00071 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00072 }
00073
00074 $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value .'/' );
00075 $sSeoUrl = $this->_getUniqueSeoUrl( $sSeoUrl, '/', $oManufacturer->getId(), $iLang );
00076
00077
00078 $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getStdLink(), $sSeoUrl, $iLang );
00079 }
00080 return $sSeoUrl;
00081 }
00082
00093 public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = false )
00094 {
00095 if (!isset($iLang)) {
00096 $iLang = $oManufacturer->getLanguage();
00097 }
00098 $sStdUrl = $oManufacturer->getStdLink() . '&pgNr=' . $iPage;
00099 $sParams = sprintf( "%0" . ceil( $this->_iCntPages / 10 + 1 ) . "d", $iPage + 1 );
00100
00101 $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00102 $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
00103
00104 return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00105 }
00106
00115 public function getManufacturerUrl( $oManufacturer, $iLang = null )
00116 {
00117 if (!isset($iLang)) {
00118 $iLang = $oManufacturer->getLanguage();
00119 }
00120 return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
00121 }
00122
00130 public function onDeleteManufacturer($oManufacturer)
00131 {
00132 $sId = oxDb::getDb()->quote($oManufacturer->getId());
00133 oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sId and oxtype = 'oxmanufacturers'");
00134 }
00135 }