Skip to content

Commit

Permalink
Revert "fix #2575"
Browse files Browse the repository at this point in the history
This reverts commit 0a5c368.
  • Loading branch information
mikspark committed Dec 19, 2016
1 parent 0a5c368 commit 6ca55ea
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions protected/modules/yupe/components/urlManager/LangUrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public function init()

$languages = implode('|', $languages);
$rules = [];
$langPattern = '/<' . $this->langParam . ':(' . $languages . ')>/';
$langPattern = '/<'.$this->langParam.':('.$languages.')>/';
foreach ($this->rules as $pattern => $route) {
if (is_array($route)) {
if (isset($route['pattern'])) {
$route['pattern'] = $langPattern . ltrim($route['pattern'], '/');
$route['pattern'] = $langPattern.ltrim($route['pattern'], '/');
$rules[] = $route;
}
} else {
$pattern = $langPattern . ltrim($pattern, '/');
$pattern = $langPattern.ltrim($pattern, '/');
$rules[$pattern] = $route;
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public function getLangFromCookie()
*/
public function getCookieKey()
{
return $this->langParam . '_' . ($this->isBackend() ? 'backend' : 'frontend');
return $this->langParam.'_'.($this->isBackend() ? 'backend' : 'frontend');
}


Expand All @@ -199,7 +199,7 @@ public function createUrl($route, $params = [], $ampersand = '&')
if ($this->getDefaultLang() === $params[$this->langParam]) {
unset($params[$this->langParam]);
} elseif (trim($route, '/') === '') {
return Yii::app()->getHomeUrl() . $params[$this->langParam];
return Yii::app()->getHomeUrl().$params[$this->langParam];
}
}

Expand All @@ -218,26 +218,26 @@ public function replaceLangInUrl($url, $lang = null)
$result = '';

if (isset($parsed['scheme'])) {
$result .= $parsed['scheme'] . '://';
$result .= $parsed['scheme'].'://';
}

if (isset($parsed['user'])) {
$result .= $parsed['user'];
if (isset($parsed['pass'])) {
$result .= ':' . $parsed['pass'];
$result .= ':'.$parsed['pass'];
}
$result .= '@';
}

if (isset($parsed['host'])) {
$result .= $parsed['host'] . '/';
$result .= $parsed['host'].'/';
}

if ('path' === $this->urlFormat && isset($parsed['path'])) {
$path = trim($parsed['path'], '/');

$replaced = preg_replace(
'#^(' . implode('|', $this->_languages) . '/){1}#',
'#^('.implode('|', $this->_languages).'){1}#',
$lang,
$path
);
Expand All @@ -246,15 +246,15 @@ public function replaceLangInUrl($url, $lang = null)
if ($path === $replaced && null !== $lang) {
$replaced = $lang;
if ($path !== '') {
$replaced .= '/' . $path;
$replaced .= '/'.$path;
}
}

$result .= $replaced;

if ($result !== '') {
if (strpos($url, '/') === 0) {
$result = '/' . $result;
$result = '/'.$result;
}

if (substr($url, -1) === '/') {
Expand All @@ -279,7 +279,7 @@ public function replaceLangInUrl($url, $lang = null)
$query = urldecode(http_build_query($queryParams));

if ($query !== '') {
$result .= '?' . $query;
$result .= '?'.$query;
}
}

Expand Down

0 comments on commit 6ca55ea

Please sign in to comment.