OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
oxseoencodertag.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
16  protected $_oTagPrepareUtil = null;
17 
27  public function getTagUri($sTag, $iLang = null, $sOxid = null)
28  {
29  return $this->_getDynamicTagUri($sTag, $this->getStdTagUri($sTag), "tag/{$sTag}/", $iLang, $sOxid);
30  }
31 
43  protected function _getDynamicTagUri($sTag, $sStdUrl, $sSeoUrl, $iLang, $sOxid = null)
44  {
45  $iShopId = $this->getConfig()->getShopId();
46 
47  $sStdUrl = $this->_trimUrl($sStdUrl);
48  $sObjectId = $this->getDynamicObjectId($iShopId, $sStdUrl);
49  $sSeoUrl = $this->_prepareUri($this->addLanguageParam($sSeoUrl, $iLang), $iLang);
50 
51  //load details link from DB
52  $sOldSeoUrl = $this->_loadFromDb('dynamic', $sObjectId, $iLang);
53  if ($sOldSeoUrl === $sSeoUrl) {
54  $sSeoUrl = $sOldSeoUrl;
55  } else {
56  if ($sOldSeoUrl) {
57  // old must be transferred to history
58  $this->_copyToHistory($sObjectId, $iShopId, $iLang, 'dynamic');
59  }
60  // creating unique
61  $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $sObjectId, $iLang);
62 
63  // inserting
64  $this->_saveToDb('dynamic', $sObjectId, $sStdUrl, $sSeoUrl, $iLang, $iShopId);
65  }
66 
67  return $sSeoUrl;
68  }
69 
77  protected function _prepareTag($sTag)
78  {
79  if ($this->_oTagPrepareUtil == null) {
80  $this->_oTagPrepareUtil = oxNew('oxtagcloud');
81  }
82 
83  return $sTag = $this->_oTagPrepareUtil->prepareTags($sTag);
84  }
85 
94  public function getStdTagUri($sTag, $blIncludeIndex = true)
95  {
96  // while tags are just strings, standard ulrs formatted stays here
97  $sUri = "cl=tag&amp;searchtag=" . rawurlencode($sTag);
98  if ($blIncludeIndex) {
99  $sUri = "index.php?" . $sUri;
100  }
101 
102  return $sUri;
103  }
104 
113  public function getTagUrl($sTag, $iLang = null)
114  {
115  if (!isset($iLang)) {
116  $iLang = oxRegistry::getLang()->getBaseLanguage();
117  }
118 
119  return $this->_getFullUrl($this->getTagUri($sTag, $iLang), $iLang);
120  }
121 
132  public function getTagPageUrl($sTag, $iPage, $iLang = null, $blFixed = false)
133  {
134  if (!isset($iLang)) {
135  $iLang = oxRegistry::getLang()->getBaseLanguage();
136  }
137  $sStdUrl = $this->getStdTagUri($sTag) . '&amp;pgNr=' . $iPage;
138  $sParams = (int) ($iPage + 1);
139 
140  $sStdUrl = $this->_trimUrl($sStdUrl, $iLang);
141  $sSeoUrl = $this->getTagUri($sTag, $iLang) . $sParams . "/";
142 
143  return $this->_getFullUrl($this->_getDynamicTagUri($sTag, $sStdUrl, $sSeoUrl, $iLang), $iLang);
144  }
145 }