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 
00030     public static function getInstance()
00031     {
00032         return oxRegistry::get("oxSeoEncoderManufacturer");
00033     }
00034 
00040     protected function _getUrlExtension()
00041     {
00042         return '/';
00043     }
00044 
00054     public function getManufacturerUri( $oManufacturer, $iLang = null, $blRegenerate = false )
00055     {
00056         if (!isset($iLang)) {
00057             $iLang = $oManufacturer->getLanguage();
00058         }
00059         // load from db
00060         if ( $blRegenerate || !( $sSeoUrl = $this->_loadFromDb( 'oxmanufacturer', $oManufacturer->getId(), $iLang ) ) ) {
00061 
00062             if ( $iLang != $oManufacturer->getLanguage() ) {
00063                 $sId = $oManufacturer->getId();
00064                 $oManufacturer = oxNew('oxmanufacturer');
00065                 $oManufacturer->loadInLang( $iLang, $sId );
00066             }
00067 
00068             $sSeoUrl = '';
00069             if ( $oManufacturer->getId() != 'root' ) {
00070                 if ( !isset( $this->_aRootManufacturerUri[$iLang] ) ) {
00071                     $oRootManufacturer = oxNew('oxmanufacturer');
00072                     $oRootManufacturer->loadInLang( $iLang, 'root' );
00073                     $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri( $oRootManufacturer, $iLang );
00074                 }
00075                 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00076             }
00077 
00078             $sSeoUrl .= $this->_prepareTitle( $oManufacturer->oxmanufacturers__oxtitle->value, false, $oManufacturer->getLanguage() ) .'/';
00079             $sSeoUrl  = $this->_processSeoUrl( $sSeoUrl, $oManufacturer->getId(), $iLang );
00080 
00081             // save to db
00082             $this->_saveToDb( 'oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getBaseStdLink($iLang), $sSeoUrl, $iLang );
00083         }
00084         return $sSeoUrl;
00085     }
00086 
00097     public function getManufacturerPageUrl( $oManufacturer, $iPage, $iLang = null, $blFixed = null )
00098     {
00099         if (!isset($iLang)) {
00100             $iLang = $oManufacturer->getLanguage();
00101         }
00102         $sStdUrl = $oManufacturer->getBaseStdLink($iLang) . '&amp;pgNr=' . $iPage;
00103         $sParams = $sParams = (int) ($iPage + 1);
00104 
00105         $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00106         $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang ) . $sParams . "/";
00107 
00108         if ( $blFixed === null ) {
00109             $blFixed = $this->_isFixed( 'oxmanufacturers', $oManufacturer->getId(), $iLang );
00110         }
00111         return $this->_getFullUrl( $this->_getPageUri( $oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00112     }
00113 
00122     public function getManufacturerUrl( $oManufacturer, $iLang = null )
00123     {
00124         if (!isset($iLang)) {
00125             $iLang = $oManufacturer->getLanguage();
00126         }
00127         return $this->_getFullUrl( $this->getManufacturerUri( $oManufacturer, $iLang ), $iLang );
00128     }
00129 
00137     public function onDeleteManufacturer( $oManufacturer )
00138     {
00139         $oDb = oxDb::getDb();
00140         $sIdQuoted = $oDb->quote( $oManufacturer->getId() );
00141         $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxmanufacturer'");
00142         $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
00143     }
00144 
00153     protected function _getAltUri( $sObjectId, $iLang )
00154     {
00155         $sSeoUrl = null;
00156         $oManufacturer = oxNew( "oxmanufacturer" );
00157         if ( $oManufacturer->loadInLang( $iLang, $sObjectId ) ) {
00158             $sSeoUrl = $this->getManufacturerUri( $oManufacturer, $iLang, true );
00159         }
00160         return $sSeoUrl;
00161     }
00162 }