oxseoencodermanufacturer.php
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
00067 public function getManufacturerUri( $oManufacturer, $iLang = null )
00068 {
00069 if (!isset($iLang)) {
00070 $iLang = $oManufacturer->getLanguage();
00071 }
00072
00073 if ( !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
00074
00075 if ( $iLang != $oManufacturer->getLanguage() ) {
00076 $sId = $oManufacturer->getId();
00077 $oManufacturer = oxNew('oxmanufacturer');
00078 $oManufacturer->loadInLang( $iLang, $sId );
00079 }
00080
00081 $sSeoUrl = '';
00082 if ( $oManufacturer->getId() != 'root' ) {
00083 if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
00084 $oRootManufacturer = oxNew('oxmanufacturer');
00085 $oRootManufacturer->loadInLang( $iLang, 'root' );
00086 $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
00087 }
00088 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00089 }
00090
00091 $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value ) .'/';
00092 $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oManufacturer->getId(), $iLang );
00093
00094
00095 $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getStdLink(), $sSeoUrl, $iLang );
00096 }
00097 return $sSeoUrl;
00098 }
00099
00110 public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = null )
00111 {
00112 if (!isset($iLang)) {
00113 $iLang = $oManufacturer->getLanguage();
00114 }
00115 $sStdUrl = $oManufacturer->getStdLink() . '&pgNr=' . $iPage;
00116 $sParams = $sParams = (int) ($iPage + 1);
00117
00118 $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00119 $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
00120
00121 if ( $blFixed === null ) {
00122 $blFixed = $this->_isFixed( 'oxmanufacturers', $oManufacturer->getId(), $iLang );
00123 }
00124 return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00125 }
00126
00135 public function getManufacturerUrl( $oManufacturer, $iLang = null )
00136 {
00137 if (!isset($iLang)) {
00138 $iLang = $oManufacturer->getLanguage();
00139 }
00140 return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
00141 }
00142
00150 public function onDeleteManufacturer($oManufacturer)
00151 {
00152 $sIdQuoted = oxDb::getDb()->quote($oManufacturer->getId());
00153 oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxmanufacturers'");
00154 }
00155 }