Go to the documentation of this file.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 ( defined( 'OXID_PHP_UNIT' ) ) {
00031 self::$_instance = modInstances::getMod( __CLASS__ );
00032 }
00033
00034 if (!self::$_instance) {
00035 self::$_instance = oxNew("oxSeoEncoderManufacturer");
00036 if ( defined( 'OXID_PHP_UNIT' ) ) {
00037 modInstances::addMod( __CLASS__, self::$_instance);
00038 }
00039 }
00040
00041 if ( defined( 'OXID_PHP_UNIT' ) ) {
00042
00043 self::$_instance->_aSeoCache = array();
00044 }
00045
00046 return self::$_instance;
00047 }
00048
00054 protected function _getUrlExtension()
00055 {
00056 return '/';
00057 }
00058
00068 public function getManufacturerUri( $oManufacturer, $iLang = null, $blRegenerate = false )
00069 {
00070 if (!isset($iLang)) {
00071 $iLang = $oManufacturer->getLanguage();
00072 }
00073
00074 if ( $blRegenerate || !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
00075
00076 if ( $iLang != $oManufacturer->getLanguage() ) {
00077 $sId = $oManufacturer->getId();
00078 $oManufacturer = oxNew('oxmanufacturer');
00079 $oManufacturer->loadInLang( $iLang, $sId );
00080 }
00081
00082 $sSeoUrl = '';
00083 if ( $oManufacturer->getId() != 'root' ) {
00084 if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
00085 $oRootManufacturer = oxNew('oxmanufacturer');
00086 $oRootManufacturer->loadInLang( $iLang, 'root' );
00087 $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
00088 }
00089 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00090 }
00091
00092 $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value ) .'/';
00093 $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oManufacturer->getId(), $iLang );
00094
00095
00096 $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getBaseStdLink($iLang), $sSeoUrl, $iLang );
00097 }
00098 return $sSeoUrl;
00099 }
00100
00111 public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = null )
00112 {
00113 if (!isset($iLang)) {
00114 $iLang = $oManufacturer->getLanguage();
00115 }
00116 $sStdUrl = $oManufacturer->getBaseStdLink($iLang) . '&pgNr=' . $iPage;
00117 $sParams = $sParams = (int) ($iPage + 1);
00118
00119 $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00120 $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
00121
00122 if ( $blFixed === null ) {
00123 $blFixed = $this->_isFixed( 'oxmanufacturers', $oManufacturer->getId(), $iLang );
00124 }
00125 return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00126 }
00127
00136 public function getManufacturerUrl( $oManufacturer, $iLang = null )
00137 {
00138 if (!isset($iLang)) {
00139 $iLang = $oManufacturer->getLanguage();
00140 }
00141 return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
00142 }
00143
00151 public function onDeleteManufacturer( $oManufacturer )
00152 {
00153 $oDb = oxDb::getDb();
00154 $sIdQuoted = $oDb->quote( $oManufacturer->getId() );
00155 $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxmanufacturer'");
00156 $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
00157 }
00158
00167 protected function _getAltUri( $sObjectId, $iLang )
00168 {
00169 $sSeoUrl = null;
00170 $oManufacturer = oxNew( "oxmanufacturer" );
00171 if ( $oManufacturer->loadInLang( $iLang, $sObjectId ) ) {
00172 $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang, true );
00173 }
00174 return $sSeoUrl;
00175 }
00176 }