oxseoencodertag.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderTag extends oxSeoEncoder
00008 {
00009 
00015     protected $_oTagPrepareUtil = null;
00016 
00026     public function getTagUri($sTag, $iLang = null, $sOxid = null)
00027     {
00028         return $this->_getDynamicTagUri($sTag, $this->getStdTagUri($sTag), "tag/{$sTag}/", $iLang, $sOxid);
00029     }
00030 
00042     protected function _getDynamicTagUri($sTag, $sStdUrl, $sSeoUrl, $iLang, $sOxid = null)
00043     {
00044         $iShopId = $this->getConfig()->getShopId();
00045 
00046         $sStdUrl = $this->_trimUrl($sStdUrl);
00047         $sObjectId = $this->getDynamicObjectId($iShopId, $sStdUrl);
00048         $sSeoUrl = $this->_prepareUri($this->addLanguageParam($sSeoUrl, $iLang), $iLang);
00049 
00050         //load details link from DB
00051         $sOldSeoUrl = $this->_loadFromDb('dynamic', $sObjectId, $iLang);
00052         if ($sOldSeoUrl === $sSeoUrl) {
00053             $sSeoUrl = $sOldSeoUrl;
00054         } else {
00055             if ($sOldSeoUrl) {
00056                 // old must be transferred to history
00057                 $this->_copyToHistory($sObjectId, $iShopId, $iLang, 'dynamic');
00058             }
00059             // creating unique
00060             $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $sObjectId, $iLang);
00061 
00062             // inserting
00063             $this->_saveToDb('dynamic', $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId);
00064         }
00065 
00066         return $sSeoUrl;
00067     }
00068 
00076     protected function _prepareTag($sTag)
00077     {
00078         if ($this->_oTagPrepareUtil == null) {
00079             $this->_oTagPrepareUtil = oxNew('oxtagcloud');
00080         }
00081 
00082         return $sTag = $this->_oTagPrepareUtil->prepareTags($sTag);
00083     }
00084 
00093     public function getStdTagUri($sTag, $blIncludeIndex = true)
00094     {
00095         // while tags are just strings, standard ulrs formatted stays here
00096         $sUri = "cl=tag&amp;searchtag=" . rawurlencode($sTag);
00097         if ($blIncludeIndex) {
00098             $sUri = "index.php?" . $sUri;
00099         }
00100 
00101         return $sUri;
00102     }
00103 
00112     public function getTagUrl($sTag, $iLang = null)
00113     {
00114         if (!isset($iLang)) {
00115             $iLang = oxRegistry::getLang()->getBaseLanguage();
00116         }
00117 
00118         return $this->_getFullUrl($this->getTagUri($sTag, $iLang), $iLang);
00119     }
00120 
00131     public function getTagPageUrl($sTag, $iPage, $iLang = null, $blFixed = false)
00132     {
00133         if (!isset($iLang)) {
00134             $iLang = oxRegistry::getLang()->getBaseLanguage();
00135         }
00136         $sStdUrl = $this->getStdTagUri($sTag) . '&amp;pgNr=' . $iPage;
00137         $sParams = (int) ($iPage + 1);
00138 
00139         $sStdUrl = $this->_trimUrl($sStdUrl, $iLang);
00140         $sSeoUrl = $this->getTagUri($sTag, $iLang) . $sParams . "/";
00141 
00142         return $this->_getFullUrl($this->_getDynamicTagUri($sTag, $sStdUrl, $sSeoUrl, $iLang), $iLang);
00143     }
00144 }