/** * Looks for "dispatch" parameter in REQUEST array and extracts controller, mode, action and extra parameters. * * @param array $req Request parameters * @param string $area Area * @return boolean always true */ function fn_get_route(&$req, $area = AREA) { $result = array(INIT_STATUS_OK); $is_allowed_url = fn_check_requested_url(); if (!$is_allowed_url) { $request_uri = fn_get_request_uri($_SERVER['REQUEST_URI']); $router = new Router($req); $router->addRoutes(fn_get_schema('routes', 'objects')); if ($params = $router->match($request_uri)) { $is_allowed_url = true; $req = $params; } } fn_set_hook('get_route', $req, $result, $area, $is_allowed_url); if (!$is_allowed_url) { $req = array('dispatch' => '_no_page'); } if (!empty($req['dispatch'])) { $dispatch = is_array($req['dispatch']) ? key($req['dispatch']) : $req['dispatch']; } else { $dispatch = 'index.index'; } rtrim($dispatch, '/.'); $dispatch = str_replace('/', '.', $dispatch); $parts = explode('.', $dispatch); Registry::set('runtime.controller', !empty($parts[0]) ? basename($parts[0]) : 'index'); Registry::set('runtime.mode', !empty($parts[1]) ? basename($parts[1]) : 'index'); Registry::set('runtime.action', !empty($parts[2]) ? $parts[2] : ''); Registry::set('runtime.dispatch_extra', !empty($parts[3]) ? $parts[3] : ''); Registry::set('runtime.checkout', false); Registry::set('runtime.root_template', 'index.tpl'); $req['dispatch'] = $dispatch; // URL's assignments Registry::set('config.current_url', fn_url_remove_service_params(Registry::get('config.' . ACCOUNT_TYPE . '_index') . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''))); return $result; }
/** * Generates URL according to schema definition * @param array $redirect_data redirect data * @param boolean $full generated full URL if true and URI part if false * @param array $query_string additional params to attach to URL * @return string URL */ function fn_generate_seo_url_from_schema($redirect_data, $full = true, $query_string = array()) { $seo_vars = fn_get_seo_vars(); if ($redirect_data['type'] == 's') { $http_path = Registry::get('config.http_path'); if (fn_allowed_for('ULTIMATE')) { $urls = fn_get_storefront_urls(Registry::get('runtime.company_id')); if (!empty($urls)) { $http_path = $urls['http_path']; } } $url = $http_path . $redirect_data['dest']; } else { $url = $seo_vars[$redirect_data['type']]['dispatch'] . '?' . $seo_vars[$redirect_data['type']]['item'] . '=' . $redirect_data['object_id']; } // do not add company_id to static routes if (fn_allowed_for('ULTIMATE') && $redirect_data['type'] != 's') { $url = fn_link_attach($url, 'company_id=' . Registry::get('runtime.company_id')); } if (!empty($query_string)) { $url = fn_link_attach($url, http_build_query($query_string)); } $lang_code = !empty($redirect_data['lang_code']) ? $redirect_data['lang_code'] : Registry::get('settings.Appearance.frontend_default_language'); if ($full) { $url = fn_url($url, 'C', 'http', $lang_code); } else { $url = fn_get_request_uri(fn_url($url, 'C', 'rel', $lang_code)); } return $url; }