30 $aAddUrlParams = array();
32 return $aAddUrlParams;
42 if ($this->_aAddUrlParams === null) {
46 if (($iCur = $this->
getConfig()->getShopCurrency())) {
47 $this->_aAddUrlParams[
'cur'] = $iCur;
63 public function prepareUrlForNoSession($sUrl)
69 $sUrl = $oStr->preg_replace(
'/(\?|&(amp;)?)(force_)?(admin_)?sid=[a-z0-9\._]+&?(amp;)?/i',
'\1', $sUrl);
70 $sUrl = $oStr->preg_replace(
'/(&|\?)$/',
'', $sUrl);
76 if ($qpos = $oStr->strpos($sUrl,
'?')) {
77 if ($qpos == $oStr->strlen($sUrl) - 1) {
86 if (!$oStr->preg_match(
'/[&?](amp;)?lang=[0-9]+/i', $sUrl)) {
92 if (!$oStr->preg_match(
'/[&?](amp;)?cur=[0-9]+/i', $sUrl)) {
93 $iCur = (int) $oConfig->getShopCurrency();
95 $sUrl .=
"{$sSep}cur=" . $iCur;
112 public function prepareCanonicalUrl($sUrl)
119 $sUrl = $oStr->preg_replace(
'/(\?|&(amp;)?)(force_)?(admin_)?sid=[a-z0-9\._]+&?(amp;)?/i',
'\1', $sUrl);
120 $sUrl = $oStr->preg_replace(
'/(&|\?)$/',
'', $sUrl);
121 $sSep = ($oStr->strpos($sUrl,
'?') ===
false) ?
'?' :
'&';
127 if (!$oStr->preg_match(
'/[&?](amp;)?lang=[0-9]+/i', $sUrl) &&
128 $iLang != $oConfig->getConfigParam(
'sDefaultLang')
130 $sUrl .=
"{$sSep}lang=" . $iLang;
146 public function appendUrl($sUrl, $aAddParams, $blFinalUrl =
false)
151 $sSeparator = $this->_getUrlParametersSeparator($sUrl);
153 if (is_array($aAddParams)) {
154 foreach ($aAddParams as $sName => $sValue) {
155 if (isset($sValue) && !$oStr->preg_match(
"/\?(.*&(amp;)?)?" . preg_quote($sName) .
"=/", $sUrl)) {
156 $sUrl .= $sSeparator . $sName .
"=" . $sValue;
157 $sSeparator =
'&';
162 if ($sUrl && !$blFinalUrl) {
163 $sUrl .= $sSeparator;
177 public function cleanUrl($sUrl, $aParams = null)
181 if (is_array($aParams)) {
182 foreach ($aParams as $sParam) {
183 $sUrl = $oStr->preg_replace(
184 '/(\?|&(amp;)?)' . preg_quote($sParam) .
'=[a-z0-9\.]+&?(amp;)?/i',
190 $sUrl = $oStr->preg_replace(
'/(\?|&(amp;)?).+/i',
'\1', $sUrl);
193 return trim($sUrl,
"?");
206 if (!preg_match(
"#^https?://#i", $sUrl)) {
207 $sShopUrl = $this->
getConfig()->getSslShopUrl();
208 $sUrl = $sShopUrl . $sUrl;
224 public function processUrl($sUrl, $blFinalUrl =
true, $aParams = null, $iLang = null)
226 $sUrl = $this->appendUrl($sUrl, $aParams, $blFinalUrl);
248 $sUrl = $this->appendUrl($sUrl, $aAddParams, $blFinalUrl);
253 $sUrl =
getStr()->preg_replace(
'/(\?|&(amp;)?)$/',
'', $sUrl);
269 $sUrlHost = @parse_url($sUrl, PHP_URL_HOST);
271 if (is_null($sUrlHost)) {
276 foreach ($aHosts as $sHost) {
277 if ($sHost === $sUrlHost) {
301 $sUrl = $this->cleanUrlParams($sUrl);
303 return getStr()->preg_replace(
'/(\?|&(amp;)?)$/',
'', $sUrl);
314 public function cleanUrlParams($sUrl, $sConnector =
'&')
316 $aUrlParts = explode(
'?', $sUrl);
319 if (!is_array($aUrlParts) || count($aUrlParts) != 2) {
323 $sUrl = $aUrlParts[0];
324 $sUrlParams = $aUrlParts[1];
328 $sUrlParams = $oStrUtils->preg_replace(
329 array(
'@(\&(amp;){1,})@ix',
'@\&{1,}@',
'@\?&@x'),
330 array(
'&',
'&',
'?'),
335 parse_str($sUrlParams, $aUrlParams);
336 $sUrl .=
'?' . http_build_query($aUrlParams,
'', $sConnector);
355 public function appendParamSeparator($sUrl)
359 if ($oStr->preg_match(
'/(\?|&(amp;)?)$/i', $sUrl)) {
363 if ($oStr->strpos($sUrl,
'?') ===
false) {
367 return $sUrl .
'&';
379 $aServerParams[
"HTTPS"] = $oUtilsServer->getServerVar(
"HTTPS");
380 $aServerParams[
"HTTP_X_FORWARDED_PROTO"] = $oUtilsServer->getServerVar(
"HTTP_X_FORWARDED_PROTO");
381 $aServerParams[
"HTTP_HOST"] = $oUtilsServer->getServerVar(
"HTTP_HOST");
382 $aServerParams[
"REQUEST_URI"] = $oUtilsServer->getServerVar(
"REQUEST_URI");
384 $sProtocol =
"http://";
386 if (isset($aServerParams[
'HTTPS']) && (($aServerParams[
'HTTPS'] ==
'on' || $aServerParams[
'HTTPS'] == 1))
387 || (isset($aServerParams[
'HTTP_X_FORWARDED_PROTO']) && $aServerParams[
'HTTP_X_FORWARDED_PROTO'] ==
'https')
389 $sProtocol =
'https://';
392 $sUrl = $sProtocol . $aServerParams[
'HTTP_HOST'] . $aServerParams[
'REQUEST_URI'];
410 $sValue = str_replace(
"&",
"&", $sValue);
411 $aNavParams = explode(
"&", $sValue);
412 $aNavParams = array_filter($aNavParams);
414 foreach ($aNavParams as $sValue) {
415 $exp = explode(
"=", $sValue);
416 $aParams[$exp[0]] = $exp[1];
430 if ($sUrl && ($sHost = @parse_url($sUrl, PHP_URL_HOST))) {
431 if (!in_array($sHost, $aHosts)) {
447 if (isset($aLanguageUrls[$iLanguageId])) {
448 $this->
_addHost($aLanguageUrls[$iLanguageId], $aHosts);
459 if ($this->_aHosts === null) {
460 $this->_aHosts = array();
497 private function _getUrlParametersSeparator($sUrl)
503 if ($oStr->strpos($sUrl,
'?') ===
false) {
506 if ($sSeparator ===
'' && !$oStr->preg_match(
"/(\?|&(amp;)?)$/", $sUrl)) {
507 $sSeparator =
'&';