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 (!self::$_instance) {
00031             self::$_instance = oxNew("oxSeoEncoderManufacturer");
00032         }
00033 
00034         if ( defined( 'OXID_PHP_UNIT' ) ) {
00035             // resetting cache
00036             self::$_instance->_aSeoCache = array();
00037         }
00038 
00039         return self::$_instance;
00040     }
00041 
00047     protected function _getUrlExtension()
00048     {
00049         return '/';
00050     }
00051 
00060     public function getManufacturerUri( $oManufacturer, $iLang = null )
00061     {
00062         if (!isset($iLang)) {
00063             $iLang = $oManufacturer->getLanguage();
00064         }
00065         // load from db
00066         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
00067 
00068             if ( $iLang != $oManufacturer->getLanguage() ) {
00069                 $sId = $oManufacturer->getId();
00070                 $oManufacturer = oxNew('oxmanufacturer');
00071                 $oManufacturer->loadInLang( $iLang, $sId );
00072             }
00073 
00074             $sSeoUrl = '';
00075             if ( $oManufacturer->getId() != 'root' ) {
00076                 if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
00077                     $oRootManufacturer = oxNew('oxmanufacturer');
00078                     $oRootManufacturer->loadInLang( $iLang, 'root' );
00079                     $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
00080                 }
00081                 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00082             }
00083 
00084             $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value .'/' );
00085             $sSeoUrl  = $this->_processSeoUrl( $sSeoUrl, $oManufacturer->getId(), $iLang );
00086 
00087             // save to db
00088             $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getStdLink(), $sSeoUrl, $iLang );
00089         }
00090         return $sSeoUrl;
00091     }
00092 
00103     public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = false )
00104     {
00105         if (!isset($iLang)) {
00106             $iLang = $oManufacturer->getLanguage();
00107         }
00108         $sStdUrl = $oManufacturer->getStdLink() . '&amp;pgNr=' . $iPage;
00109         $sParams = sprintf( "%0" . ceil( $this->_iCntPages / 10 + 1 ) . "d", $iPage + 1 );
00110 
00111         $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00112         $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
00113 
00114         return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00115     }
00116 
00125     public function getManufacturerUrl( $oManufacturer, $iLang = null )
00126     {
00127         if (!isset($iLang)) {
00128             $iLang = $oManufacturer->getLanguage();
00129         }
00130         return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
00131     }
00132 
00140     public function onDeleteManufacturer($oManufacturer)
00141     {
00142         $sId = oxDb::getDb()->quote($oManufacturer->getId());
00143         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sId and oxtype = 'oxmanufacturers'");
00144     }
00145 }

Generated on Tue Aug 18 09:21:06 2009 for OXID eShop CE by  doxygen 1.5.5