/** * Matches a user submitted path with parts defined by a map. Assigns and * returns an array of variables on a successful match. * * @param string $path Path used to match against this routing map * @return array|false An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) { $path = trim($path, $this->_urlDelimiter); $pathParts = explode($this->_urlDelimiter, $path, 2); if (in_array($pathParts[0], self::$_locales)) { $path = sizeof($pathParts) > 1 ? $pathParts[1] : ''; $currentLocale = $pathParts[0]; self::$_hasLocaleInUrl = true; } else { if (isset($this->_defaults['locale'])) { $currentLocale = $this->_defaults['locale']; } else { $currentLocale = self::$_defaultLocale; } } self::$_currentLocale = $currentLocale; $params = parent::match($path, $partial); if ($params) { Axis_Area::frontend(); $params = array_merge($params, array('locale' => $currentLocale)); } return $params; }
protected function _initArea() { Axis_Area::frontend(); }
/** * Matches a user submitted path with parts defined by a map. Assigns and * returns an array of variables on a successful match. * * @param string $path Path used to match against this routing map * @return array|false An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) { $path = trim($path, $this->_urlDelimiter); $pathParts = explode($this->_urlDelimiter, $path, 2); if (!empty($pathParts[0]) && strlen($pathParts[0]) > 1) { foreach (self::$_locales as $locale) { // preventing duplicate urls: // site.com/uk and site.com/uk_UA - only one will work after next check if (trim(Axis_Locale::getLanguageUrl($locale), '/') == $pathParts[0]) { self::$_hasLocaleInUrl = true; break; } } } if (self::$_hasLocaleInUrl) { $path = sizeof($pathParts) > 1 ? $pathParts[1] : ''; $currentLocale = $pathParts[0]; } elseif (isset($this->_defaults['locale'])) { $currentLocale = $this->_defaults['locale']; } else { $currentLocale = self::$_defaultLocale; } self::$_currentLocale = $currentLocale; $params = parent::match($path, $partial); if ($params) { Axis_Area::frontend(); $params = array_merge($params, array('locale' => $currentLocale)); } return $params; }