00001 <?php
00002
00007 class oxSeoEncoder extends oxSuperCfg
00008 {
00015 protected static $_aReservedWords = array( 'admin' );
00016
00022 protected static $_sSeparator = null;
00023
00029 protected $_iIdLength = 255;
00030
00036 protected static $_sPrefix = null;
00037
00043 protected $_sAddParams = null;
00044
00048 protected static $_instance = null;
00049
00055 public static function getInstance()
00056 {
00057 if (!self::$_instance) {
00058 self::$_instance = oxNew("oxSeoEncoder");
00059 }
00060 return self::$_instance;
00061 }
00062
00066 public function __construct()
00067 {
00068 $myConfig = $this->getConfig();
00069 if (!self::$_sSeparator) {
00070 $this->setSeparator( $myConfig->getConfigParam( 'sSEOSeparator' ) );
00071 }
00072 if (!self::$_sPrefix) {
00073 $this->setPrefix( $myConfig->getConfigParam( 'sSEOuprefix' ) );
00074 }
00075 $this->setReservedWords( $myConfig->getConfigParam( 'aSEOReservedWords' ) );
00076 }
00077
00089 protected function _copyToHistory( $sId, $iShopId, $iLang, $sType = null, $sNewId = null )
00090 {
00091 $sObjectid = $sNewId?"'$sNewId'":'oxobjectid';
00092 $sType = $sType?"oxtype = {$sType} and":'';
00093
00094
00095 $sSub = "select {$sObjectid}, MD5( LOWER( oxseourl ) ), oxshopid, oxlang, now() from oxseo where {$sType} oxobjectid = {$sId} and oxshopid = {$iShopId} and oxlang = {$iLang} limit 1";
00096 $sQ = "replace oxseohistory ( oxobjectid, oxident, oxshopid, oxlang, oxinsert ) {$sSub}";
00097 oxDb::getDb()->execute( $sQ );
00098 }
00099
00106 protected function _getAddParams()
00107 {
00108
00109 if ( $this->_sAddParams === null ) {
00110 $this->_sAddParams = $this->_getAddParamsFnc( oxConfig::getParameter('currency'), $this->getConfig()->getShopId() );
00111 }
00112 return $this->_sAddParams;
00113 }
00114
00124 protected function _getAddParamsFnc( $iCur, $iActShop )
00125 {
00126
00127 $this->_sAddParams = '';
00128 $sSep = '?';
00129 if ( $iCur ) {
00130 $this->_sAddParams .= $sSep . 'cur=' . $iCur;
00131 $sSep = '&';
00132 }
00133
00134
00135 return $this->_sAddParams;
00136 }
00137
00147 protected function _getDynamicUri( $sStdUrl, $sSeoUrl, $iLang )
00148 {
00149 $iShopId = $this->getConfig()->getShopId();
00150
00151 $sStdUrl = $this->_trimUrl( $sStdUrl );
00152 $sObjectId = md5( strtolower( $iShopId . $sStdUrl ) );
00153 $sSeoUrl = $this->_prepareTitle( $sSeoUrl );
00154
00155
00156 $sOldSeoUrl = $this->_loadFromDb( 'dynamic', $sObjectId, $iLang );
00157 if ( $sOldSeoUrl === $sSeoUrl ) {
00158 $sSeoUrl = $sOldSeoUrl;
00159 } else {
00160
00161 if ( $sOldSeoUrl ) {
00162 $oDb = oxDb::getDb();
00163 $this->_copyToHistory( $oDb->quote( $sObjectId ), $oDb->quote( $iShopId ), $iLang, $oDb->quote( 'dynamic' ) );
00164 }
00165
00166
00167 $sSeoUrl = $this->_getUniqueSeoUrl( $sSeoUrl, null, $sObjectId, $iLang );
00168
00169
00170 $this->_saveToDb( 'dynamic', $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId );
00171 }
00172
00173 return $sSeoUrl;
00174 }
00175
00184 protected function _getFullUrl( $sSeoUrl, $iLang = null)
00185 {
00186 return $this->getConfig()->getShopURL( $iLang ) . $sSeoUrl . $this->_getAddParams();
00187 }
00188
00199 protected function _getSeoIdent( $sSeoUrl, $iLang = null )
00200 {
00201 return md5( strtolower( $sSeoUrl ) );
00202 }
00203
00213 protected function _getStaticUri( $sStdUrl, $iShopId, $iLang )
00214 {
00215 $sIdent = md5( strtolower( $iShopId . $this->_trimUrl( $sStdUrl, $iLang ) ) );
00216 return $this->_loadFromDb( 'static', $sIdent, $iLang );
00217 }
00218
00232 protected function _getUniqueSeoUrl( $sSeoUrl, $sConstEnd = null, $sObjectId = null, $iObjectLang = null )
00233 {
00234 $oStr = getStr();
00235 if ($sConstEnd === null) {
00236 $aMatched = array();
00237 if ( preg_match('/\.html?$/i', $sSeoUrl, $aMatched ) ) {
00238 $sConstEnd = $aMatched[0];
00239 } else {
00240 if ($sSeoUrl{$oStr->strlen($sSeoUrl)-1} != '/') {
00241 $sSeoUrl .= '/';
00242 }
00243 $sConstEnd = '/';
00244 }
00245 }
00246
00247 $sBaseSeoUrl = $sSeoUrl;
00248 if ( $sConstEnd && $oStr->substr( $sSeoUrl, 0 - $oStr->strlen( $sConstEnd ) ) == $sConstEnd ) {
00249 $sBaseSeoUrl = $oStr->substr( $sSeoUrl, 0, $oStr->strlen( $sSeoUrl ) - $oStr->strlen( $sConstEnd ) );
00250 }
00251
00252 $oDb = oxDb::getDb();
00253 $iShopId = $this->getConfig()->getShopId();
00254 $iCnt = 0;
00255 $sCheckSeoUrl = $this->_trimUrl( $sSeoUrl );
00256 $sQ = "select 1 from oxseo where oxshopid = '{$iShopId}'";
00257
00258
00259 if ( $sObjectId && isset($iObjectLang) ) {
00260 $sQ .= " and not (oxobjectid = '{$sObjectId}' and oxlang = $iObjectLang)";
00261 }
00262
00263 while ( $oDb->getOne( $sQ ." and oxident='".$this->_getSeoIdent( $sCheckSeoUrl )."' " ) ) {
00264 $sAdd = '';
00265 if ( self::$_sPrefix ) {
00266 $sAdd = self::$_sSeparator . self::$_sPrefix;
00267 }
00268 if ( $iCnt ) {
00269 $sAdd .= self::$_sSeparator . $iCnt;
00270 }
00271 ++$iCnt;
00272
00273 $sSeoUrl = $sBaseSeoUrl . $sAdd . $sConstEnd;
00274 $sCheckSeoUrl = $this->_trimUrl( $sSeoUrl );
00275 }
00276 return $sSeoUrl;
00277 }
00278
00294 protected function _loadFromDb( $sType, $sId, $iLang, $iShopId = null, $sParams = null, $blStrictParamsCheck = true)
00295 {
00296 $oDb = oxDb::getDb( true );
00297 if ( $iShopId === null ) {
00298 $iShopId = $this->getConfig()->getShopId();
00299 }
00300
00301 $iShopId = $oDb->quote( $iShopId );
00302 $sId = $oDb->quote( $sId );
00303 $sType = $oDb->quote( $sType );
00304 $iLang = (int) $iLang;
00305
00306 $sQ = "select oxfixed, oxseourl, oxexpired, oxtype from oxseo where oxtype = {$sType}
00307 and oxobjectid = {$sId} and oxshopid = {$iShopId} and oxlang = {$iLang}";
00308
00309 $sParams = $sParams ? $sParams : '';
00310 if ( $sParams && $blStrictParamsCheck ) {
00311 $sQ .= " and oxparams = '{$sParams}'";
00312 } else {
00313 $sQ .= " order by oxparams = '{$sParams}' desc";
00314 }
00315 $sQ .= " limit 1";
00316
00317 $sSeoUrl = false;
00318 $oRs = $oDb->execute( $sQ );
00319 if ( $oRs && $oRs->recordCount() > 0 && !$oRs->EOF ) {
00320
00321 if ( $oRs->fields['oxexpired'] && ( $oRs->fields['oxtype'] == 'static' || $oRs->fields['oxtype'] == 'dynamic' ) ) {
00322
00323 $this->_copyToHistory( $sId, $iShopId, $iLang );
00324 $oDb->execute( "update oxseo set oxexpired = 0 where oxobjectid = {$sId} and oxlang = '{$iLang}' " );
00325 $sSeoUrl = $oRs->fields['oxseourl'];
00326 } elseif ( !$oRs->fields['oxexpired'] || $oRs->fields['oxfixed'] ) {
00327
00328 $sSeoUrl = $oRs->fields['oxseourl'];
00329 }
00330 }
00331 return $sSeoUrl;
00332 }
00333
00342 protected function _prepareTitle( $sTitle, $blSkipTruncate = false )
00343 {
00344
00345 $sTitle = $this->encodeString( $sTitle );
00346
00347
00348 $sTitle = strip_tags( $sTitle );
00349 $sSeparator = self::$_sSeparator;
00350 $sPrefix = self::$_sPrefix;
00351
00352 foreach ( self::$_aReservedWords as $sWord ) {
00353
00354 $sTitle = preg_replace( array( "/(\s$sWord)$/i", "/^($sWord\s)/i", "/(\s$sWord\s)/i", "/^($sWord)$/i",
00355 "/(\/$sWord)$/i", "/^($sWord\/)/i", "/(\/$sWord\/)/i"),
00356 " $1{$sSeparator}{$sPrefix}{$sSeparator} ", $sTitle );
00357 }
00358
00359
00360 $sExt = '';
00361 $oStr = getStr();
00362 $aMatched = array();
00363 if ( preg_match( '/\.html?$/i', $sTitle, $aMatched ) ) {
00364 $sExt = $oStr->substr( $sTitle, 0 - $oStr->strlen( $aMatched[0] ) );
00365 $sTitle = $oStr->substr( $sTitle, 0, $oStr->strlen( $sTitle ) - $oStr->strlen( $aMatched[0] ) );
00366 }
00367
00368
00369 if ( !$blSkipTruncate && $oStr->strlen( $sTitle ) > $this->_iIdLength ) {
00370
00371 if ( ( $iFirstSpace = $oStr->strstr( $oStr->substr( $sTitle, $this->_iIdLength ), ' ' ) !== false ) ) {
00372 $sTitle = $oStr->substr( $sTitle, 0, $this->_iIdLength + $iFirstSpace );
00373 }
00374 }
00375
00376
00377 $sRegExp = '/[^A-Za-z0-9'.preg_quote( self::$_sSeparator, '/').'\/]+/';
00378 $sTitle = trim( $oStr->preg_replace( array( "/\W*\/\W*/", $sRegExp ), array( "/", self::$_sSeparator ), $sTitle ), self::$_sSeparator );
00379
00380
00381 if ( !$sTitle ) {
00382 $sTitle = $this->_prepareTitle( self::$_sPrefix );
00383 }
00384
00385
00386 $sTitle .= $sExt;
00387
00388
00389 return $oStr->preg_replace( array( '|//+|', '/' . preg_quote( self::$_sSeparator . self::$_sSeparator, '/' ) .'+/' ),
00390 array( '/', self::$_sSeparator ), $sTitle );
00391 }
00392
00393
00412 protected function _saveToDb( $sType, $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId = null, $blFixed = 0, $sKeywords = '', $sDescription = '', $sParams = null )
00413 {
00414 $oDb = oxDb::getDb( true );
00415 if ( $iShopId === null ) {
00416 $iShopId = $this->getConfig()->getShopId();
00417 }
00418
00419 $iShopId = $oDb->quote( $iShopId );
00420
00421 $sObjectId = $oDb->quote( $sObjectId );
00422 $sType = $oDb->quote( $sType );
00423
00424 $iLang = (int) $iLang;
00425
00426 $sStdUrl = $this->_trimUrl( $sStdUrl );
00427 $sSeoUrl = $this->_trimUrl( $sSeoUrl );
00428
00429 $sIdent = $this->_getSeoIdent( $sSeoUrl );
00430
00431 $sStdUrl = $oDb->quote( $sStdUrl );
00432 $sSeoUrl = $oDb->quote( $sSeoUrl );
00433
00434 $blFixed = (int) $blFixed;
00435
00436 $sQ = "select oxfixed, oxexpired, ( oxstdurl like {$sStdUrl} and oxexpired != 2 ) as samestdurl, oxseourl like {$sSeoUrl} as sameseourl from oxseo where oxtype = {$sType} and oxobjectid = {$sObjectId} and oxshopid = {$iShopId} and oxlang = {$iLang} ";
00437 $sQ .= $sParams?" and oxparams = '{$sParams}' " : '';
00438 $sQ .= "limit 1";
00439
00440 $oRs = $oDb->execute( $sQ );
00441 if ( $oRs && $oRs->recordCount() > 0 && !$oRs->EOF ) {
00442
00443 if ( $oRs->fields['samestdurl'] && $oRs->fields['sameseourl'] && $oRs->fields['oxexpired'] ) {
00444
00445 return $oDb->execute( "update oxseo set oxexpired = 0 where oxtype = {$sType} and oxobjectid = {$sObjectId} and oxshopid = {$iShopId} and oxlang = {$iLang} limit 1" );
00446 } elseif ( $oRs->fields['oxexpired'] && !$oRs->fields['oxfixed'] ) {
00447
00448 $this->_copyToHistory( $sObjectId, $iShopId, $iLang, $sType );
00449 }
00450 }
00451 $oStr = getStr();
00452 $sKeywords = $sKeywords ? $oDb->quote( $oStr->htmlentities( $this->encodeString( strip_tags( $sKeywords ), false ) ) ) : false;
00453 $sDescription = $sDescription ? $oDb->quote( $oStr->htmlentities( strip_tags( $sDescription ) ) ) : false;
00454
00455
00456 $sParams = $sParams ? $oDb->quote( $sParams ) :'""';
00457
00458 $sQ = "insert into oxseo
00459 (oxobjectid, oxident, oxshopid, oxlang, oxstdurl, oxseourl, oxtype, oxfixed, oxexpired, oxkeywords, oxdescription, oxparams)
00460 values
00461 ( {$sObjectId}, '$sIdent', {$iShopId}, {$iLang}, {$sStdUrl}, {$sSeoUrl}, {$sType}, '$blFixed', '0',
00462 ".( $sKeywords ? $sKeywords : "''" ).", ".( $sDescription ? $sDescription : "''" ).", $sParams )
00463 on duplicate key update oxident = '$sIdent', oxstdurl = {$sStdUrl}, oxseourl = {$sSeoUrl}, oxfixed = '$blFixed', oxexpired = '0',
00464 oxkeywords = ".( $sKeywords ? $sKeywords : "oxkeywords" ).", oxdescription = ".( $sDescription ? $sDescription : "oxdescription" );
00465
00466 return $oDb->execute( $sQ );
00467 }
00468
00479 protected function _trimUrl( $sUrl, $iLang = null )
00480 {
00481 $sUrl = str_replace( $this->getConfig()->getShopURL( $iLang ), '', $sUrl );
00482
00483 return preg_replace( '/(force_)?sid=[a-z0-9\.]+&?(amp;)?/i', '', $sUrl );
00484 }
00485
00494 public function encodeString( $sString, $blReplaceChars = true )
00495 {
00496
00497 $sString = getStr()->html_entity_decode( $sString );
00498
00499 if ( $blReplaceChars ) {
00500 $aReplaceChars = $this->getConfig()->getConfigParam( 'aSeoReplaceChars' );
00501 $sString = str_replace( array_keys( $aReplaceChars ), array_values( $aReplaceChars ), $sString );
00502 }
00503
00504
00505 $aReplaceWhat = array( '&', '"', ''', '<', '>' );
00506 return str_replace( $aReplaceWhat, '', $sString );
00507 }
00508
00516 public function setSeparator( $sSeparator = null )
00517 {
00518 self::$_sSeparator = $sSeparator;
00519 if ( !self::$_sSeparator ) {
00520 self::$_sSeparator = '-';
00521 }
00522 }
00523
00531 public function setPrefix( $sPrefix )
00532 {
00533 if ($sPrefix) {
00534 self::$_sPrefix = $sPrefix;
00535 } else {
00536 self::$_sPrefix = 'oxid';
00537 }
00538 }
00539
00547 public function setIdLength( $iIdlength = null )
00548 {
00549 if ( isset( $iIdlength ) ) {
00550 $this->_iIdLength = $iIdlength;
00551 }
00552 }
00553
00561 public function setReservedWords( $aReservedWords )
00562 {
00563 self::$_aReservedWords = array_merge( self::$_aReservedWords, $aReservedWords );
00564 }
00565
00566
00578 public function markAsExpired( $sId, $iShopId = null, $iExpStat = 1, $iLang = null, $sParams = null )
00579 {
00580 $sWhere = $sId ? "where oxobjectid = '{$sId}'" : '';
00581 $sWhere .= isset( $iShopId ) ? ( $sWhere ? " and oxshopid = '{$iShopId}'" : "where oxshopid = '{$iShopId}'" ) : '';
00582 $sWhere .= $iLang ? ( $sWhere ? " and oxlang = '{$iLang}'" : "where oxlang = '{$iLang}'" ) : '';
00583 $sWhere .= $sParams ? ( $sWhere ? " and {$sParams}" : "where {$sParams}" ) : '';
00584
00585 $sQ = "update oxseo set oxexpired = '{$iExpStat}' $sWhere ";
00586 oxDb::getDb()->execute( $sQ );
00587 }
00588
00602 protected function _getPageUri( $oObject, $sType, $sStdUrl, $sSeoUrl, $sParams, $iLang = null, $blFixed = false )
00603 {
00604 if (!isset($iLang)) {
00605 $iLang = $oObject->getLanguage();
00606 }
00607 $iShopId = $this->getConfig()->getShopId();
00608
00609
00610 if ( ( $sOldSeoUrl = $this->_loadFromDb( $sType, $oObject->getId(), $iLang, $iShopId, $sParams ) ) ) {
00611 if ( $sOldSeoUrl === $sSeoUrl ) {
00612 return $sSeoUrl;
00613 } else {
00614 $oDb = oxDb::getDb();
00615 $this->_copyToHistory( $oDb->quote( $oObject->getId() ), $oDb->quote( $iShopId ), $iLang, $oDb->quote( $sType ) );
00616 }
00617 }
00618
00619 $this->_saveToDb( $sType, $oObject->getId(), $sStdUrl, $sSeoUrl, $iLang, $iShopId, (int) $blFixed, '', '', $sParams );
00620
00621 return $sSeoUrl;
00622 }
00623
00633 public function encodeStaticUrls( $aStaticUrl, $iShopId, $iLang )
00634 {
00635 $oDb = oxDb::getDb();
00636 $sValues = '';
00637 $sOldObjectId = null;
00638
00639
00640 $sStdUrl = $this->_trimUrl( trim( $aStaticUrl['oxseo__oxstdurl'] ) );
00641 $sObjectId = $aStaticUrl['oxseo__oxobjectid'];
00642
00643 if ( !$sObjectId || $sObjectId == '-1' ) {
00644 $sObjectId = md5( strtolower ( $iShopId.$sStdUrl ) );
00645 } else {
00646
00647 $sOldObjectId = $sObjectId;
00648
00649
00650 if ( md5( strtolower ( $iShopId.$sStdUrl ) ) != $sObjectId ) {
00651 $sObjectId = md5( strtolower ( $iShopId.$sStdUrl ) );
00652 }
00653 }
00654
00655 foreach ( $aStaticUrl['oxseo__oxseourl'] as $iLang => $sSeoUrl ) {
00656
00657
00658 if ( ( $sSeoUrl = trim( $sSeoUrl ) ) ) {
00659 $sSeoUrl = $this->_prepareTitle( $this->_trimUrl( $sSeoUrl ) );
00660 $sSeoUrl = $this->_getUniqueSeoUrl( $sSeoUrl, null, $sObjectId, $iLang );
00661 }
00662
00663 if ( $sOldObjectId ) {
00664
00665 if ( !$oDb->getOne( "select ('{$sSeoUrl}' like oxseourl) & ('{$sStdUrl}' like oxstdurl) from oxseo where oxobjectid = '{$sOldObjectId}' and oxshopid = '{$iShopId}' and oxlang = '{$iLang}' " ) ) {
00666 $this->_copyToHistory( $oDb->quote( $sOldObjectId ), $oDb->quote( $iShopId ), $iLang, $oDb->quote( 'static' ), $sObjectId );
00667 }
00668 }
00669
00670 if ( !$sSeoUrl || !$sStdUrl ) {
00671 continue;
00672 }
00673
00674 $sIdent = $this->_getSeoIdent( $sSeoUrl );
00675
00676 if ( $sValues ) {
00677 $sValues .= ', ';
00678 }
00679
00680 $sValues .= "( '{$sObjectId}', '{$sIdent}', '{$iShopId}', '{$iLang}', '$sStdUrl', '$sSeoUrl', 'static' )";
00681 }
00682
00683
00684 if ( $sOldObjectId ) {
00685 $oDb->execute( "delete from oxseo where oxobjectid in ( '{$sOldObjectId}', '{$sObjectId}' )" );
00686 }
00687
00688
00689 if ( $sValues ) {
00690
00691 $sQ = "insert into oxseo ( oxobjectid, oxident, oxshopid, oxlang, oxstdurl, oxseourl, oxtype ) values {$sValues} ";
00692 $oDb->execute( $sQ );
00693 }
00694
00695 return $sObjectId;
00696 }
00697
00705 public function copyStaticUrls( $iShopId )
00706 {
00707 $iBaseShopId = $this->getConfig()->getBaseShopId();
00708 if ( $iShopId != $iBaseShopId ) {
00709 foreach (array_keys(oxLang::getInstance()->getLanguageIds()) as $iLang) {
00710 $iLang = (int) $iLang;
00711 $sQ = "insert into oxseo ( oxobjectid, oxident, oxshopid, oxlang, oxstdurl, oxseourl, oxtype )
00712 select MD5( LOWER( CONCAT( '{$iShopId}', oxstdurl ) ) ), MD5( LOWER( oxseourl ) ),
00713 '$iShopId', oxlang, oxstdurl, oxseourl, oxtype from oxseo where oxshopid = '{$iBaseShopId}' and oxtype = 'static' and oxlang='$iLang' ";
00714 oxDb::getDb()->execute( $sQ );
00715 }
00716 }
00717 }
00718
00728 public function getStaticUrl( $sStdUrl, $iLang = null, $iShopId = null )
00729 {
00730 if (!isset($iShopId)) {
00731 $iShopId = $this->getConfig()->getShopId();
00732 }
00733 if (!isset($iLang)) {
00734 $iLang = oxLang::getInstance()->getEditLanguage();
00735 }
00736
00737 $sFullUrl = '';
00738 if ( ( $sSeoUrl = $this->_getStaticUri( $sStdUrl, $iShopId, $iLang ) ) ) {
00739 $sFullUrl = $this->_getFullUrl( $sSeoUrl, $iLang );
00740 }
00741 return $sFullUrl;
00742 }
00743
00760 public function addSeoEntry( $sObjectId, $iShopId, $iLang, $sStdUrl, $sSeoUrl, $sType, $blFixed = 1, $sKeywords = '', $sDescription = '', $sParams = '' )
00761 {
00762 $sSeoUrl = $this->_getUniqueSeoUrl( $this->_prepareTitle( $this->_trimUrl( $sSeoUrl ) ), null, $sObjectId, $iLang );
00763 $this->_saveToDb( $sType, $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId, $blFixed, $sKeywords, $sDescription, $sParams );
00764 }
00765
00776 public function deleteSeoEntry( $sObjectId, $iShopId, $iLang, $sType )
00777 {
00778 $sQ = "delete from oxseo where oxobjectid = '{$sObjectId}' and oxshopid = '{$iShopId}' and oxlang = '{$iLang}' and oxtype = '{$sType}' ";
00779 oxDb::getDb()->execute( $sQ );
00780 }
00781
00792 public function getMetaData( $sObjectId, $sMetaType, $iShopId = null, $iLang = null )
00793 {
00794 $iShopId = ( !isset( $iShopId ) ) ? $this->getConfig()->getShopId():$iShopId;
00795 $iLang = ( !isset( $iLang ) ) ? oxLang::getInstance()->getTplLanguage():$iLang;
00796
00797 return oxDb::getDb()->getOne( "select {$sMetaType} from oxseo where oxobjectid = '{$sObjectId}' and oxshopid = '{$iShopId}' and oxlang = '{$iLang}' order by oxparams" );
00798 }
00799
00813 public function getDynamicUrl( $sStdUrl, $sSeoUrl, $iLang )
00814 {
00815 return $this->_getFullUrl( $this->_getDynamicUri( $sStdUrl, $sSeoUrl, $iLang ) );
00816 }
00817
00826 public function fetchSeoUrl( $sStdUrl, $iLanguage = null )
00827 {
00828 $oDb = oxDb::getDb( true );
00829 $sStdUrl = $oDb->quote( $sStdUrl );
00830 $iLanguage = isset( $iLanguage ) ? $iLanguage : oxLang::getInstance()->getBaseLanguage();
00831
00832 $sSeoUrl = false;
00833
00834 $sQ = "select oxseourl, oxlang from oxseo where oxstdurl = $sStdUrl and oxlang = '$iLanguage' limit 1";
00835 $oRs = $oDb->execute( $sQ );
00836 if ( !$oRs->EOF ) {
00837 $sSeoUrl = $oRs->fields['oxseourl'];
00838 }
00839
00840 return $sSeoUrl;
00841 }
00842 }