oxseoencoderrecomm.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderRecomm extends oxSeoEncoder
00008 {
00012     protected static $_instance = null;
00013 
00019     public static function getInstance()
00020     {
00021         // disable caching for test modules
00022         if ( defined( 'OXID_PHP_UNIT' ) ) {
00023             self::$_instance = modInstances::getMod( __CLASS__ );
00024         }
00025 
00026         if ( !self::$_instance instanceof oxSeoEncoderRecomm ) {
00027             self::$_instance = oxNew( 'oxSeoEncoderRecomm' );
00028             if ( defined( 'OXID_PHP_UNIT' ) ) {
00029                 modInstances::addMod( __CLASS__, self::$_instance);
00030             }
00031         }
00032 
00033         if ( defined( 'OXID_PHP_UNIT' ) ) {
00034             // resetting cache
00035             self::$_instance->_aSeoCache = array();
00036         }
00037 
00038         return self::$_instance;
00039     }
00040 
00049     public function getRecommUri( $oRecomm, $iLang = null )
00050     {
00051         if ( !( $sSeoUrl = $this->_loadFromDb( 'dynamic', $oRecomm->getId(), $iLang ) ) ) {
00052             $myConfig = $this->getConfig();
00053 
00054             // fetching part of base url
00055             $sSeoUrl = $this->_getStaticUri(
00056                         $oRecomm->getBaseStdLink( $iLang, false ),
00057                         $myConfig->getShopId(),
00058                         $iLang
00059                     )
00060                     .
00061                     $this->_prepareTitle( $oRecomm->oxrecommlists__oxtitle->value );
00062 
00063             // creating unique
00064             $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oRecomm->getId(), $iLang );
00065 
00066             // inserting
00067             $this->_saveToDb( 'dynamic', $oRecomm->getId(), $oRecomm->getBaseStdLink( $iLang ), $sSeoUrl, $iLang, $myConfig->getShopId() );
00068         }
00069 
00070         return $sSeoUrl;
00071     }
00072 
00081     public function getRecommUrl( $oRecomm, $iLang = null)
00082     {
00083         if (!isset($iLang)) {
00084             $iLang = oxLang::getInstance()->getBaseLanguage();
00085         }
00086         return $this->_getFullUrl( $this->getRecommUri( $oRecomm, $iLang ), $iLang );
00087     }
00088 
00099     public function getRecommPageUrl( $oRecomm, $iPage, $iLang = null, $blFixed = false )
00100     {
00101         if (!isset($iLang)) {
00102             $iLang = oxLang::getInstance()->getBaseLanguage();
00103         }
00104         $sStdUrl = $oRecomm->getBaseStdLink( $iLang ) . '&amp;pgNr=' . $iPage;
00105         $sParams = (int) ($iPage + 1);
00106 
00107         $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00108         $sSeoUrl = $this->getRecommUri( $oRecomm, $iLang ) . $sParams . "/";
00109 
00110         return $this->_getFullUrl( $this->_getPageUri( $oRecomm, 'dynamic', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00111     }
00112 }