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