Go to the documentation of this file.00001 <?php
00002
00007 class oxSeoEncoderTag extends oxSeoEncoder
00008 {
00012 protected static $_instance = null;
00013
00019 protected $_oTagPrepareUtil = null;
00020
00028 public static function getInstance()
00029 {
00030 return oxRegistry::get("oxSeoEncoderTag");
00031 }
00032
00042 public function getTagUri( $sTag, $iLang = null, $sOxid = null )
00043 {
00044 return $this->_getDynamicTagUri( $sTag, $this->getStdTagUri( $sTag ), "tag/{$sTag}/", $iLang, $sOxid );
00045 }
00046
00058 protected function _getDynamicTagUri( $sTag, $sStdUrl, $sSeoUrl, $iLang, $sOxid = null )
00059 {
00060 $iShopId = $this->getConfig()->getShopId();
00061
00062 $sStdUrl = $this->_trimUrl( $sStdUrl );
00063 $sObjectId = $this->getDynamicObjectId( $iShopId, $sStdUrl );
00064 $sSeoUrl = $this->_prepareUri( $this->addLanguageParam( $sSeoUrl, $iLang ), $iLang );
00065
00066
00067 $sOldSeoUrl = $this->_loadFromDb( 'dynamic', $sObjectId, $iLang );
00068 if ( $sOldSeoUrl === $sSeoUrl ) {
00069 $sSeoUrl = $sOldSeoUrl;
00070 } else {
00071
00072 if ( $sOldSeoUrl ) {
00073
00074 $this->_copyToHistory( $sObjectId, $iShopId, $iLang, 'dynamic' );
00075 }
00076
00077 $oTagCloud = oxNew('oxtagcloud');
00078 $sTag = $oTagCloud->prepareTags($sTag);
00079 $sViewName = getViewName( 'oxartextends', $iLang );
00080 $oDb = oxDb::getDb();
00081 $sQ = "select 1 from {$sViewName} where match ( {$sViewName}.oxtags )
00082 against( ".$oDb->quote( "\"".$sTag."\"" )." IN BOOLEAN MODE )";
00083
00084 if ( $sOxid ) {
00085 $sQ .= " and oxid = " . $oDb->quote( $sOxid );
00086 }
00087
00088 if ( $oDb->getOne( $sQ ) ) {
00089
00090 $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $sObjectId, $iLang );
00091
00092
00093 $this->_saveToDb( 'dynamic', $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId );
00094 } else {
00095 $sSeoUrl = false;
00096 }
00097 }
00098
00099 return $sSeoUrl;
00100 }
00101
00109 protected function _prepareTag( $sTag )
00110 {
00111 if ( $this->_oTagPrepareUtil == null ) {
00112 $this->_oTagPrepareUtil = oxNew('oxtagcloud');
00113 }
00114
00115 return $sTag = $this->_oTagPrepareUtil->prepareTags($sTag);
00116 }
00117
00126 public function getStdTagUri( $sTag, $blIncludeIndex = true )
00127 {
00128
00129 $sUri = "cl=tag&searchtag=" . rawurlencode( $sTag );
00130 if ( $blIncludeIndex ) {
00131 $sUri = "index.php?" . $sUri;
00132 }
00133 return $sUri;
00134 }
00135
00144 public function getTagUrl( $sTag, $iLang = null)
00145 {
00146 if (!isset($iLang)) {
00147 $iLang = oxRegistry::getLang()->getBaseLanguage();
00148 }
00149 return $this->_getFullUrl( $this->getTagUri( $sTag, $iLang ), $iLang );
00150 }
00151
00162 public function getTagPageUrl( $sTag, $iPage, $iLang = null, $blFixed = false )
00163 {
00164 if (!isset($iLang)) {
00165 $iLang = oxRegistry::getLang()->getBaseLanguage();
00166 }
00167 $sStdUrl = $this->getStdTagUri( $sTag ) . '&pgNr=' . $iPage;
00168 $sParams = (int) ($iPage + 1);
00169
00170 $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00171 $sSeoUrl = $this->getTagUri( $sTag, $iLang ) . $sParams . "/";
00172
00173 return $this->_getFullUrl( $this->_getDynamicTagUri( $sTag, $sStdUrl, $sSeoUrl, $iLang ), $iLang );
00174 }
00175 }