Index: branches/5.2.x/core/kernel/managers/rewrite_url_processor.php
===================================================================
diff -u -r15343 -r15374
--- branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15343)
+++ branches/5.2.x/core/kernel/managers/rewrite_url_processor.php (.../rewrite_url_processor.php) (revision 15374)
@@ -1,6 +1,6 @@
Application->GetVar('_mod_rw_url_');
if ( $url ) {
- foreach ($this->_urlEndings as $url_ending) {
- if ( substr($url, strlen($url) - strlen($url_ending)) == $url_ending ) {
- $url = substr($url, 0, strlen($url) - strlen($url_ending));
- $default_ending = $this->Application->ConfigValue('ModRewriteUrlEnding');
-
- // user manually typed url with different url ending -> redirect to same url with default url ending
- if ( ($url_ending != $default_ending) && $this->Application->ConfigValue('ForceModRewriteUrlEnding') ) {
- $target_url = $this->Application->BaseURL() . $url . $default_ending;
-
- trigger_error('Mod-rewrite url "' . $_SERVER['REQUEST_URI'] . '" without "' . $default_ending . '" line ending used', E_USER_NOTICE);
- $this->Application->Redirect('external:' . $target_url, Array ('response_code' => 301));
- }
-
- break;
- }
- }
+ $this->_redirectToDefaultUrlEnding($url);
+ $url = $this->_removeUrlEnding($url);
}
$cached = $this->_getCachedUrl($url);
@@ -177,6 +163,68 @@
}
/**
+ * Detects url ending of given url
+ *
+ * @param string $url
+ * @return string
+ * @access protected
+ */
+ protected function _findUrlEnding($url)
+ {
+ if ( !$url ) {
+ return '';
+ }
+
+ foreach ($this->_urlEndings as $url_ending) {
+ if ( mb_substr($url, mb_strlen($url) - mb_strlen($url_ending)) == $url_ending ) {
+ return $url_ending;
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * Removes url ending from url
+ *
+ * @param string $url
+ * @return string
+ * @access protected
+ */
+ protected function _removeUrlEnding($url)
+ {
+ $url_ending = $this->_findUrlEnding($url);
+
+ if ( !$url_ending ) {
+ return $url;
+ }
+
+ return mb_substr($url, 0, mb_strlen($url) - mb_strlen($url_ending));
+ }
+
+ /**
+ * Redirects user to page with default url ending, where needed
+ *
+ * @param string $url
+ * @return void
+ * @access protected
+ */
+ protected function _redirectToDefaultUrlEnding($url)
+ {
+ $default_ending = $this->Application->ConfigValue('ModRewriteUrlEnding');
+
+ if ( $this->_findUrlEnding($url) == $default_ending || !$this->Application->ConfigValue('ForceModRewriteUrlEnding') ) {
+ return;
+ }
+
+ // user manually typed url with different url ending -> redirect to same url with default url ending
+ $target_url = $this->Application->BaseURL() . $this->_removeUrlEnding($url) . $default_ending;
+
+ trigger_error('Mod-rewrite url "' . $_SERVER['REQUEST_URI'] . '" without "' . $default_ending . '" line ending used', E_USER_NOTICE);
+ $this->Application->Redirect('external:' . $target_url, Array ('response_code' => 301));
+ }
+
+ /**
* Returns url parsing result from cache or false, when not yet parsed
*
* @param $url
@@ -314,9 +362,34 @@
*/
public function parse($string, $pass_name = 'pass')
{
+ // external url (could be back this website as well)
+ if ( preg_match('/external:(.*)/', $string, $regs) ) {
+ $string = $regs[1];
+ }
+
$vars = Array ($pass_name => Array ('m'));
- $url_parts = $string ? explode('/', trim(mb_strtolower($string, 'UTF-8'), '/')) : Array ();
+ $url_components = parse_url($string);
+ if ( isset($url_components['query']) ) {
+ parse_str($url_components['query'], $vars);
+ }
+
+ if ( isset($url_components['path']) ) {
+ if ( BASE_PATH ) {
+ $string = preg_replace('/^' . preg_quote(BASE_PATH, '/') . '/', '', $url_components['path'], 1);
+ }
+ else {
+ $string = $url_components['path'];
+ }
+
+ $string = $this->_removeUrlEnding(trim($string, '/'));
+ }
+ else {
+ $string = '';
+ }
+
+ $url_parts = $string ? explode('/', mb_strtolower($string, 'UTF-8')) : Array ();
+
$this->_partsToParse = $url_parts;
if ( ($this->HTTPQuery->Get('rewrite') == 'on') || !$url_parts ) {
@@ -450,7 +523,7 @@
* @return string
* @access protected
*
- * @todo Should find a way, how to determine what rewrite listerner page is it
+ * @todo Should find a way, how to determine what rewrite listener page is it
*/
protected function _parsePage(&$url_parts, &$vars)
{
@@ -808,7 +881,7 @@
{
return count($this->_partsToParse) > 0;
}
-
+
/**
* Builds url
*
Index: branches/5.2.x/core/units/helpers/user_helper.php
===================================================================
diff -u -r15176 -r15374
--- branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 15176)
+++ branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 15374)
@@ -1,6 +1,6 @@
event->SetRedirectParam('m_lang', $language_id); // data
$this->Application->Session->SetField('Language', $language_id); // interface
+
+ // set language for Front-End with enabled Mod-Rewrite
+ if ( MOD_REWRITE ) {
+ $this->_injectLanguageIntoUrl($language_id);
+ }
}
/**
+ * Inject language into whatever page user wants to go after login
+ *
+ * @param int $language_id
+ * @return void
+ * @access protected
+ */
+ protected function _injectLanguageIntoUrl($language_id)
+ {
+ $url = $this->Application->HREF($this->event->redirect, '', $this->event->getRedirectParams(), $this->event->redirectScript);
+ $vars = $this->Application->parseRewriteUrl($url, 'pass');
+
+ $vars['pass'] = implode(',', $vars['pass']);
+ $vars['m_lang'] = $language_id;
+ $template = $vars['t'];
+ unset($vars['is_virtual'], $vars['t']);
+
+ $this->event->redirect = $template;
+ $this->event->setRedirectParams($vars, false);
+ }
+
+ /**
* Checks that user is allowed to use super admin mode
*
* @return bool
Index: branches/5.2.x/core/kernel/application.php
===================================================================
diff -u -r15287 -r15374
--- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15287)
+++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15374)
@@ -1,6 +1,6 @@
UrlManager->rewrite->parse($url, $pass_name);
+ }
+
+ /**
* Returns base part of all urls, build on website
*
* @param string $prefix
Index: branches/5.2.x/core/kernel/utility/event.php
===================================================================
diff -u -r15250 -r15374
--- branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 15250)
+++ branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 15374)
@@ -1,6 +1,6 @@
redirectParams = kUtil::array_merge_recursive($this->redirectParams, $params);
+ if ( $append ) {
+ // append new parameters to parameters set before
+ $params = kUtil::array_merge_recursive($this->redirectParams, $params);
+ }
+
+ $this->redirectParams = $params;
}
/**